How to Add WooCommerce Delivery Estimates

Creating WooCommerce Delivery Estimates

The first thing we’ll need is the shipping method’s ID so we can identify it in our code and add the appropriate estimate to its label. You can get this under WooCommerce > Settings > Shipping in the “Shipping Methods” table.

WooCommerce shipping method IDs

Shipping method IDs

We’ll do a switch on the method’s ID so we can change the estimate for each rate; you can add an estimate for any or all rates in your shop, and these rates can be different for each method.

Setting a default is optional here. If you don’t want to show the estimate by default for all rates, you can leave this out. Here’s the code you’ll need (can be modified as desired).

<?php
/**
* only copy opening php tag if needed
* Displays shipping estimates for WC shipping rates
*/
function sv_shipping_method_estimate_label( $label, $method ) {
$label .= ‘<br /><small>’;
switch ( $method->method_id ) {
case ‘flat_rate’:
$label .= ‘Est delivery: 2-4 days’;
break;
case ‘free_shipping’:
$label .= ‘Est delivery: 4-7 days’;
break;
case ‘international_delivery’:
$label .= ‘Est delivery: 7-10 days’;
break;
default:
$label .= ‘Est delivery: 3-5 days’;
}
$label .= ‘</small>’;
return $label;
}
add_filter( ‘woocommerce_cart_shipping_method_full_label’, ‘sv_shipping_method_estimate_label’, 10, 2 );

view rawwc-shipping-estimate.php hosted with 

 by GitHub

Feel free to change the label’s text — you could do something like “up to 7 days” instead of a date range if you prefer.

Once you’ve added the estimates for each shipping method, these will now be displayed with the method’s label on the cart page:

WooCommerce delivery estimates on the cart page

Estimates on the cart page

As well as on the checkout page:

WooCommerce delivery estimates

Estimates at checkout

Adding WooCommerce delivery estimates is a simple way to keep customers informed as to how long shipping for each method will take so they can ensure their orders arrive when they need them

Source : https://www.skyverge.com/blog/how-to-add-woocommerce-delivery-estimates/

I would like to share this one from skyverge.com tutorial, it really saves my life in todays project. Thank You Sky Verge.

Leave a Reply