• Resolved venkeyaccent

    (@venkeyaccent)


    Hi, I need advice on how to display shipping cost added to product price.

    Iam using realtime shipping carrier plugin so as of now if customer enters the pincode in checkout page the plugin provides realtime shipping rate to customer destination. What i need now is the rate displayed with product price.

    Example: If a T-shirt price is 50$ and shipping price is 3$ which is displayed at checkout, instead I want the product price to be 53$ calculating shipping.

    Is there any plugin or script that i can make this possible so whether the product is in shop page, single product page or home page i want the product to be displayed with shipping cost.

    There are some e-commerce sites already using this model they do this and offers free shipping in checkout page because the shipping cost is already added to product and hidden from customer. I can send you example sites but please someone advice.

    • This topic was modified 1 year, 5 months ago by venkeyaccent.
Viewing 1 replies (of 1 total)
  • Plugin Support Shameem R. a11n

    (@shameemreza)

    Hello @venkeyaccent

    To achieve this functionality, you can use a combination of hooks and custom code. Here’s a step-by-step guide to help you:

    1. First, you’ll need to create a child theme (if you haven’t already) to avoid losing your customizations when updating your theme. You can follow this guide on how to create a child theme: https://developer.www.ads-software.com/themes/advanced-topics/child-themes/

    2. In your child theme’s functions.php file, add the following code:

    // Add shipping cost to product price
    function wc_add_shipping_cost_to_product_price( $price, $product ) {
    // Get the shipping cost
    $shipping_cost = 3; // Replace this with your shipping cost or a function that calculates it
    
    // Add the shipping cost to the product price
    $price_with_shipping = $price + $shipping_cost;
    
    return $price_with_shipping;
    }
    add_filter( 'woocommerce_get_price', 'wc_add_shipping_cost_to_product_price', 10, 2 );
    
    // Display "Free Shipping" at checkout
    function wc_free_shipping_label( $label, $method ) {
    return __( 'Free Shipping', 'woocommerce' );
    }
    add_filter( 'woocommerce_cart_shipping_method_full_label', 'wc_free_shipping_label', 10, 2 );

    This code will add the shipping cost to the product price and display “Free Shipping” at the checkout page. Make sure to replace $shipping_cost with your desired shipping cost or a function that calculates it based on the user’s location.

    Please note that this solution is a simple example and might not cover all scenarios or be suitable for all stores. You may need to customize the code further to fit your specific requirements.

    Thanks!

Viewing 1 replies (of 1 total)
  • The topic ‘Display Shipping cost with Product price together’ is closed to new replies.