Jump to content

Shipping / Postage cost on product page and product list


evolution.x

Recommended Posts

Hi,

 

As the title says, does anybody know how to show the shipping cost of the product on the product.tpl or/and product-list.tpl?

 

I think i would have to create a call to the database requesting the weight of the product displayed then another call to match up the relevant shipping cost for that weight?

 

Any help on this will be greatly appreciated!

 

Thanks

Edited by evolution.x (see edit history)
  • Like 1
Link to comment
Share on other sites

  • 2 weeks later...

I have managed to display the shipping cost for the item on the product page, with the help of Rocky!

 

I added the code below to product.php:

 

$carrier = new Carrier(33, intval($cookie->id_lang));
$shippingCost = $carrier->getDeliveryPriceByWeight($product->weight, 7);
$smarty->assign('shippingCost', $shippingCost);

 

Change "33" to your carier of choice and change "7" to the zone of your choice.

 

I then added the code below to product.tpl:

 

{convertPrice price=$shippingCost}

 

I am now trying to add this code to the product-list.tpl but cannot find the correct php file to add the $smarty variables? Any ideas?

  • Like 2
Link to comment
Share on other sites

  • 5 months later...

I am in the process of upgrading from 1.3.2.3 to 1.4.9.0.

 

The code does not work anymore?

 

I have changes it to the below so far but it does not display the price, only £0.00 ?

 

   $carrier = new Carrier(33, intval($cookie->id_lang));
   $shippingCost = $carrier->getDeliveryPriceByWeight($product->weight, 7);
   self::$smarty->assign(array(
	   'shippingCost' => $shippingCost,
   ));

 

Any ideas on what needs changing?

 

Thanks

Edited by evolution.x (see edit history)
Link to comment
Share on other sites

I now have this as the code has changed from 1.3 to 1.4:

 

$carrier = new Carrier(33, intval($cookie->id_lang));
   $shippingCost = Carrier::getDeliveryPriceByWeight($this->product->weight, 7);
   self::$smarty->assign(array(
 'shippingCost' => $shippingCost,
   ));

 

This is now giving me and error:

 

Call to undefined method ProductController::getMaxDeliveryPriceByWeight() in /home/sites/mysite.com/public_html/classes/Carrier.php on line 202

Link to comment
Share on other sites

Hi Pablus,

 

Thanks for your input, at first looks the code you gave would not work for what i require.

 

I am trying to show the postage cost of a product from 1 particular carrier / zone on the product page itself before product is even added to cart.

 

Correct me if i'm wrong but the code you gave only shows the cost of shipping once product is added to cart?

  • Like 1
Link to comment
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...