vical Posted December 12, 2011 Share Posted December 12, 2011 Hi everyone, PrestaShop installed version 1.4.0.17 We work long, there are improvements of source code. We have a problem with the calculation of discounts on goods in the cart. We have made corrections to the module controllers / orderController.php /* Check minimal amount */ $currency = Currency::getCurrency((int)self::$cart->id_currency); $orderTotal = self::$cart->getOrderTotal(); $existingDiscounts = self::$cart->getDiscounts(true); if ( ((int)$orderTotal>=10000) ) { self::$cart->deleteDiscount(1);self::$cart->deleteDiscount(2);self::$cart->deleteDiscount(3); self::$cart->addDiscount(1); } elseif ( ((int)$orderTotal>=7500) and ((int)$orderTotal<10000) ) { self::$cart->deleteDiscount(1);self::$cart->deleteDiscount(2);self::$cart->deleteDiscount(3); self::$cart->addDiscount(2); } elseif ( ((int)$orderTotal>=5000) and ((int)$orderTotal<7500) ) { self::$cart->deleteDiscount(1);self::$cart->deleteDiscount(2);self::$cart->deleteDiscount(3); self::$cart->addDiscount(3); } elseif ( ((int)$orderTotal<5000)) { self::$cart->deleteDiscount(1);self::$cart->deleteDiscount(2);self::$cart->deleteDiscount(3); } $orderTotal = self::$cart->getOrderTotal(); At low volume products program works correctly GET http://soblazn-tmn/c...e&qty=1&op=down 200 OK 5.48s JSON products [Object { id=1725, link="http://soblazn-tmn/product.php?id_product=1725", quantity=2, ещё...}, Object { id=251, link="http://soblazn-tmn/product.php?id_product=251", quantity=2, ещё...}, Object { id=1695, link="http://soblazn-tmn/product.php?id_product=1695", quantity=1, ещё...}] discounts [Object { id="3", name="ADD5PERCENT :...", description="Скидка 5%", ещё...}] 0 Object { id="3", name="ADD5PERCENT :...", description="Скидка 5%", ещё...} id "3" name "ADD5PERCENT :..." description "Скидка 5%" nameDescription "ADD5PERCENT :..." link "http://soblazn-tmn/order.php?deleteDiscount=3" price "-308 руб" shippingCost "0 руб" wrappingCost "0 руб" nbTotalProducts "5" total "5 856 руб" productTotal "5 856 руб" hasError false If, however, increase the quantity of goods in the cart, the discount is not considered GET http://soblazn-tmn/c...ue&qty=99&op=up 200 OK 8.54s JSON products [Object { id=1725, link="http://soblazn-tmn/product.php?id_product=1725", quantity=100, ещё...}, Object { id=251, link="http://soblazn-tmn/product.php?id_product=251", quantity=100, ещё...}, Object { id=1695, link="http://soblazn-tmn/product.php?id_product=1695", quantity=100, ещё...}] discounts [Object { id="1", name="AddTenPercent :...", description="Скидка 10%", ещё...}, Object { id="1", name="AddTenPercent :...", description="Скидка 10%", ещё...}] 0 Object { id="1", name="AddTenPercent :...", description="Скидка 10%", ещё...} id "1" name "AddTenPercent :..." description "Скидка 10%" nameDescription "AddTenPercent :..." link "http://soblazn-tmn/order.php?deleteDiscount=1" price "-" 1 Object { id="1", name="AddTenPercent :...", description="Скидка 10%", ещё...} id "1" name "AddTenPercent :..." description "Скидка 10%" nameDescription "AddTenPercent :..." link "http://soblazn-tmn/order.php?deleteDiscount=1" price "-" shippingCost "0 руб" wrappingCost "0 руб" In addition, somewhere there is the second discount Can someone explain what we are doing wrong and how to calculate discounts on goods in your cart Many Thanks in advance 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