Show shipping rates on product view

Did some searching and didnt find anything -anyone have some code to show the shipping rates on the product details page from the SHIPPING CHARGES section of Shipping methods? So not the freight shipping rate but the cost dependancies that are set for a grouping of provinces or states or countries - Essentially have a US price and a Canadian price and want to show it.



Thanks in advance.

I’m also looking for this and haven’t found anything yet.

Assuming you can’t use the shipping estimation block because it expects to have the products in the cart already… I’m looking at doing a mod for someone with that functionality. Be interested to see if a solution other than what I’ve come up with will do the job for the product detail page.

in the end I just wrote a mod to pull the relevant data from the database and it works perfectly - now we are using cost dependancy option and only one value - no 0-50 = $20.00 shipping and 50-100 = 22.00 - so just one value in the serialzied data and it is working perfectly for my setup.



This is the block of code added to controllers/customer/products.php



$shp_rts = db_get_array("SELECT r.rate_value, d.destination FROM cscart_products p, cscart_shippings s, cscart_shipping_rates r, cscart_destination_descriptions d WHERE p.company_id = s.company_id AND s.shipping_id = r.shipping_id AND r.destination_id = d.destination_id AND p.product_id = ".$_REQUEST['product_id'], CART_LANGUAGE);

$shiprates = array();

if (!empty($shp_rts)) {
foreach ($shp_rts as $shprt) {
$unserialrate = unserialize($shprt['rate_value']);
foreach ($unserialrate as $k => $v) {
if ($k == "C") {
foreach ($v as $kk => $vv) {
foreach ($vv as $kkk => $vvv) {
if ($kkk == "value") {
$shpval = $vvv;
}
}
}
}
}
$shiprates[$shprt['destination']] = $shpval;
}
}

unset($shp_rts);

$view->assign('prod_shipping_rates', $shiprates);



Then made the reference in the default product template to show the results accordingly.

Works for static rates, but realtime would be problematic in this solution.

Would really help is you enclosed code in code tags. Kind hard to read otherwise.