ukvapeclub Posted March 24, 2015 Share Posted March 24, 2015 (edited) Hi guys, I've started having some problems recently when trying to manually create an order for a customer via the back office. Everything's fine unless I try to use a cart rule (voucher) in the order. If I try to confirm an order that has a cart rule applied to it, I get a whitescreen. I enabled debugging and the error causing the whitescreen is: Fatal error: Call to a member function getOrderTotal() on a non-object in .../public_html/classes/CartRule.php on line 1050 I've had a look at CartRule.php and here's the section containing line 1050... /** * Return the estimated cart VAT from the difference between the total amount taxes included and taxes excluded. * @return float Estimated VAT rate. */ public function getCartAverageVatRate() { $context = Context::getContext(); $cart_amount_ti = $context->cart->getOrderTotal(true, Cart::ONLY_PRODUCTS); $cart_amount_te = $context->cart->getOrderTotal(false, Cart::ONLY_PRODUCTS); $cart_vat_amount = $cart_amount_ti - $cart_amount_te; if ($cart_vat_amount == 0 || $cart_amount_te == 0) $cart_average_vat_rate = 0; else $cart_average_vat_rate = Tools::ps_round($cart_vat_amount / $cart_amount_te, 3); return (float)$cart_average_vat_rate; } So, can anyone tell me what's going wrong here? I haven't changed anything to do with cart rules or Vat, so I'm at a loss. Thanks in advance! Stu Edited March 24, 2015 by ukvapeclub (see edit history) Link to comment Share on other sites More sharing options...
Vendedor Autônomo Posted March 24, 2015 Share Posted March 24, 2015 Same error here! But curiously, it happens only with a specific client. So I tried to put the order without the discount voucher and now it's working. But I still can't explain the reason to this. Link to comment Share on other sites More sharing options...
madimax Posted April 6, 2015 Share Posted April 6, 2015 hello, i had this problem this morning i go to classe CartRule.php and modify the function : public function getCartAverageVatRate() { //$context = Context::getContext(); $cart=new Cart(Context::getContext()->cart->id); $cart_amount_ti = $cart->getOrderTotal(true, Cart::ONLY_PRODUCTS); $cart_amount_te = $cart->getOrderTotal(false, Cart::ONLY_PRODUCTS); $cart_vat_amount = $cart_amount_ti - $cart_amount_te; if ($cart_vat_amount == 0 || $cart_amount_te == 0) $cart_average_vat_rate = 0; else $cart_average_vat_rate = Tools::ps_round($cart_vat_amount / $cart_amount_te, 3); return (float)$cart_average_vat_rate; } it works for me now when i add the voucher 3 Link to comment Share on other sites More sharing options...
betal Posted April 9, 2015 Share Posted April 9, 2015 Hello, I've got the same problem and i use the solution of madmix and it work's fine ! If it's a real bug in prestashop 1.6, may be necessary to put il in the Forge ? Thanks a lot madmix. Link to comment Share on other sites More sharing options...
madimax Posted April 9, 2015 Share Posted April 9, 2015 Hello, i have pull it on the forge ;-) Regards Link to comment Share on other sites More sharing options...
ukvapeclub Posted April 14, 2015 Author Share Posted April 14, 2015 Nice work madimax, well done Link to comment Share on other sites More sharing options...
linkin11 Posted June 1, 2015 Share Posted June 1, 2015 Fantastic, solved now. Many thanks Link to comment Share on other sites More sharing options...
cold_mind Posted June 24, 2015 Share Posted June 24, 2015 Thx madimax solved me. Link to comment Share on other sites More sharing options...
madimax Posted August 27, 2015 Share Posted August 27, 2015 ;-) Link to comment Share on other sites More sharing options...
dszuecs Posted December 1, 2015 Share Posted December 1, 2015 Hi there I am facing a similar issue - i get the fatal error while clicking on active carts in the backend: Fatal error: Call to undefined method CartRule::getCartAverageVatRate() in /override/classes/CartRule.php on line 156 Lines arround 156 shows this: /** * @see ObjectModel::delete() */ public function delete() { if (!parent::delete()) { return false; } Configuration::updateGlobalValue('PS_CART_RULE_FEATURE_ACTIVE', CartRule::isCurrentlyUsed($this->def['table'], true)); $r = Db::getInstance()->delete('cart_cart_rule', '`id_cart_rule` = '.(int)$this->id); $r &= Db::getInstance()->delete('cart_rule_carrier', '`id_cart_rule` = '.(int)$this->id); $r &= Db::getInstance()->delete('cart_rule_shop', '`id_cart_rule` = '.(int)$this->id); $r &= Db::getInstance()->delete('cart_rule_group', '`id_cart_rule` = '.(int)$this->id); $r &= Db::getInstance()->delete('cart_rule_country', '`id_cart_rule` = '.(int)$this->id); $r &= Db::getInstance()->delete('cart_rule_combination', '`id_cart_rule_1` = '.(int)$this->id.' OR `id_cart_rule_2` = '.(int)$this->id); $r &= Db::getInstance()->delete('cart_rule_product_rule_group', '`id_cart_rule` = '.(int)$this->id); $r &= Db::getInstance()->delete('cart_rule_product_rule', 'NOT EXISTS (SELECT 1 FROM `'._DB_PREFIX_.'cart_rule_product_rule_group` WHERE `'._DB_PREFIX_.'cart_rule_product_rule`.`id_product_rule_group` = `'._DB_PREFIX_.'cart_rule_product_rule_group`.`id_product_rule_group`)'); $r &= Db::getInstance()->delete('cart_rule_product_rule_value', 'NOT EXISTS (SELECT 1 FROM `'._DB_PREFIX_.'cart_rule_product_rule` WHERE `'._DB_PREFIX_.'cart_rule_product_rule_value`.`id_product_rule` = `'._DB_PREFIX_.'cart_rule_product_rule`.`id_product_rule`)'); return $r; I am on 1.6.1.3 right now, the issue started already with 1.6.1.1 Any advice? Cheers & thank you Dennis 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