Repository › Forums › Support › WooCommerce Extended Coupon Features PRO › Minimum subtotal agreed products does not work
- This topic has 11 replies, 2 voices, and was last updated 5 years, 8 months ago by Soft79.
-
AuthorPosts
-
January 12, 2018 at 8:02 pm #2490jazzynlParticipant
Hello,
The counting ‘Minimum subtotal agreed products’ does not apply.
When i fill in 3 there, i can still add a coupon code at 1 product.
I tried re-install the plugin, cleaning cache, stopped WP Rocket plugin but all will not slove the problem.
In the DEBUG file there is noting to see.The option ‘Minimum number of agreed products’ works, but that is not suitable.
What can be the problem?January 12, 2018 at 9:12 pm #2491Soft79KeymasterHi,
Minimal subtotal of matching products refers to the total price of the matching products in the cart. So if the subtotal exceeds $ 3 (or whatever currency) it will apply.
January 13, 2018 at 11:25 am #2493jazzynlParticipantOk, this is working in a price value!
The problem is, i want to add 5€ on 1 product but the costumer must have 3 products in total in the basket.
How can i achief that? The products have not all the same price.
When i not excluse the products, then the €5 will added on the wrong product combination.January 13, 2018 at 2:17 pm #2495Soft79KeymasterIf you use the following snippet, the coupon will only apply if you have 3 or more items in the cart.
1. Create a € 5 discount coupon
2. On the Usage Restrictions-tab select the Product to which it must apply
3. Append the following snippet to your child themes’ functions.php (replace your_coupon_code by the actual coupon code):add_action( 'wjecf_assert_coupon_is_valid', function( $coupon, $wc_discounts ) { if ( strtolower( WJECF_Wrap( $coupon )->get_code() ) == strtolower( 'your_coupon_code' ) ) { //Must have at least 3 items in the cart $items = WJECF_WC()->get_discount_items( $wc_discounts ); $qty = 0; foreach( $items as $item_key => $item ) { if ( $item->product === false ) continue; $qty += $item->quantity; if ($qty >= 3) return; } throw new Exception( WC_Coupon::E_WC_COUPON_NOT_APPLICABLE ); } }, 10, 2 );
Now the coupon will only be valid if there are at least 3 items in the cart.
January 13, 2018 at 7:25 pm #2496jazzynlParticipantHi Soft79, thanks for the fast response!
The problem when i add the code to the functions.php i get an: HTTP ERROR 500 error.
Is there a fault in the code?add_action( 'wjecf_assert_coupon_is_valid', function( $coupon, $wc_discounts ) { if ( strtolower( WJECF_Wrap( $coupon )->get_code() ) == strtolower( 'earlybird' ) ) { //Must have at least 3 items in the cart $items = WJECF_WC()->get_discount_items( $wc_discounts ); $qty = 0; foreach( $items as $item_key => $item ) { if ( $item->product === false ) continue; $qty += $item->quantity; if ($qty >= 3) return; } throw new Exception( WC_Coupon::E_WC_COUPON_NOT_APPLICABLE ); } }, 10, 2 );
January 13, 2018 at 7:32 pm #2497Soft79KeymasterWhat version of php do you have? It’s mentioned in the WooCommerce System Status.
January 13, 2018 at 7:56 pm #2498jazzynlParticipantPHP-versie: 7.1.12
January 13, 2018 at 8:00 pm #2499Soft79KeymasterWhat version of Extended Coupon Features? Any error message in the debug.log ?
January 13, 2018 at 8:09 pm #2500jazzynlParticipantThe version of Extended Coupon Features is: 2.6.0.2
the debus shows no errors:
(just a part of it)
2018-01-13T21:02:28+00:00 DEBUG woocommerce_after_calculate_totals WJECF_AutoCoupon::get_all_auto_coupons Autocoupons:
2018-01-13T21:02:28+00:00 DEBUG woocommerce_after_calculate_totals WJECF_AutoCoupon::update_matched_autocoupons Auto coupons that should be in cart:
2018-01-13T21:02:28+00:00 DEBUG woocommerce_after_calculate_totals WJECF_AutoCoupon::update_matched_autocoupons Coupons in cart: earlybirdI have a fatal error log:
2018-01-13T20:14:42+00:00 CRITICAL Uncaught ArgumentCountError: Too few arguments to function {closure}(), 1 passed in /****/public_html/wp-includes/class-wp-hook.php on line 286 and exactly 2 expected in /****/public_html/wp-content/themes/****/functions.php:152
Stack trace:
#0 /****/public_html/wp-includes/class-wp-hook.php(286): {closure}(Object(WC_Coupon))
#1 /****/public_html/wp-includes/class-wp-hook.php(310): WP_Hook->apply_filters(”, Array)
#2 /****/public_html/wp-includes/plugin.php(453): WP_Hook->do_action(Array)
#3 /****//public_html/wp-content/plugins/woocommerce-auto-added-coupons/includes/WJECF_Controller.php(463): do_action(‘wjecf_assert_co…’, Object(WC_Coupon))
#4 /****/public_html/wp-includes/class-wp-hook.php(286): WJECF_Controller->assert_coupon_is_valid(true, Object(WC_Coupon), Object(WC_Discounts))
#5 /your help is greatly appreciated! Sorry for the problem.
January 13, 2018 at 8:20 pm #2501Soft79KeymasterThe snippet requires at least version 2.6.1 of WooCommerce Extended Coupon Features PRO. Please update to the latest version.
January 15, 2018 at 6:42 pm #2505jazzynlParticipantPRO version in combination with the snippet is working well.
Maybe it is an feature in an next update so that you can select it.– product A gives €5 discount, but it will be only there if product B an/or C are in the basket with minimum of 3.
Thanks for support.
January 15, 2018 at 7:11 pm #2509Soft79KeymasterGreat! Thanks for the feedback.
-
AuthorPosts
- You must be logged in to reply to this topic.