This topic has 3 replies, 3 voices, and was last updated 5 months, 3 weeks ago ago by Andrew Mitchell
Good morning/afternoon/evening,
Just before I start to try to code anything myself, is there an option or a snippet to create a minimum order amount?
I want to adjust it to minimum order amount = 10 euro for shipping, and no limit for local pickup. But I’m looking for snippet to start with (or maybe you already have this somewhere)?
Kind regards,
Nancy
Hi @Nancy,
Please try adding the following codes under functions.php file locates in your child theme:
function set_minimum_order_amount() {
// Set minimum order amount
$minimum = 30;
$chosen_methods = WC()->session->get( 'chosen_shipping_methods' );
$chosen_shipping = $chosen_methods[0];
// Check if the minimum order amount is met
if (WC()->cart->total < $minimum && 0 !== strpos( $chosen_shipping, 'local_pickup' )) {
wc_add_notice(sprintf('Your current order total is %s — you must have an order with a minimum of %s to place your order.', wc_price(WC()->cart->total), wc_price($minimum)), 'error');
}
}
add_action('woocommerce_checkout_process', 'set_minimum_order_amount');
add_action('woocommerce_before_cart', 'set_minimum_order_amount');
Should you require any additional customizations for your website, please feel free to submit a request through our customization panel at [8Theme Customization Panel](https://www.8theme.com/account/#etheme_customization_panel).
Thank you for choosing us for your website needs. Should you have any further questions or require assistance, please do not hesitate to contact us.
Kind regards,
8Theme’s Team
Dear Nancy,
In the spirit of gratitude, we want to express our appreciation for your trust in our products. As a valued customer, your experience matters greatly. Would you consider sharing it by giving our theme a deserving 5-star rating on ThemeForest?
Click here to share your thoughts: https://themeforest.net/downloads
Being part of our community means a lot, and your feedback contributes immensely.
Best Regards,
The 8Theme Team
The issue related to '‘Minimum amount to order snippet/option (or block if below)’' has been successfully resolved, and the topic is now closed for further responses