• Resolved vince23

    (@vince23)


    Hey,

    I’m triyng to display the shipping cost for each item on the single product page.

    I tried using this code:

    <?php
    $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 'Versandkosten: ' . ($flat_rate_settings['cost_per_order'] + $fee);?>

    The problem is that it always returns a zero as the shipping prive, even though I’ve defined the shipping classes and they seem to work on the checkout page.

    Can you give me a hint what’s wrong ?

    Thanks in advance.

    • This topic was modified 7 years, 3 months ago by vince23.
Viewing 2 replies - 1 through 2 (of 2 total)
Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Display Shipping cost on prodzct page’ is closed to new replies.