Last active
April 14, 2017 10:16
-
-
Save bryceadams/9d469b7c297db5aebad9 to your computer and use it in GitHub Desktop.
Restricts WooCommerce local pickup for minimum order amount
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
/** | |
* Restricts WooCommerce local pickup for minimum order amount | |
* Change $min_amount to the integer amount you want to set as the minimum. | |
*/ | |
add_filter( 'woocommerce_shipping_local_pickup_is_available', 'wcs_pickup_min_amount', 10, 2 ); | |
function wcs_pickup_min_amount( $is_available ) { | |
if ( ! $is_available ) { | |
return $is_available; | |
} | |
$has_met_min_amount = false; | |
$min_amount = 40; | |
if ( WC()->cart->prices_include_tax ) { | |
$total = WC()->cart->cart_contents_total + array_sum( WC()->cart->taxes ); | |
} else { | |
$total = WC()->cart->cart_contents_total; | |
} | |
if ( $total >= $min_amount ) { | |
$has_met_min_amount = true; | |
} | |
return $has_met_min_amount; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hi,
That's a great code. But I need to display an error message when $min_amount < 40.
Could you suggest me please?
Thank you.