paulormf Posted July 12, 2014 Share Posted July 12, 2014 Hello for all!!! I had set the previous version of prestahshop (1.5), a condition where a specific group of customers would have to reach a minimum value to make the purchase. With the upgrade to the new version of prestashop (1.6), all groups are needing to reach this minimum. Could someone give me a hand? url: www.shopsensual.com.br presta: 1.6.0.8 1 Link to comment Share on other sites More sharing options...
Stadtsirene Posted November 6, 2014 Share Posted November 6, 2014 (edited) Hey! I replaced this (OrderController.php) / PS1.6.0.9 // Check minimal amount $currency = Currency::getCurrency((int)$this->context->cart->id_currency); $orderTotal = $this->context->cart->getOrderTotal(); $minimal_purchase = Tools::convertPrice((float)Configuration::get('PS_PURCHASE_MINIMUM'), $currency); if ($this->context->cart->getOrderTotal(false, Cart::ONLY_PRODUCTS) < $minimal_purchase && $this->step > 0) { $this->step = 0; $this->errors[] = sprintf( Tools::displayError('A minimum purchase total of %1s (tax excl.) is required in order to validate your order, current purchase total is %2s (tax excl.).'), Tools::displayPrice($minimal_purchase, $currency), Tools::displayPrice($this->context->cart->getOrderTotal(false, Cart::ONLY_PRODUCTS), $currency) ); } With /* START */ // Check minimal amount $currency = Currency::getCurrency((int)$this->context->cart->id_currency); $orderTotal = $this->context->cart->getOrderTotal(); $minimal_purchase = Tools::convertPrice((float)Configuration::get('PS_PURCHASE_MINIMUM'), $currency); /**/ $customer = new Customer((int)(self::$cookie->id_customer)); $groupes = $customer->getGroups(); /**/ if ($this->context->cart->getOrderTotal(false, Cart::ONLY_PRODUCTS) < 100 and ($groupes[0]==4) && $this->step > 0) { $this->step = 0; $this->errors[] = sprintf( Tools::displayError('A minimum purchase total of 100 (tax excl.) is required in order to validate your order, current purchase total is %2s (tax excl.).'), Tools::displayPrice($minimal_purchase, $currency), Tools::displayPrice($this->context->cart->getOrderTotal(false, Cart::ONLY_PRODUCTS), $currency) ); } /**/ if ($this->context->cart->getOrderTotal(false, Cart::ONLY_PRODUCTS) < $minimal_purchase && $this->step > 0) { $this->step = 0; $this->errors[] = sprintf( Tools::displayError('A minimum purchase total of %1s (tax excl.) is required in order to validate your order, current purchase total is %2s (tax excl.).'), Tools::displayPrice($minimal_purchase, $currency), Tools::displayPrice($this->context->cart->getOrderTotal(false, Cart::ONLY_PRODUCTS), $currency) ); } /* END */ Change bold-written numbers (false, Cart::ONLY_PRODUCTS) < 100 and ($groupes[0]==4) with your min. purchase and special group-id. I know ... its dirty .... Any other ideas? Edited November 6, 2014 by Stadtsirene (see edit history) Link to comment Share on other sites More sharing options...
Drazh Posted February 15, 2015 Share Posted February 15, 2015 (edited) Hi,me too i need this modification and i made it in the file /controllers/front/OrderController.php.... but nothing happens The group id i want to apply le limitation is number 4, like your example, but they can purchase without any limitation...Any suggestions? Thank you. UPDATE: sorry i use the OrderOpcController.php not the 5 steps OrderController.php. I have find a solution for the one-step checkout (OrderOpcController.php): Find and replace this: /* Check minimal amount */ $currency = Currency::getCurrency((int)$this->context->cart->id_currency); $minimal_purchase = Tools::convertPrice((float)Configuration::get('PS_PURCHASE_MINIMUM'), $currency); if ($this->context->cart->getOrderTotal(false, Cart::ONLY_PRODUCTS) < $minimal_purchase) return '<p class="warning">'.sprintf( Tools::displayError('A minimum purchase total of %1s (tax excl.) is required in order to validate your order, current purchase total is %2s (tax excl.).'), Tools::displayPrice($minimal_purchase, $currency), Tools::displayPrice($this->context->cart->getOrderTotal(false, Cart::ONLY_PRODUCTS), $currency) ).'</p>'; with this: /* Check minimal amount */ $currency = Currency::getCurrency((int)$this->context->cart->id_currency); $customer = new Customer((int)($this->context->customer->id)); $groupes = $customer->getGroups(); if ($groupes[0]== 4) $minimal_purchase = Tools::convertPrice((float)Configuration::get('PS_PURCHASE_MINIMUM'), $currency); else $minimalPurchase = 1; if ($this->context->cart->getOrderTotal(false, Cart::ONLY_PRODUCTS) < $minimal_purchase) return '<p class="warning">'.sprintf( Tools::displayError('A minimum purchase total of %1s (tax excl.) is required in order to validate your order, current purchase total is %2s (tax excl.).'), Tools::displayPrice($minimal_purchase, $currency), Tools::displayPrice($this->context->cart->getOrderTotal(false, Cart::ONLY_PRODUCTS), $currency) ).'</p>'; and set in your back-office the minimum purchase value. So in this exemple the customers in the group id 4 have the restriction amount set in the BO, and the other group id customes have the restriction of only 1 euro. Work fine on my prestashop 1.6.0.9 Thank you! Edited February 15, 2015 by Drazh (see edit history) Link to comment Share on other sites More sharing options...
wiseprt Posted May 12, 2015 Share Posted May 12, 2015 Hello, I want to do something similar to @paulormf. I want to be able to add different minimum order amount depending the Country. For example i want the "Germany" to have a minimum amount of 50€ but "Greece" have a minimum amount of 10€. Is something like this possible? Any help appreciated. Best Reagrds. Link to comment Share on other sites More sharing options...
AlejandroNovás Posted July 26, 2015 Share Posted July 26, 2015 Hi, me too i need this modification and i made it in the file /controllers/front/OrderController.php.... but nothing happens The group id i want to apply le limitation is number 4, like your example, but they can purchase without any limitation... Any suggestions? Thank you. UPDATE: sorry i use the OrderOpcController.php not the 5 steps OrderController.php. I have find a solution for the one-step checkout (OrderOpcController.php): Find and replace this: /* Check minimal amount */ $currency = Currency::getCurrency((int)$this->context->cart->id_currency); $minimal_purchase = Tools::convertPrice((float)Configuration::get('PS_PURCHASE_MINIMUM'), $currency); if ($this->context->cart->getOrderTotal(false, Cart::ONLY_PRODUCTS) < $minimal_purchase) return '<p class="warning">'.sprintf( Tools::displayError('A minimum purchase total of %1s (tax excl.) is required in order to validate your order, current purchase total is %2s (tax excl.).'), Tools::displayPrice($minimal_purchase, $currency), Tools::displayPrice($this->context->cart->getOrderTotal(false, Cart::ONLY_PRODUCTS), $currency) ).'</p>'; with this: /* Check minimal amount */ $currency = Currency::getCurrency((int)$this->context->cart->id_currency); $customer = new Customer((int)($this->context->customer->id)); $groupes = $customer->getGroups(); if ($groupes[0]== 4) $minimal_purchase = Tools::convertPrice((float)Configuration::get('PS_PURCHASE_MINIMUM'), $currency); else $minimalPurchase = 1; if ($this->context->cart->getOrderTotal(false, Cart::ONLY_PRODUCTS) < $minimal_purchase) return '<p class="warning">'.sprintf( Tools::displayError('A minimum purchase total of %1s (tax excl.) is required in order to validate your order, current purchase total is %2s (tax excl.).'), Tools::displayPrice($minimal_purchase, $currency), Tools::displayPrice($this->context->cart->getOrderTotal(false, Cart::ONLY_PRODUCTS), $currency) ).'</p>'; and set in your back-office the minimum purchase value. So in this exemple the customers in the group id 4 have the restriction amount set in the BO, and the other group id customes have the restriction of only 1 euro. Work fine on my prestashop 1.6.0.9 Thank you! Help , I do not work well , is like ignoring the modified code because: 1. The system limiting the minimum order for all groups that I have in prestashop . 2. The notice displayed is given by a module file ( onepagecheckoutps.php ) , not the OrderOpcController.php Regards 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