Skip to content

Instantly share code, notes, and snippets.

@rashmimalpande
Last active May 5, 2021 23:38
Show Gist options
  • Save rashmimalpande/9983a2bf6b0aefad3ddd645c2411e22b to your computer and use it in GitHub Desktop.
Save rashmimalpande/9983a2bf6b0aefad3ddd645c2411e22b to your computer and use it in GitHub Desktop.
<?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' );
}
}
?>
@gamzegenccelik
Copy link

Where should put free-shipping-notice-on-cart.php file in server? Shoul I put inside theme wocommerce folder?

@RemiBLoizeau
Copy link

@gamzegenccelik in your functions.php file 😉

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment