Neo_odessa Posted July 18, 2016 Share Posted July 18, 2016 (edited) I`m trying change minimal amount in cart different for one country. I`m using module advancedcheckous so i`m doing modifications not in orderOpcController.php I`m found code in advancedcheckout.php I`ve added for country that I need: $id_country = Tools::GetValue('id_country'); if ($id_country = 216){ $minimal_purchase = Tools::convertPrice((float)Configuration::get('PS_PURCHASE_MINIMUM'), $currency);} For other countries I need Increase minimal amount up to 1.66667 Please check my code why it not working: public function cartListErrors() { $err = array(); $errors = array(); $arr = array(); $arr = $this->checkQuantitiesAlt(); $currency = Currency::getCurrency((int)$this->context->cart->id_currency); $id_country = Tools::GetValue('id_country'); if ($id_country = 216){ $minimal_purchase = Tools::convertPrice((float)Configuration::get('PS_PURCHASE_MINIMUM'), $currency);} else { $minimal_purchase = Tools::convertPrice((float)Configuration::get('PS_PURCHASE_MINIMUM')*1.6666667, $currency);} if ($this->context->cart->getOrderTotal(true, Cart::ONLY_PRODUCTS) < $minimal_purchase) { $err[] = sprintf( $this->l( 'A minimum purchase total of %1s (tax excl.) is required to validate'. ' your order, current purchase total is %2s (tax excl.).' ), Tools::displayPrice($minimal_purchase, $currency), Tools::displayPrice( $this->context->cart->getOrderTotal(true, Cart::ONLY_PRODUCTS), $currency ) ); } Edited July 18, 2016 by Neo_odessa (see edit history) Link to comment Share on other sites More sharing options...
Neo_odessa Posted July 25, 2016 Author Share Posted July 25, 2016 Somebody can help? Please look )) Link to comment Share on other sites More sharing options...
ventura Posted July 26, 2016 Share Posted July 26, 2016 To check the customer delivery address (id) you can try with $this->context->cart->id_address_delivery Then you can access to all customer address object $customer_delivery = new Address($this->context->cart->id_address_delivery); and check the customer country id with $customer_delivery->id_country Link to comment Share on other sites More sharing options...
Neo_odessa Posted July 28, 2016 Author Share Posted July 28, 2016 (edited) I`ve tried do how you suggested but nothing works Please check the code I`ve added your suggestions on lines 272-274 public function cartListErrors() { $err = array(); $errors = array(); $arr = array(); $arr = $this->checkQuantitiesAlt(); $currency = Currency::getCurrency((int)$this->context->cart->id_currency); $this->context->cart->id_address_delivery; $customer_delivery = new Address($this->context->cart->id_address_delivery); if ($customer_delivery->id_country = '216'){ $minimal_purchase = Tools::convertPrice((float)Configuration::get('PS_PURCHASE_MINIMUM'), $currency);} else { $minimal_purchase = Tools::convertPrice((float)Configuration::get('PS_PURCHASE_MINIMUM')*1.6666667, $currency);} if ($this->context->cart->getOrderTotal(true, Cart::ONLY_PRODUCTS) < $minimal_purchase) { $err[] = sprintf( $this->l( 'A minimum purchase total of %1s (tax excl.) is required to validate'. ' your order, current purchase total is %2s (tax excl.).' ), Tools::displayPrice($minimal_purchase, $currency), Tools::displayPrice( $this->context->cart->getOrderTotal(true, Cart::ONLY_PRODUCTS), $currency ) ); } And strange when I`m adding this line $customer_delivery->id_country = '216' It showing in cart $minimal_purchase for all countries same as I`ve added in back office and when I`m changing this line to $customer_delivery->id_country == '216' In cart showing $minimal_purchase *1.6 Edited July 28, 2016 by Neo_odessa (see edit history) Link to comment Share on other sites More sharing options...
ventura Posted July 29, 2016 Share Posted July 29, 2016 The red color code that you use it´s not necesary $currency = Currency::getCurrency((int)$this->context->cart->id_currency); $this->context->cart->id_address_delivery; $customer_delivery = new Address($this->context->cart->id_address_delivery); if ($customer_delivery->id_country == '216'){ $minimal_purchase = Tools::convertPrice((float)Configuration::get('PS_PURCHASE_MINIMUM'), $currency);} else { $minimal_purchase = Tools::convertPrice((float)Configuration::get('PS_PURCHASE_MINIMUM')*1.6666667, $currency);} Keep in mind the module´s overrides or controllers that include. Link to comment Share on other sites More sharing options...
Neo_odessa Posted July 30, 2016 Author Share Posted July 30, 2016 I`ve deleted not necesary code but still not working, I check if I changing this lines I see results in front office. Only can`t understand how put country "if" Link to comment Share on other sites More sharing options...
Neo_odessa Posted August 1, 2016 Author Share Posted August 1, 2016 Any Ideas why it code not work`s? 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