wojtas26 Posted November 14, 2016 Share Posted November 14, 2016 please help with this module in version 1.5 works in version 1.6.1.8 but not where the error public function displayProductButtons($params) { global $errors; /* @var $product ProductCore */ $product = $params['product']; /* @var $cookie CookieCore */ $cookie = $params['cookie']; $id_currency = (int) $cookie->id_currency; $id_lang = (int) $cookie->id_lang ; $id_zone = $this->getZoneFromLoggedUser(); if($id_zone == false){ $lang_isoCode = Language::getIsoById( $id_lang ); if(isset($this->langCarriersMap[$lang_isoCode])){ $id_zone = Zone::getIdByName($this->langCarriersMap[$lang_isoCode]); }else{ $id_zone = Zone::getIdByName($this->defaultZone); } } $carriers = Carrier::getCarriersForOrder($id_zone); $lowestShipping = false; foreach($carriers as $carrierAr){ if($carrierAr['name'] == $this->personalPickUp) continue; /* @var $carrier CarrierCore */ $carrier = new CarrierCore($carrierAr['id_carrier'], $id_lang); $shipping = $carrier->getDeliveryPriceByPrice($product->getPrice(), $id_zone, $id_currency); if($lowestShipping == true || $shipping < $lowestShipping){ $lowestShipping = $shipping; if($lowestShipping == 0){ break; } } } $freeShipping = ($lowestShipping !== false && $lowestShipping == 0 ? true :false); $this->context->smarty->assign( array( 'freeShipping' => $freeShipping )); return $this->display(__FILE__, 'product.tpl'); } /** * Vypočítá jakou částku ej nutné přidat do kočíku pro dopravu zdarma, podle aktuálně zvoleného jazyka * @return int */ public function getFreeShippingLeft() { $id_lang = (int) $this->context->cookie->id_lang ; $id_zone = $this->getZoneFromLoggedUser(); if($id_zone == false){ $lang_isoCode = Language::getIsoById( $id_lang ); if(isset($this->langCarriersMap[$lang_isoCode])){ $id_zone = Zone::getIdByName($this->langCarriersMap[$lang_isoCode]); }else{ $id_zone = Zone::getIdByName($this->defaultZone); } } $carriers = Carrier::getCarriersForOrder($id_zone); //nejnižší hranice pro dopravu zdarma $lowestLimit = FALSE; foreach($carriers as $carrierAr){ if($carrierAr['name'] == $this->personalPickUp) continue; /* @var $carrier CarrierCore */ $carrier = new Carrier($carrierAr['id_carrier'], $id_lang); //ranges $priceRanges = $carrier->getRangeObject(); if(!$priceRanges instanceof RangePriceCore) continue;; $ranges = $priceRanges->getRanges($carrierAr['id_carrier']); $rangesPrice = CarrierCore::getDeliveryPriceByRanges($carrier->getRangeTable(), $carrierAr['id_carrier']); $rangeIdPrice = array(); //vytvoří pole id=>cena pro snažší dohledávání ceny foreach($rangesPrice as $range){ if($range['id_zone'] == $id_zone) $rangeIdPrice[$range['id_range_price']] = $range['price']; } //projde všechny rozsahy, pokud je doprava = 0, pokusí se zapsat dolní hranici rozsahu jako nejnžší foreach($ranges as $range){ $shippingPrice = $rangeIdPrice[$range['id_range_price']]; if($shippingPrice == 0){ if($lowestLimit === FALSE || $range['delimiter1'] < $lowestLimit) $lowestLimit = $range['delimiter1']; } } } //celková cena objednávky bez poštovného $taxCalculationMethod = Group::getPriceDisplayMethod((int)Group::getCurrent()->id); $useTax = !($taxCalculationMethod == PS_TAX_EXC); $totalToPay = $this->context->cart->getOrderTotal($useTax, Cart::BOTH_WITHOUT_SHIPPING); //cena za dopravu převedená do aktuální měny $shipping = Tools::convertPrice($lowestLimit, $this->context->currency, $this->context->currency->getDefaultCurrency()); //zbývá do dopravy zdarma return $shipping - $totalToPay; } } Link to comment Share on other sites More sharing options...
Daresh Posted November 14, 2016 Share Posted November 14, 2016 Have you tried this: https://www.prestashop.com/forums/topic/494147-free-module-spend-x-to-get-free-shipping/ Link to comment Share on other sites More sharing options...
wojtas26 Posted November 14, 2016 Author Share Posted November 14, 2016 ok but its not working translations Link to comment Share on other sites More sharing options...
wojtas26 Posted November 14, 2016 Author Share Posted November 14, 2016 There is another problem for the Czech when I have free shipping and 60 € for other EU countries 160 € 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