ResolvedMinimum order quantity for delivery
- This topic has 3 replies, 3 voices, and was last updated 2 years, 6 months ago by
Althemist.
- AuthorPosts
- October 16, 2020 at 7:45 pm #26477
juliansantanilla
ParticipantHi, how´s it going…
How can we set up a Minimum order quantity for delivery?
For example, If a Customer order only 1 Buerger for 5 USD, the online store can´t sell that product.
If the Minimum order quantity for delivery is 20 USD, the Onnline Store can sell that product.How can I set up that feature?
October 19, 2020 at 8:08 am #26500Althemist
KeymasterHi juliansantanilla,
I am afraid this is not theme related. Also, there is no such feature in WooCommerce by default. You’d need to use a plugin for minimum quantity. There are many plugins like this, both free and premium. Something like this one:
Product Quantity, Minimum Maximum quantity & Minimum Order quantity WooCommerce
Hope this helps.
Regards,
DimitarNovember 9, 2020 at 2:34 am #27045polspede
ParticipantHi!
I made such mod myself. All you need is to modify functions.php of your child theme. Add this at the end of file (don’t forget to make backup!):function getMinimumCartNoticeErrorText() { $str = 'The delivery requires you to have an order with a value of at least %s in your cart.'; return $str; } function checkIfMinimumCartOrderIsMet() { $woo_min_cart_order = 50; // amount $woo_include_shipping = false; $woo_min_cart_end_value = $woo_include_shipping ? WC()->cart->total : WC()->cart->subtotal; $woo_min_cart_shipping = WC()->cart->get_shipping_total(); return ($woo_min_cart_end_value < $woo_min_cart_order && $woo_min_cart_shipping > 0) ? array('cart_min_order' => $woo_min_cart_order, 'cart_total' => $woo_min_cart_end_value, 'cart_shipping' => $woo_min_cart_shipping) : null; } function checkMinimumCartOrder() { $noMinOrder = checkIfMinimumCartOrderIsMet(); if ($noMinOrder) { if (is_cart() || is_checkout()) { wc_print_notice( sprintf( esc_html__(getMinimumCartNoticeErrorText(), 'lafka'), wc_price($noMinOrder['cart_min_order']) ), 'error' ); } } } // cart view add_action('woocommerce_before_cart', 's77_woocommerce_before_cart_min_order'); function s77_woocommerce_before_cart_min_order() { checkMinimumCartOrder(); } // checkout view add_action('woocommerce_before_checkout_form', 's77_woocommerce_before_checkout_form_min_order'); function s77_woocommerce_before_checkout_form_min_order() { checkMinimumCartOrder(); } // when 'place order' button at checkout is pressed add_action('woocommerce_checkout_process', 's77_woocommerce_checkout_process_min_order'); function s77_woocommerce_checkout_process_min_order() { $noMinOrder = checkIfMinimumCartOrderIsMet(); if ($noMinOrder) { throw new Exception(sprintf( esc_html__(getMinimumCartNoticeErrorText(), 'lafka'), wc_price($noMinOrder['cart_min_order']) )); } }
November 9, 2020 at 10:09 am #27056Althemist
KeymasterHello polspede,
Thanks for sharing with other users, so they can benefit from your experience.
Regards,
Dimitar - AuthorPosts
You must be logged in and have valid license to reply to this topic.