show alert total free shipping minicart cart

// show alert total free shipping
add_action('woocommerce_cart_totals_after_shipping', 'tzn_custom_woocommerce_after_cart_totals', 8);
if (!function_exists('tzn_custom_woocommerce_after_cart_totals')) {
    function tzn_custom_woocommerce_after_cart_totals()
    {
        $amount_free = "";
        if (function_exists('tzn_admin')) {
            // get free_shipping from shopkit
            $tzn_options = tzn_admin()->get_options();
            $tzn_loyalty_options = $tzn_options[tzn_shopkit::LOYALTY];
            $amount_free = $tzn_loyalty_options['free_shipping'];
        }
        if($amount_free != ""){
            $total = WC()->cart->total;
            $percent = ($total/$amount_free)*100;
            echo $percent;
            if($total < $amount_free){ 
                $missing = $amount_free - $total;
                echo '<p class="notification-shipping-free">'.sprintf(__("Nur noch <b>%s</b> für die versandkostenfrei Lieferung!", 'tzn'), $missing." CHF").'</p>';
            }
        }
    }
}

Leave a Reply

Your email address will not be published. Required fields are marked *