Skip to content

Instantly share code, notes, and snippets.

@runezero
Last active May 25, 2022 20:06
Show Gist options
  • Select an option

  • Save runezero/80c65217c67110b82e9e1cc38359e893 to your computer and use it in GitHub Desktop.

Select an option

Save runezero/80c65217c67110b82e9e1cc38359e893 to your computer and use it in GitHub Desktop.
[Checkout notice free shipping at cart price] Set Woo Checkout notice to inform about free shipping from specific price in cart #woocommerce
<?php
add_action('woocommerce_before_cart_contents', 'woo_notice_free_shipping_minimal_price');
function woo_notice_free_shipping_minimal_price() {
global $woocommerce;
$bedragGratisVerzenden = 75;
$cart_total = floatval($woocommerce->cart->cart_contents_total);
$extraForFreeShipping = $bedragGratisVerzenden - $cart_total;
// $shipping_cost = $woocommerce->cart->shipping_total;
// $cart_total = floatval( $woocommerce->cart->cart_contents_total) - floatval($shipping_cost);
//$cart_total = $cart_total * 1.21; //incl BTW. Regel uitzetten voor excl BTW
//$cart_total = round($cart_total,2);
// $extraForFreeShipping = $bedragGratisVerzenden - $cart_total;
//
// $extraForFreeShipping = number_format($extraForFreeShipping, 2, ",", "");
$diff = $bedragGratisVerzenden - $cart_total;
if($cart_total < $bedragGratisVerzenden && $diff > 0) {
echo '<div id="woocommerce-cart-notice-name" class="woocommerce-cart-notice woocommerce-cart-notice-minimum-amount woocommerce-info">
Vanaf <b>€'.$bedragGratisVerzenden.',- </b> betaal je geen verzendkosten. Besteed <strong>€'.$extraForFreeShipping.'</strong> extra en profiteer van de gratis verzending!</div>';
}
}
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment