/** * Display extra amount needed for free shipping */ add_action('woocommerce_before_cart', 'cc_free_shipping_cart_notice'); function cc_free_shipping_cart_notice() { $min_amount = 50; //change this to your free shipping threshold $current = WC()->cart->subtotal; if ($current < $min_amount) { $added_text = esc_html__('Get free shipping if you order another ', 'woocommerce') . wc_price($min_amount - $current) . esc_html__(' more!', 'woocommerce'); $return_to = apply_filters('woocommerce_continue_shopping_redirect', wc_get_raw_referer() ? wp_validate_redirect(wc_get_raw_referer(), false ) : wc_get_page_permalink('shop')); $notice = sprintf('%s %s', esc_url($return_to), esc_html__('Continue Shopping', 'woocommerce'), $added_text); wc_print_notice($notice, 'notice'); } }