sinedo Posted March 8, 2015 Share Posted March 8, 2015 Hi, I want to modify my PS 1.6 to display shipping price (best price) in product page. So I want to add this feature to exsisting product.tpl file. How can I do it? Link to comment Share on other sites More sharing options...
Simone Salerno Posted March 8, 2015 Share Posted March 8, 2015 Shipping price depends on cart quantity, so it's difficult to show a realistic price if your customer hasn't a cart yet. If you want nevertheless, you should look at Carrier::getDeliveryPriceByWeight($weight, $id_zone) in classes/Carrier.php or at Cart::getPackageShippingCost($id_carrier, $use_tax, $country, $product_list, $id_zone) filling all that params with data about your customer and his current cart. If a user isn't logged in, you won't have access to much data about him, so you can do little to show a realistic price. I suppose the best option in that case is to use Carrier::getDeliveryPriceByWeight(0, your-zone-id). Link to comment Share on other sites More sharing options...
sinedo Posted March 8, 2015 Author Share Posted March 8, 2015 Ok, thank you very much -> tha's what I'm looking for! Carrier::getDeliveryPriceByWeight($weight, $id_zone) 1 Link to comment Share on other sites More sharing options...
frafra85 Posted April 1, 2015 Share Posted April 1, 2015 Hi, could you explain me how insert this code in my product.tpl ? Thanks. 1 Link to comment Share on other sites More sharing options...
moy2010 Posted April 5, 2015 Share Posted April 5, 2015 Hi, sinedo. Could you please share your solution for this? I'm also looking to display shipping cost on product page . Link to comment Share on other sites More sharing options...
PascalVG Posted April 5, 2015 Share Posted April 5, 2015 Hi moy, You could do something like this: Edit file (or better, override): controllers/front/ProductController.php: add the following code: (find black code, add red code): $default_carrier =new Carrier((int)Configuration::get('PS_CARRIER_DEFAULT')); $carrier_zones = $default_carrier->getZones(); if (isset($carrier_zones) && !empty($carrier_zones)) { $first_carrier_zone = $carrier_zones[0]['id_zone']; $delivery_price = $default_carrier->getDeliveryPriceByWeight($this->product->weight, $first_carrier_zone); } else $delivery_price = 'not found'; $this->context->smarty->assign(array( 'stock_management' => Configuration::get('PS_STOCK_MANAGEMENT'), 'customizationFields' => ($this->product->customizable) ? $this->product->getCustomizationFields($this->context->language->id) : false, 'accessories' => $this->product->getAccessories($this->context->language->id), 'return_link' => $return_link, 'product' => $this->product, 'product_manufacturer' => new Manufacturer((int)$this->product->id_manufacturer, $this->context->language->id), 'token' => Tools::getToken(false), 'features' => $this->product->getFrontFeatures($this->context->language->id), 'attachments' => (($this->product->cache_has_attachments) ? $this->product->getAttachments($this->context->language->id) : array()), 'allow_oosp' => $this->product->isAvailableWhenOutOfStock((int)$this->product->out_of_stock), 'last_qties' => (int)Configuration::get('PS_LAST_QTIES'), 'HOOK_EXTRA_LEFT' => Hook::exec('displayLeftColumnProduct'), 'HOOK_EXTRA_RIGHT' => Hook::exec('displayRightColumnProduct'), 'HOOK_PRODUCT_OOS' => Hook::exec('actionProductOutOfStock', array('product' => $this->product)), 'HOOK_PRODUCT_ACTIONS' => Hook::exec('displayProductButtons', array('product' => $this->product)), 'HOOK_PRODUCT_TAB' => Hook::exec('displayProductTab', array('product' => $this->product)), 'HOOK_PRODUCT_TAB_CONTENT' => Hook::exec('displayProductTabContent', array('product' => $this->product)), 'display_qties' => (int)Configuration::get('PS_DISPLAY_QTIES'), 'display_ht' => !Tax::excludeTaxeOption(), 'currencySign' => $this->context->currency->sign, 'currencyRate' => $this->context->currency->conversion_rate, 'currencyFormat' => $this->context->currency->format, 'currencyBlank' => $this->context->currency->blank, 'jqZoomEnabled' => Configuration::get('PS_DISPLAY_JQZOOM'), 'ENT_NOQUOTES' => ENT_NOQUOTES, 'outOfStockAllowed' => (int)Configuration::get('PS_ORDER_OUT_OF_STOCK') , // <- add comma here! 'delivery_price' => $delivery_price )); Then, in themes/<your theme folder>product.tpl, add this code wherever you need it: {if $delivery_price} <div class = "estimated_delivery_price"> {l s='Initial delivery costs estimate :'}{convertPrice price=$delivery_price} </div> {/if} Result: To modify the decoration of the price or text, you can add some css code to themes/<your theme folder>/css/global.css, like: .estimated_delivery_price { font-size: 18px; } Hope that does the trick, pascal. ------------ P.S. the initial suggestion given above: Carrier::getDeliveryPriceByWeight($weight, $id_zone) Doesn't work directly, as the function is not declared 'static', so therefore we first have to create an instance (object) : $default_carrier =new Carrier((int)Configuration::get('PS_CARRIER_DEFAULT')); and then use this instance (i.e. object) to get to the function: $default_carrier->getDeliveryPriceByWeight(...) FYI :-) 6 Link to comment Share on other sites More sharing options...
moy2010 Posted April 6, 2015 Share Posted April 6, 2015 Great, it worked perfectly . Thanks, PascalVG! Link to comment Share on other sites More sharing options...
PascalVG Posted April 6, 2015 Share Posted April 6, 2015 Perfect, thanks for the feedback! I'll mark the topic as solved :-) Happy selling, pascal. Link to comment Share on other sites More sharing options...
zbi Posted May 28, 2015 Share Posted May 28, 2015 given solution gives the result as a price no tax, and how to display the price of shipping with tax? Link to comment Share on other sites More sharing options...
Spoons Posted May 29, 2015 Share Posted May 29, 2015 I know this thread is marked as solved but I'm tearing my hair out here I'd like to hide the shipping costs (PS 1.6) until a customer is logged in. I've searched everywhere but haven't found the solution, any ideas gratefully received!!! 1 Link to comment Share on other sites More sharing options...
moy2010 Posted May 30, 2015 Share Posted May 30, 2015 You could use this "if" sentence:{if $is_logged} code here {/if} Link to comment Share on other sites More sharing options...
universo Posted November 15, 2015 Share Posted November 15, 2015 Hello Pascal, you can make a code change for id language? Thank you Link to comment Share on other sites More sharing options...
GuiLeC Posted April 14, 2016 Share Posted April 14, 2016 It doesn't work for me (using Prestashop 1.6.1.3) Link to comment Share on other sites More sharing options...
GuiLeC Posted April 19, 2016 Share Posted April 19, 2016 Did anyone find a solution for Prestashop 1.6.1.3 ?? Link to comment Share on other sites More sharing options...
pkt Posted August 23, 2016 Share Posted August 23, 2016 Does not work in 1.6.1.4 either :-( Link to comment Share on other sites More sharing options...
El Patron Posted October 20, 2016 Share Posted October 20, 2016 Hi, I've solved the inaccurate shipping carrier costs for logged/non-logged. Please see PrestaShop International Shipping Carrier Localization Pro Link to comment Share on other sites More sharing options...
vucumbra Posted October 26, 2016 Share Posted October 26, 2016 not work also in 1.6.1.7 Link to comment Share on other sites More sharing options...
Rynraf Posted November 29, 2016 Share Posted November 29, 2016 Hi I tried this changes in Prestashop 1.6.0.14 but always I have "not found" info, for every product. I'm not a Prestashop deverloper and I don't know this code and its connections, relationships... What should I change in above code? Link to comment Share on other sites More sharing options...
StefArts Posted December 2, 2016 Share Posted December 2, 2016 Hi I tried this changes in Prestashop 1.6.0.14 but always I have "not found" info, for every product. I'm not a Prestashop deverloper and I don't know this code and its connections, relationships... What should I change in above code? Hello, I have the same problem here... Prestashop 1.6.1.6 Link to comment Share on other sites More sharing options...
pwerginz Posted January 3, 2017 Share Posted January 3, 2017 Is it possible to add all delivery costs from every country which is deliverable :delivery costs :Austria 150€ Germany 120€ etc.. I tried to implement a second variable $delivery_price_de like the first one but no result .... Link to comment Share on other sites More sharing options...
pwerginz Posted January 4, 2017 Share Posted January 4, 2017 nobody has a solution or idea ? Link to comment Share on other sites More sharing options...
electrostuff_de Posted March 23, 2017 Share Posted March 23, 2017 (edited) Hi, im using 1.6.1.7 <<-- this does not work :/ Is it comfortable with this Version? I don't even get a "not found" message, so I guess the var is not forwarding to the template? Is there a way how I can check this? Edited March 23, 2017 by electrostuff_de (see edit history) Link to comment Share on other sites More sharing options...
zgredek Posted June 14, 2017 Share Posted June 14, 2017 Hi moy, You could do something like this: Hello Pascal! Can You reedit your code to make this works for 1.6.1.2 and above? When I put your code, my product site just dissapear - error 500. More people have this same problem in this topic. Thanks! Link to comment Share on other sites More sharing options...
El Patron Posted February 7, 2018 Share Posted February 7, 2018 On 10/19/2016 at 7:33 PM, El Patron said: Hi, I've solved the inaccurate shipping carrier costs for logged/non-logged. Please see PrestaShop International Shipping Carrier Localization Pro This module is 'incredible'. took us 6 months to create / test. We just suck at marketing it...lol https://www.prestaheroes.com/en-us/modules/geo-localization/prestashop-shipping-commander rule the pool check it out! Link to comment Share on other sites More sharing options...
greko_1905 Posted October 14, 2021 Share Posted October 14, 2021 Hello, does someone also have a solution for Prestashop 1.7? Link to comment Share on other sites More sharing options...
El Patron Posted October 14, 2021 Share Posted October 14, 2021 Yes the module we wrote above, took is six months, nobody has done it since. Link to comment Share on other sites More sharing options...
sebsimappus Posted May 27, 2022 Share Posted May 27, 2022 Hello, Many thanks for the information for prestashop 1.6. Is it possible to update the tutorial for prestashop 1.7 and 1.8 A big thank you to you Link to comment Share on other sites More sharing options...
El Patron Posted May 30, 2022 Share Posted May 30, 2022 On 5/27/2022 at 3:34 AM, sebsimappus said: Hello, Many thanks for the information for prestashop 1.6. Is it possible to update the tutorial for prestashop 1.7 and 1.8 A big thank you to you you should upgrade your ps to stay current, 1.6 is no longer supported....we seldom see them in the wild anymore... 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