keweli Posted June 3, 2010 Share Posted June 3, 2010 I want to show the weight of the product.I know this is the line for price:{convertPrice price=$product->getPrice(true, $smarty.const.NULL, 2)}Anyone know how to show weight? Link to comment Share on other sites More sharing options...
rocky Posted June 3, 2010 Share Posted June 3, 2010 Change line 331 of product.php (in PrestaShop v1.3) from: $smarty->display(_PS_THEME_DIR_.'product.tpl'); to: $smarty->assign('weightUnit', Configuration::get(Configuration::get('PS_WEIGHT_UNIT'))); $smarty->display(_PS_THEME_DIR_.'product.tpl'); then add the following to product.tpl in your theme's directory wherever you want the weight: {$product->weight}{$weightUnit} Link to comment Share on other sites More sharing options...
keweli Posted June 4, 2010 Author Share Posted June 4, 2010 Thanks for the reply sir.Since you noted v1.3, will this not work for v1.2.5?This is slightly off-topic, but is it possible to call on carriers with the weight?So lets say I have the following: 50g (from the code you previously provided)and country (which I have figured out).Is it possible to use these 2 pieces of information to check a certain carrier (maybe by its ID or something) to see the price?Thanks again. Link to comment Share on other sites More sharing options...
rocky Posted June 4, 2010 Share Posted June 4, 2010 It will work in PrestaShop v1.2.5 too. When I say "in PrestaShop v1.3", I mean the line number I am mentioning is from PrestaShop v1.3 and it may be slightly different in other PrestaShop versions.I'm guessing you want to display the shipping cost of the product for a specific carrier? You can add code like the following to product.php to get the shipping cost of the product: $carrier = new Carrier(1, intval($cookie->id_lang)); $shippingCost = $carrier->getDeliveryPriceByWeight($product->weight, 2); $smarty->assign('shippingCost', $shippingCost); Change 1 to the ID of the carrier and change 2 to the zone that you want to get the shipping cost for.You can then use the following in product.tpl: {l s='Shipping cost:'} {convertPrice price=$shippingCost} Link to comment Share on other sites More sharing options...
keweli Posted June 4, 2010 Author Share Posted June 4, 2010 Thanks a lot rocky, this has been highly useful and I will post again if I get into any trouble with it!Just one last question, if I wanna include it in order.php (Shipping Cart page), do I just add also this to order.php? $carrier = new Carrier(1, intval($cookie->id_lang)); $shippingCost = $carrier->getDeliveryPriceByWeight($product->weight, 2); $smarty->assign('shippingCost', $shippingCost); Link to comment Share on other sites More sharing options...
Kebbe Posted June 27, 2010 Share Posted June 27, 2010 Hi, i want to do the same thing, but this does not work for me. The product-page is just blank when i paste the code in product.phpAny idea? Or do i have to activate something in the back office?I want to show weight at Product listings and at the product side. Link to comment Share on other sites More sharing options...
rocky Posted June 27, 2010 Share Posted June 27, 2010 You should edit config/config.inc.php and temporarily change 'display_errors' from 'off' to 'on' so that you get an error message instead of a blank page. Post the error here. Link to comment Share on other sites More sharing options...
Kebbe Posted June 27, 2010 Share Posted June 27, 2010 Dude! Fast reply.Still got a blank page Link to comment Share on other sites More sharing options...
rocky Posted June 27, 2010 Share Posted June 27, 2010 That's weird. It should give you an error message. Did you use straight quotes around 'on' instead of the angle quotes the forum uses? I can't help you without an error message. I just tested the code on my test site and it worked fine. Link to comment Share on other sites More sharing options...
Kebbe Posted June 27, 2010 Share Posted June 27, 2010 This is how it looks /* Debug only */ @ini_set('display_errors', 'on'); define('_PS_DEBUG_SQL_', false); edit: Now i tried with: /* Debug only */ @ini_set('display_errors', ‘on’); define('_PS_DEBUG_SQL_', false); Still a blank page Link to comment Share on other sites More sharing options...
rocky Posted June 27, 2010 Share Posted June 27, 2010 That's right. You should be getting error messages instead of blank pages. I don't understand why you are not. Link to comment Share on other sites More sharing options...
Kebbe Posted June 27, 2010 Share Posted June 27, 2010 Maybe something with .htaccess? I don't know.Or some other things i can activate on back office? Link to comment Share on other sites More sharing options...
rocky Posted June 27, 2010 Share Posted June 27, 2010 You could try adding the following to your .htaccess: php_flag display_errors on Link to comment Share on other sites More sharing options...
Kebbe Posted June 27, 2010 Share Posted June 27, 2010 It worked Parse error: syntax error, unexpected ';' in /hsphere/local/home/foto2972/shop.rcfreak.no/product.php on line 331 product.php 330 ); 331 $smarty->assign('weightUnit', Configuration::get(Configuration::get('PS_WEIGHT_UNIT')); 332 $smarty->display(_PS_THEME_DIR_.'product.tpl'); Any idea? Link to comment Share on other sites More sharing options...
rocky Posted June 27, 2010 Share Posted June 27, 2010 You're right. Line 331 is missing a parenthesis at the end. There should be three of them. I don't know why I didn't pick it up before. I've correct my code above. Link to comment Share on other sites More sharing options...
Kebbe Posted June 27, 2010 Share Posted June 27, 2010 Nice! Thanks mate But how do i get the weight to show at the product list?I now just tried do add a new line in product.php, but it did not work $smarty->assign('weightUnit', Configuration::get(Configuration::get('PS_WEIGHT_UNIT'))); $smarty->display(_PS_THEME_DIR_.'product.tpl'); $smarty->display(_PS_THEME_DIR_.'product-list.tpl'); And tried to paste in this in the product-list.tpl {$product->weight}{$weightUnit} Link to comment Share on other sites More sharing options...
rocky Posted June 27, 2010 Share Posted June 27, 2010 You can't call product-list.tpl from product.php like that. It won't work. You need to find everywhere that product-list.tpl is already called including category.php, search.php and best-sales.php. Add the weight unit line before those calls to product-list.tpl, then use the following in product-list.tpl: {$product.weight}{$weightUnit} Link to comment Share on other sites More sharing options...
Kebbe Posted June 27, 2010 Share Posted June 27, 2010 Thanks for all the help mate!Will try what you say Edit: Will just inform that just this code in product-list.tpl worked without any other modifications for me. {$product.weight}{$weightUnit} Again, thanks for all your help! Link to comment Share on other sites More sharing options...
KT Design Posted May 7, 2012 Share Posted May 7, 2012 How do you display the sipping price in a newer version of prestashop?... $carrier = new Carrier(1, intval($cookie->id_lang)); $shippingCost = $carrier->getDeliveryPriceByWeight($product->weight, 2); $smarty->assign('shippingCost', $shippingCost); Change 1 to the ID of the carrier and change 2 to the zone that you want to get the shipping cost for. You can then use the following in product.tpl: {l s='Shipping cost:'} {convertPrice price=$shippingCost} This does not work in version 1.4.7.0. What code will work in this newer version og prestashop? When i use this code it shows " Shipping cost: DKK 0,00 " Link to comment Share on other sites More sharing options...
Recommended Posts