pixAN Posted May 7, 2018 Share Posted May 7, 2018 Bonjour, Dans le fichier Cart.php et dans la fonction getPackageShippingCost, J'applique les frais de port ci-dessous, seulement la dernière condition ne fonctionne pas (elseif(($show) && ($show_m) && ($show_l)) ...) : Je n'arrive pas à comprendre pourquoi? Pouvez-vous m'aider à y voir plus clair ? Merci $show = false; $show_m = false; $show_l = false; foreach ($products as $product) { if($product['weight']=="50.000000"){ $listFirst[]=$product; $show = true; } if($product['weight']=="100.000000"){ $listSecond[]=$product; $show_m = true; } if($product['weight']=="200.000000"){ $show_l = true; $listThird[]=$product; } } if ($show && $show_m){ $shipping_cost += $carrier->getDeliveryPriceByWeight($this->getTotalWeight($$listFirst), $id_zone) + $carrier->getDeliveryPriceByWeight($this->getTotalWeight($listSecond), $id_zone); } elseif($show && $show_l){ $shipping_cost += $carrier->getDeliveryPriceByWeight($this->getTotalWeight($listFirst), $id_zone) + $carrier->getDeliveryPriceByWeight($this->getTotalWeight($listThird), $id_zone); } elseif($show_m && $show_l){ $shipping_cost += $carrier->getDeliveryPriceByWeight($this->getTotalWeight($listSecond), $id_zone) + $carrier->getDeliveryPriceByWeight($this->getTotalWeight($listThird), $id_zone); } elseif($show && $show_m && $show_l){ $shipping_cost += $carrier->getDeliveryPriceByWeight($this->getTotalWeight($listFirst), $id_zone) + $carrier->getDeliveryPriceByWeight($this->getTotalWeight($listSecond), $id_zone) + $carrier->getDeliveryPriceByWeight($this->getTotalWeight($listThird), $id_zone); } else{ $shipping_cost += $carrier->getDeliveryPriceByWeight($this->getTotalWeight($product_list), $id_zone); } Link to comment Share on other sites More sharing options...
doekia Posted May 7, 2018 Share Posted May 7, 2018 si a et b sinon si a et c sinon si a et b et c tu comprends bien que la 3eme condition ne peux pas s'exécuter puisque soit la 1 a été remplie, soit la 2 pour que les condition de la 3 soient remplies Link to comment Share on other sites More sharing options...
pixAN Posted May 8, 2018 Author Share Posted May 8, 2018 ah oui en effet du coup comment dois-je indiquer les conditions pour que cela fonctionne. Autre question , j'aimerais que si : if($product['weight']=="200.000000") le poids du produit trouvé est 200 kg alors on considére qu'il vaut désormais 400kg? Merci Link to comment Share on other sites More sharing options...
pixAN Posted May 8, 2018 Author Share Posted May 8, 2018 Je crois avoir compris , j'ai ajouté : !&show,ou !@show_m ... a toutes les conditions Par contre une idée pour changer la valeur du poids de tous les produits qui font 200 kg? Link to comment Share on other sites More sharing options...
pixAN Posted May 8, 2018 Author Share Posted May 8, 2018 par contre il m'arrive d'avoir ce message quand j'ajoute un produit au panier Impossible to add the product to the cart. textStatus: 'parsererror' errorThrown: 'SyntaxError: JSON Parse error: Unexpected identifier "Array"' responseText:Array ( [id_product_attribute] => 0 [id_product] => 353 [cart_quantity] => 1 [id_shop] => 1 [name] ... Comment je peux débugger ce message? Link to comment Share on other sites More sharing options...
pixAN Posted May 8, 2018 Author Share Posted May 8, 2018 Sinon pour le poids j'ai essayé cela : if($product['weight']="200.000000"){ $product['weight']="400.000000"; $newWeight[]=$product['weight']; $listThird = array_replace($product, $newWeight); $show_j = true; print_r($listThird); } Dans le print-r j'ai bien le changement de poids mais ensuite il n'est pas pris en compte dans le panier Link to comment Share on other sites More sharing options...
pixAN Posted May 8, 2018 Author Share Posted May 8, 2018 En enlevant le print-r le message (impossible to add the product...) n'apparait plus, une explication à cela car c'est assez incompréhensible non? Link to comment Share on other sites More sharing options...
doekia Posted May 8, 2018 Share Posted May 8, 2018 Je ne suis pas sûr de comprendre ce que tu attends de ce forum? En premier il te suffit d'inverser et de mettre la condition la plus complète en premier si a et b et c sinon si a et b sinon si a et c Juste de la pure logique. En second tu écris du code, donc à priori tu développes. Ton code bug et tu nous demande comment le débuguer? Puis tu ajoutes du code qui fait encore plus planter et tu t'étonnes. Avant de commencer à coder, il faut au moins savoir comment ça fonctionne et comme c'est censé fonctionner. D'ailleurs j'ai peur de l'endroit où tu as écris ce code Donc je t'exhorte à relire les ouvrages suivant: - php pour les nuls - ajax pour les nuls - json pour les nuls - la logique pour les nuls - les overrides prestashop pour les nuls 1 Link to comment Share on other sites More sharing options...
pixAN Posted May 8, 2018 Author Share Posted May 8, 2018 C'est résolu, juste un soucis de condition, merci quand même. Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now