Last active
May 5, 2021 23:38
-
-
Save rashmimalpande/9983a2bf6b0aefad3ddd645c2411e22b to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
add_action( 'woocommerce_before_cart', 'wc_add_notice_free_shipping' ); | |
function wc_add_notice_free_shipping() { | |
$free_shipping_settings = get_option('woocommerce_free_shipping_1_settings'); | |
$amount_for_free_shipping = $free_shipping_settings['min_amount']; | |
$cart = WC()->cart->subtotal; | |
$remaining = $amount_for_free_shipping - $cart; | |
if( $amount_for_free_shipping > $cart ){ | |
$notice = sprintf( "Add %s worth more products to get free shipping", wc_price($remaining)); | |
wc_print_notice( $notice , 'notice' ); | |
} | |
} | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Where should put free-shipping-notice-on-cart.php file in server? Shoul I put inside theme wocommerce folder?