Seagull
posted this
29 January 2017
Hello, I was just trying to see if there was a way to have the shipping cost of an item displaying on the product's page? I think it should be doable with the CMS code but unfortunately I am not proficient enough in coding to work out what it is that I need.
: I found this discussion on Stackoverflow
the answer there was to add this code to the template:
$shipping_class_id = $product->get_shipping_class_id();
$shipping_class= $product->get_shipping_class();
$fee = 0;
if ($shipping_class_id) {
$flat_rates = get_option("woocommerce_flat_rates");
$fee = $flat_rates[$shipping_class]['cost'];
}
$flat_rate_settings = get_option("woocommerce_flat_rate_settings");
echo 'Shipping cost: ' . ($flat_rate_settings['cost_per_order'] + $fee);
But I'm not sure how or what I need to pull out of that to add to the CMS code as in these examples here: http://answers.themler.com/articles/67129/tips-and-tricks
I don't know if it makes a difference but this website I am working on uses all flat rates for shipping with different values according to the size/weight either.
Best regards,
Angela
Hello, I was just trying to see if there was a way to have the shipping cost of an item displaying on the product's page? I think it should be doable with the CMS code but unfortunately I am not proficient enough in coding to work out what it is that I need.
: [I found this discussion on Stackoverflow][1]
the answer there was to add this code to the template:
$shipping_class_id = $product->get_shipping_class_id();
$shipping_class= $product->get_shipping_class();
$fee = 0;
if ($shipping_class_id) {
$flat_rates = get_option("woocommerce_flat_rates");
$fee = $flat_rates[$shipping_class]['cost'];
}
$flat_rate_settings = get_option("woocommerce_flat_rate_settings");
echo 'Shipping cost: ' . ($flat_rate_settings['cost_per_order'] + $fee);
But I'm not sure how or what I need to pull out of that to add to the CMS code as in these examples here: [http://answers.themler.com/articles/67129/tips-and-tricks][2]
[1]: http://stackoverflow.com/questions/40279590/woocommerce-get-shipping-costs-on-the-product-page
[2]: http://answers.themler.com/articles/67129/tips-and-tricks
I don't know if it makes a difference but this website I am working on uses all flat rates for shipping with different values according to the size/weight either.
Best regards,
Angela
Vote to pay developers attention to this features or issue.