Home Forums Basel – Premium Template Show Remainder for Free Shipping in Cart & Checkout Page

This topic contains 4 replies, has 2 voices, and was last updated by  ochow7 1 year ago.

Viewing 5 posts - 1 through 5 (of 5 total)
  • Author
    Posts
  • #88202

    ochow7
    Customer

    Hello,

    If I offer free shipping for orders that are $50+, and someone has $20 in their cart, is there a way to show on the CART PAGE as well as the CHECKOUT PAGE the difference that’s left in order to qualify for free shipping?

    Is there a setting that I’m missing?

    • This topic was modified 1 year ago by  ochow7.
    #88249

    Hi,

    Sorry, but there is no such option in our theme and WooCommerce by default. It may require additional code customization or extra plugin but we don’t have an instruction for this. It is out of our theme support scope.

    Regards

    #88457

    ochow7
    Customer

    I understand.

    I just found this website that offers two solutions using code:

    I just downloaded the plugin, MY CUSTOM FUNCTIONS, because I’m not a coder and don’t understand how to edit PHP files. I inputted the code, and it says it causes an error.

    Can you kindly take a quick look at the two codes they offer for:
    #1 – Show Amount Left for Free Shipping on Cart Page
    #2 – Show Amount Left for Free Shipping on Checkout Page

    I would like the color of the box the match the themes color.

    Genuinely, I would appreciate your help with adding this crucial piece of functionality.

    Thanks.

    #88510

    Sorry, but we don’t know how this code is supposed to work and we don’t have an instruction to fix it.

    Regards

    #88544

    ochow7
    Customer

    If anyone is following along, I found a great solution on this website.

    Download a plugin that will allow you to add Custom PHP and enter the following code:

    /**
     * Show a message at the cart/checkout displaying
     * how much to go for free shipping.
     */
    function my_custom_wc_free_shipping_notice() {
    	if ( ! is_cart() && ! is_checkout() ) { // Remove partial if you don't want to show it on cart/checkout
    		return;
    	}
    	$packages = WC()->cart->get_shipping_packages();
    	$package = reset( $packages );
    	$zone = wc_get_shipping_zone( $package );
    	$cart_total = WC()->cart->get_displayed_subtotal();
    	if ( WC()->cart->display_prices_including_tax() ) {
    		$cart_total = round( $cart_total - ( WC()->cart->get_discount_total() + WC()->cart->get_discount_tax() ), wc_get_price_decimals() );
    	} else {
    		$cart_total = round( $cart_total - WC()->cart->get_discount_total(), wc_get_price_decimals() );
    	}
    	foreach ( $zone->get_shipping_methods( true ) as $k => $method ) {
    		$min_amount = $method->get_option( 'min_amount' );
    		if ( $method->id == 'free_shipping' && ! empty( $min_amount ) && $cart_total < $min_amount ) {
    			$remaining = $min_amount - $cart_total;
    			wc_add_notice( sprintf( 'Add %s more to get free shipping!', wc_price( $remaining ) ) );
    		}
    	}
    }
    
    Private Content Hidden
Viewing 5 posts - 1 through 5 (of 5 total)

The topic ‘Show Remainder for Free Shipping in Cart & Checkout Page’ is closed to new replies.