osCommerce France : Accueil Forum Portail osCommerce France Réponses aux questions Foire aux contributions

Bienvenue invité ( Connexion | Inscription )

 
Reply to this topicStart new topic
> Forcer la quantité commandée à la quantité disponible en stock, si la qté demandée > à la qté disponible
ren0
posté 14 May 2007, 18:18
Message #1


Ceinture blanche+ OSC
Icône de groupe

Groupe : Membres
Messages : 22
Inscrit : 16-March 07
Membre no 15964



Bonjour,

J'ai cru voir cette fonctionnalité sur des boutiques OsCommerce et je recherche une contribution qui permettrait de forcer la quantité demandée par le client à la quantité maximum disponible en stock. Je m'explique :

- Le client demande 24 articles "A"
- En stock, il n'y a que 20 articles "A"
- Par défaut dans shopping_cart.php, j'ai un message qui indique
CITATION
"Les produits marqués *** ne sont pas en stock dans la quantité désirée.
Merci de corriger la quantité des articles marqués (***), Merci"
et la quantité dans le panier reste à 24.

Je voudrais que la case "quantité" dans mon panier prenne la valeur de la quantité disponible en stock (dans notre exemple 20), voire (en super cadeau bonus) qu'un message du type
CITATION
"vous aviez demandé 24 articles A, or seulement 20 sont disponibles, la quantité d'article A a été modifiée en conséquence"
s'affiche wink.gif

J'ai fait moult recherches sur les sites francophone et US, sans succès... sad.gif
Est-ce que quelqu'un connaîtrait cette contribution, ou aurais-je rêvé ?!? confused.gif
Merci pour vos réponses.

Go to the top of the page
 
frdd
posté 16 May 2007, 08:59
Message #2


Ceinture orange OSC
Icône de groupe

Groupe : Membres
Messages : 265
Inscrit : 26-April 05
Lieu : Moselle
Membre no 5642



bjr ren0

j'ignore si la contrib existe

ou meme si c'est autorisé de modifier le choix du client de cette manière ,

perso , j'affiche les quantités dispo. avec interdiction de validation si stock zero

Après , c'est au client de corriger ses quantités pour valider sa commande ...

ca à l'air de mieux marcher depuis

après tu ajoute un peu de design par icones de disponibilité
ca égaye le look

@+


--------------------
amitiés , Didier
depuis fin 2018 sur OVH // en OSC 2.3.4. pack fr //
-------------------------------------------------
ms2.2fr delaballe (merci Olivier) // "main_categories1.0c_1" // del column_right ;compatibilité AOL // DYNAMENUS ; login box ; Twenga_xml ; leguide_xml ; create_pdf,v 1.4 (factures) ; quick stock update ; pdf_katalog_206 ok ; CCGV Trad (juste reductions ) ; Stock list ; Stock icones ; FCK editor (superbe ); newsletter subscriber ( ok sauf + bugs sur header et footer1/2 ) ; Admin Access Level (désactivé) ; Mini_Images_v2.0 ;No_popup_in_product_info;zoom image ds product listing ;Dynamic SiteMap v 3.1 with complete XML sitemaps ; Who's Online Enhancement ; Quantity Box in Product Listing v1.0 ; QPBPP 1.35 + correction CMCIC // Multiple Products Manager v2.6 // subcategory_textboxes_v2.0.4_1 // export universel en cours // mise a niveau PHP5 en cours //
Go to the top of the page
 
ren0
posté 17 May 2007, 17:10
Message #3


Ceinture blanche+ OSC
Icône de groupe

Groupe : Membres
Messages : 22
Inscrit : 16-March 07
Membre no 15964



Merci pour ta réponse frdd. En fait, j'explique, j'ai rajouté une boite de "saisie libre" des quantités dans le product_listing.php ou product_info.php. Le client peut donc taper 24 et ajouter 24 unités à son panier.

Alors, j'ai rajouté 2 petits bouts de code dans application_top.php.

1) Dans le case 'add_product' (si le client ajoute à son panier depuis product_listing.php ou product_info.php) :
CODE
                                  $stock_check = tep_check_stock($HTTP_POST_VARS['products_id'], $cart->get_quantity(tep_get_uprid($HTTP_POST_VARS['products_id'], $HTTP_POST_VARS['id'])) + $HTTP_POST_VARS['cart_quantity']);
                                  if (tep_not_null($stock_check)) {
                                  
                                  // mise à jour de la quantité saisie = quantité max disponible
                                  $HTTP_POST_VARS['cart_quantity']= tep_get_products_stock($HTTP_POST_VARS['products_id']);
                                  // mise à jour du panier pour mise à jour sous-total                                  $cart->update_quantity($HTTP_POST_VARS['products_id'],$HTTP_POST_VARS['cart_quantity']);
                                  // redirection vers le panier pour marquer l'attention du visiteur sur le fait que la quantité a été modifiée
                                  tep_redirect(tep_href_link(FILENAME_SHOPPING_CART, tep_get_all_get_params($parameters)));
                                  }


2) Dans le case 'buy_now'(au cas où il cliquerait sur "ajouter au panier" (bouton sans box de saisie libre de qté) pour un article dont il a déjà la qté max dans son panier)

CODE
                                  $stock_check = tep_check_stock($HTTP_GET_VARS['products_id'],                  $cart->get_quantity($HTTP_GET_VARS['products_id'])+1);
                                  if (tep_not_null($stock_check)) {
                                
                                  // mise à jour de la quantité saisie = quantité max disponible
                                  $HTTP_GET_VARS['cart_quantity']= tep_get_products_stock($HTTP_GET_VARS['products_id']);
                                  // mise à jour du panier pour mise à jour sous-total
                                  $cart->update_quantity($HTTP_GET_VARS['products_id'],$HTTP_GET_VARS['cart_quantity']);
                                  // redirection vers le panier pour marquer l'attention du visiteur sur le fait que la quantité a été modifiée
                                  tep_redirect(tep_href_link(FILENAME_SHOPPING_CART, tep_get_all_get_params($parameters)));
                                  }


J'ai dû également rajouter un petit bout de code dans "shopping_cart.php"
CODE
if (STOCK_CHECK == 'true') {
        $stock_check = tep_check_stock($products[$i]['id'], $products[$i]['quantity']);
        if (tep_not_null($stock_check)) {
          $any_out_of_stock = 1;
        
          //mise à jour de la quantité saisie = quantité max disponible
         $products[$i]['quantity']= tep_get_products_stock($products[$i]['id']);
          // mise à jour du panier pour mise à jour sous-total
          $cart->update_quantity($products[$i]['id'],$products[$i]['quantity']);
                    
          $products_name .= $stock_check;
        }
      }


Toutefois, de cette façon, le problème n'est pas complètement réglé sad.gif : en effet, dans le cas où le client a 19 articles A dans son panier et que, depuis le shopping_cart.php à la place de 19, il écrit "24" et clique sur "mettre à jour le panier" (alors qu'on a que 20 articles A en stock par exemple), certes la quantité en face de l'article est bien ramenée à 20 (quantité max en stock), mais la quantité "nb d'articles" affichée à côté de mon petit icone "panier" dans le "bandeau" header.php reste à 24 !!!!. Pour qu'elle se mette à jour, il faut que je clique sur "mettre à jour" dans shopping_cart.php, comment reproduire ce "clic" dans le code de shopping_cart.php ? Je bloque shock.gif sad.gif

De plus, les petites modif dans "application_top" sont efficaces si le client ajoute des articles depuis ailleurs que shopping_cart.php, mais me font "perdre" une information cruciale : l'article du panier sur lequel s'est produit la mise à jour forcée de la quantité (qté=qté max dispo en stock), d'où l'impossibilité de le notifier en rouge par exemple, pour qu'il soit bien visible du client... sad.gif

Je voudrais vraiment que le client ait une indication plus précise que
CITATION
"Les produits marqués *** ne sont pas en stock dans la quantité désirée.
Merci de corriger la quantité des articles marqués (***), Merci"

dans son panier confused.gif

Quand tu me dis que tu affiches les qté dispo, tu me parles de ton product_listing ou de ton product_info?
As-tu une idée pour que cela se fasse sur shopping_cart.php? comment as-tu fait si ce n'est pas dans ton product_listing/product_info ? cool.gif

Merci !
Go to the top of the page
 
frdd
posté 18 May 2007, 10:03
Message #4


Ceinture orange OSC
Icône de groupe

Groupe : Membres
Messages : 265
Inscrit : 26-April 05
Lieu : Moselle
Membre no 5642



slt reno0

je t'aurais aidé avec plaisir sur le code
seulement je suis très novice en php

je m'entraine comme je peux , mais suis loin de pouvoir te repondre .. sorry .. blush.gif

il y aura surement un pro du code qui saura te secourir en passant dessus , wink.gif


CITATION
Quand tu me dis que tu affiches les qté dispo, tu me parles de ton product_listing ou de ton product_info?
As-tu une idée pour que cela se fasse sur shopping_cart.php? comment as-tu fait si ce n'est pas dans ton product_listing/product_info ? cool.gif


la contrib me donne un indicateur a 5 ou 6 barrettes soit rouge verte ou orange
et en modifiant tres légèrement le code , j'ai mis la quantité réelle dessous au lieu des infos approximatives

et ceci aussi bien dans product_listing et product_info

sur le shopping_cart.php je ne l'ai pas , ( pas eu le temps de paufinner suite à mes probs de spam )
mais il doit y avoir moyen surement d'insérer le code dedans ...


contrib
CITATION
quantity_image_unlimited_v1_0

http://www.oscommerce.com/community/contributions,2507

sur include/module/product_listing j'ai modifié comme ceci:

CODE
          case 'PRODUCT_LIST_QUANTITY':
     /*            $lc_align = 'right';
                 $lc_text = ' ' . $listing['products_quantity'] . ' ';
     */
     // #################### START Qauntity images and text unlimited ############# //-->            
              $lc_align = 'center';
     //       $lc_text = ' ' . $listing['products_quantity'] . ' ';
              $lc_text = ' ' . picto_qty($listing['products_quantity']) . $listing['products_quantity'] . ' ';
     // move the "//" down one line to get actual numbers instead of icons.
     // =====================================================================
     // <!-- #################### END Qauntity images and text unlimited ############# //-->
                 break;
               case 'PRODUCT_LIST_WEIGHT':



et dans include /product_info comme ceci

ligne 118

CODE
<!--// #################### START Qauntity images and text unlimited ############# //-->
     <table border="2" cellpadding="0" cellspacing="0" style="border-collapse: collapse" bordercolor="#B90101" width="182" id="AutoNumber1">
       <tr>
         <td width="180" bgcolor="#FBF8F8">
         <p align="center"><font color="#FBF8F8">
     <!--// ancien original <?php echo $lc_text = '' . picto_qty($product_info['products_quantity']) . ''; ?>
     </font></td> //-->
     <!--// Modifié ( FRDD 2007 05 04 mettre valeur de stock sous icone image ) DEBUT   //-->
      </font><font face="Arial" size="2"><?php echo 'Situation du stock'; ?>
     <?php echo $lc_text = '&nbsp;' .  picto_qty($product_info['products_quantity']) . $product_info['products_quantity'] . " pieces" . '&nbsp;'; ?></font></td>
     <!--// Modifié ( FRDD 2007 05 04 mettre valeur de stock sous icone image ) FIN   //-->
       </tr>
     </table>
     <!--// #################### END Qauntity images and text unlimited ############# // -->


et ligne.226

CODE
<!--// #################### START Qauntity images and text unlimited ############# //-->
     <!--// Modifié ( FRDD 2007 05 04 mettre valeur de stock sous icone image ) DEBUT   //-->            
                     <td class="main" align="center"><?php echo 'Situation du stock'; ?>
     <?php echo $lc_text = '' . picto_qty($product_info['products_quantity']) . $product_info['products_quantity'] . " pieces" . ''; ?></font></td></p>
     <!--// Modifié ( FRDD 2007 05 04 mettre valeur de stock sous icone image ) FIN   //-->                
     <!--// #################### END Qauntity images and text unlimited ############# //-->



tu mets soit l'un soit l'autre soit les deux
suivant que tu veuilles l'afficher dans le corps du produit ou le cadre inférieur .

et derniere modif ,

catalog/includes/functions/general.php

au lieu de


CODE
// #################### START Qauntity images and text unlimited #############
   function picto_qty($quantity=0) {
   global $warning_stock;
   if      ($quantity <=-900 ) { $picto = tep_image(DIR_QUANTITY_ICONS.'stock_red_6.gif', TEXT_STOCK_TEMP).'
   '. TEXT_STOCK_TEMP;
   }
   elseif (($quantity <= -800 ) and ($quantity >= -899 )) {  $picto = tep_image(DIR_QUANTITY_ICONS.'stock_red_6.gif', TEXT_STOCK_EOL).'
   '. TEXT_STOCK_EOL;
   }
   elseif (($quantity <= -700 ) and ($quantity >= -799 )) {  $picto = tep_image(DIR_QUANTITY_ICONS.'stock_orange_6.gif', TEXT_STOCK_24).'
   '. TEXT_STOCK_24;
   }
   elseif (($quantity <= -600 ) and ($quantity >= -699 )) {  $picto = tep_image(DIR_QUANTITY_ICONS.'stock_orange_6.gif', TEXT_STOCK_SOON).'
   '. TEXT_STOCK_SOON;
   }
   elseif (($quantity <= -500 ) and ($quantity >= -599 )) {  $picto = tep_image(DIR_QUANTITY_ICONS.'stock_red_4.gif', TEXT_STOCK_ASK).'
   '. TEXT_STOCK_ASK;
   }
   elseif (($quantity <= -400 ) and ($quantity >= -499 )) {  $picto = tep_image(DIR_QUANTITY_ICONS.'stock_red_6.gif', TEXT_STOCK_3WEEKS).'
   '. TEXT_STOCK_3WEEKS;
   }
   elseif (($quantity <= -300 ) and ($quantity >= -399 )) {  $picto = tep_image(DIR_QUANTITY_ICONS.'stock_red_3.gif', TEXT_STOCK_1WEEKS).'
   '. TEXT_STOCK_1WEEKS;
   }
   elseif (($quantity <= -200 ) and ($quantity >= -299 )) {  $picto = tep_image(DIR_QUANTITY_ICONS.'stock_orange_3.gif', TEXT_STOCK_DAYS ).'
   '. TEXT_STOCK_DAYS;
   }
   elseif (($quantity <= -0 )   and ($quantity >= -199 )) {  $picto = tep_image(DIR_QUANTITY_ICONS.'stock_orange_3.gif', TEXT_STOCK_BUY).'
   '. TEXT_STOCK_BUY;
   }
   elseif (($quantity >= 1 )    and ($quantity <= 1 ))    {  $picto = tep_image(DIR_QUANTITY_ICONS.'stock_green_1.gif', TEXT_STOCK_VERY_FEW).'
   '. TEXT_STOCK_VERY_FEW;
   }
   elseif (($quantity >= 2 )    and ($quantity <= 2 ))    {  $picto = tep_image(DIR_QUANTITY_ICONS.'stock_green_2.gif', TEXT_STOCK_VERY_FEW).'
   '. TEXT_STOCK_VERY_FEW;
   }
   elseif (($quantity >= 3 )    and ($quantity <= 3 ))    {  $picto = tep_image(DIR_QUANTITY_ICONS.'stock_green_3.gif', TEXT_STOCK_FEW).'
   '. TEXT_STOCK_FEW;
   }
   elseif (($quantity >= 4 )    and ($quantity <= 4 ))    {  $picto = tep_image(DIR_QUANTITY_ICONS.'stock_green_4.gif', TEXT_STOCK_FEW).'
   '. TEXT_STOCK_FEW;
   }
   elseif (($quantity >= 5 )    and ($quantity <= 5 ))     {  $picto = tep_image(DIR_QUANTITY_ICONS.'stock_green_5.gif', TEXT_STOCK_FEW).'
   '. TEXT_STOCK_FEW;
   }
   else   { $picto = tep_image(DIR_QUANTITY_ICONS.'stock_green_6.gif', TEXT_STOCK_ON_STOCK ).'
   '. TEXT_STOCK_ON_STOCK;
   }
   return $picto;
   }
  
   // #################### END Qauntity images and text unlimited #############


j'ai mis :

CODE
// #################### START Qauntity images and text unlimited #############
   function picto_qty($quantity=0) {
   global $warning_stock;
   if      ($quantity <=-900 ) { $picto = tep_image(DIR_QUANTITY_ICONS.'stock_red_6.gif', TEXT_STOCK_TEMP).'
   ';
   }
   elseif (($quantity <= 1 ) and ($quantity >= 1 )) {  $picto = tep_image(DIR_QUANTITY_ICONS.'stock_red_1.gif', TEXT_STOCK_EOL).'
   ';
   }
  
   elseif (($quantity <= 2 ) and ($quantity >= 2 )) {  $picto = tep_image(DIR_QUANTITY_ICONS.'stock_red_2.gif', TEXT_STOCK_ASK).'
   ';
   }
   elseif (($quantity <= 0 ) and ($quantity >= -5000 )) {  $picto = tep_image(DIR_QUANTITY_ICONS.'stock_red_6.gif', TEXT_STOCK_ASK).'
   ';
   }
  
   elseif (($quantity <= 5 ) and ($quantity >= 3 )) {  $picto = tep_image(DIR_QUANTITY_ICONS.'stock_orange_6.gif', TEXT_STOCK_SOON).'
   ';
   }
  
  
  
  
   elseif (($quantity <= -699 ) and ($quantity >= -699 )) {  $picto = tep_image(DIR_QUANTITY_ICONS.'stock_red_6.gif', TEXT_STOCK_3WEEKS).'
   ';
   }
   elseif (($quantity <= -300 ) and ($quantity >= -399 )) {  $picto = tep_image(DIR_QUANTITY_ICONS.'stock_red_3.gif', TEXT_STOCK_1WEEKS).'
   ';
   }
   elseif (($quantity <= -200 ) and ($quantity >= -299 )) {  $picto = tep_image(DIR_QUANTITY_ICONS.'stock_orange_3.gif', TEXT_STOCK_DAYS ).'
   ';
   }
   elseif (($quantity <= -700 )   and ($quantity >= -700 )) {  $picto = tep_image(DIR_QUANTITY_ICONS.'stock_orange_3.gif', TEXT_STOCK_BUY).'
   ';
   }
  
  
   elseif (($quantity >= 5 )    and ($quantity <= 5 ))    {  $picto = tep_image(DIR_QUANTITY_ICONS.'stock_green_1.gif', TEXT_STOCK_VERY_FEW).'
   ';
   }
   elseif (($quantity >= 10 )    and ($quantity <= 19 ))    {  $picto = tep_image(DIR_QUANTITY_ICONS.'stock_green_2.gif', TEXT_STOCK_VERY_FEW).'
   ';
   }
   elseif (($quantity >= 20 )    and ($quantity <= 29 ))    {  $picto = tep_image(DIR_QUANTITY_ICONS.'stock_green_3.gif', TEXT_STOCK_FEW).'
   ';
   }
   elseif (($quantity >= 30 )    and ($quantity <= 39 ))    {  $picto = tep_image(DIR_QUANTITY_ICONS.'stock_green_4.gif', TEXT_STOCK_FEW).'
   ';
   }
   elseif (($quantity >= 40 )    and ($quantity <= 49 ))     {  $picto = tep_image(DIR_QUANTITY_ICONS.'stock_green_5.gif', TEXT_STOCK_FEW).'
   ';
   }
  
   else   { $picto = tep_image(DIR_QUANTITY_ICONS.'stock_green_6.gif', TEXT_STOCK_ON_STOCK ).'
   ';
   }
   return $picto;
   }
  
   // #################### END Qauntity images and text unlimited #############



je pense que le code doit étre insérable dans le panier aussi ...



a+


--------------------
amitiés , Didier
depuis fin 2018 sur OVH // en OSC 2.3.4. pack fr //
-------------------------------------------------
ms2.2fr delaballe (merci Olivier) // "main_categories1.0c_1" // del column_right ;compatibilité AOL // DYNAMENUS ; login box ; Twenga_xml ; leguide_xml ; create_pdf,v 1.4 (factures) ; quick stock update ; pdf_katalog_206 ok ; CCGV Trad (juste reductions ) ; Stock list ; Stock icones ; FCK editor (superbe ); newsletter subscriber ( ok sauf + bugs sur header et footer1/2 ) ; Admin Access Level (désactivé) ; Mini_Images_v2.0 ;No_popup_in_product_info;zoom image ds product listing ;Dynamic SiteMap v 3.1 with complete XML sitemaps ; Who's Online Enhancement ; Quantity Box in Product Listing v1.0 ; QPBPP 1.35 + correction CMCIC // Multiple Products Manager v2.6 // subcategory_textboxes_v2.0.4_1 // export universel en cours // mise a niveau PHP5 en cours //
Go to the top of the page
 

Reply to this topicStart new topic
1 utilisateur(s) sur ce sujet (1 invité(s) et 0 utilisateur(s) anonyme(s))
0 membre(s) :

 



RSS Version bas débit Nous sommes le : 28th March 2024 - 22:21
Ce site est déclaré auprès de la commision Nationale
de l'Informatique et des Libertés (déclaration n°: 1043896)