How to view the balance until free shipping?

If you offer your customers the option of free shipping above a certain value of goods, it may be useful to display the remaining amount that is needed. This is made possible by the following code snippet, which must be stored in the functions.php file.

add_action( 'woocommerce_before_cart', 'balance_free_shipping_cart_notice' );
function balance_free_shipping_cart_notice() {
   $min_amount = 49; //Betrag, ab dem kostenloser Versand angeboten wird
   $current = WC()->cart->subtotal;
   if ( $current < $min_amount ) {
      $added_text = 'Zum kostenlosen Versand fehlt noch ein Restbetrag von ' . wc_price( $min_amount - $current ) . ' !';
      $return_to = wc_get_page_permalink( 'shop' );
      $notice = sprintf( '<a href="%s" class="button wc-forward">%s</a> %s', esc_url( $return_to ), 'Einkauf fortsetzen', $added_text );
      wc_print_notice( $notice, 'notice' );
Without cookies
This website does not use cookies or tracking. More information can be found in the privacy policy.