Repository › Forums › Support › WooCommerce Extended Coupon Features PRO › Restriction AND product
- This topic has 24 replies, 2 voices, and was last updated 5 years, 11 months ago by Soft79.
-
AuthorPosts
-
October 9, 2018 at 7:18 pm #3937Soft79Keymaster
For now this is a quick fix:
In the file wp-content/plugins/woocommerce-auto-added-coupons-pro/includes/plugins/WJECF_WPML.php find the following (around line 25):
add_filter( 'wjecf_get_product_id', array( $this, 'filter_get_product_id' ), 10 ); add_filter( 'wjecf_get_product_ids', array( $this, 'filter_get_product_ids' ), 10 ); add_filter( 'woocommerce_coupon_get_description', array( $this, 'filter_get_coupon_description' ), 10, 2 );
and replace with:
add_filter( 'wjecf_get_product_id', array( $this, 'filter_get_product_id' ), 10 ); add_filter( 'wjecf_get_product_ids', array( $this, 'filter_get_product_ids' ), 10 ); add_filter( 'wjecf_get_product_cat_id', array( $this, 'filter_get_product_cat_id' ), 10 ); add_filter( 'wjecf_get_product_cat_ids', array( $this, 'filter_get_product_cat_ids' ), 10 ); add_filter( 'woocommerce_coupon_get_description', array( $this, 'filter_get_coupon_description' ), 10, 2 );
That should work, but changing language while a coupon is in the cart might invalidate the coupon.
I need to investigate further, but it might take a while.
October 11, 2018 at 8:18 am #3942pereParticipantHi!
I’ve tested that and didn’t work.
I have 3 coupons:
1- If I put in the cart 2 pieces of product (condition OR) category A I get discount (Works)
2- If I put in the cart 2 pieces of product (condition OR) category B I get discount (Works)
3- If I put in the cart 2 pieces of product (condition OR) category A and B I get both discount (Works)
4- If I put in the cart 1 piece of product category A (condition AND) and B I get nothing (don’t work)Hope it helps…
October 11, 2018 at 3:39 pm #3944Soft79KeymasterYou deleted the coupons. Please send me a coupon code with AND restriction to test with.
October 11, 2018 at 3:55 pm #3945pereParticipantYou have pack 99 (the one with (AND) . and buy 2 yin yan / buy 2 karma (OR)
October 11, 2018 at 4:27 pm #3946Soft79KeymasterIt doesn’t look like you’ve applied the patch. Are you sure you saved it correctly?
October 11, 2018 at 7:20 pm #3947pereParticipantHi!
I didn’t apply in coupon PRO I made it in the main plugin, know it works but there’s something wrong U_U
I mean, the discount works, but not as spected.
I have one discount that if 1 product of CAT A an 1 of CAT B is in the cart, it applies de discount. (this is what you have solved now 🙂
I have another discount that if you have 2 products of CAT A you get a discount.
Another that if you have 2 product of CAT B you get a discount.
But I can’t have all of them at a time, and I need them to be compatible with other coupons. So now, if someone have 2 products of CAT A and 1 of CAT B, I get doubled discounted, for 1 (A) + 1 (B) and 2 (A).
Well to avoid that I made the following.
Coupon pack 99: If 1 product of CAT A an 1 of CAT B is in the cart, apply coupon.
Coupon 2 Karma: If 2 product of CAT A (AND) 1 product of CAT B IS NOT (excluded), apply coupon.
Coupon 2 Yin Yan: If 2 product of CAT B (AND) 1 product of CAT A IS NOT (excluded), apply coupon.But I’m getting all aplied anyway…
I leave you some screens:
October 11, 2018 at 7:45 pm #3948pereParticipantI just deactivated Pack 99, to avoid orders with soo much discount. You can test with other 2
October 11, 2018 at 8:56 pm #3949Soft79KeymasterChange discount types to cart discount.
You can delete the FREE plugin.
October 12, 2018 at 2:34 pm #3954pereParticipantHi!
Now it seems to work! But is there anyway to do that with percentage? Because i work with multicurrency.
Many thank’s again!
October 17, 2018 at 6:57 am #3966Soft79KeymasterThe following snippet restores the ‘Cart Percent Discount’ which unfortunately was removed from WooCommerce in version 3.0.
add_filter( 'woocommerce_cart_coupon_types', function ( $coupon_types ) { if ( ! in_array( 'percent_cart', $coupon_types ) ) $coupon_types[] = 'percent_cart'; return $coupon_types; }, 10, 1 ); add_filter( 'woocommerce_coupon_discount_types', function ( $coupon_discount_types ) { $coupon_discount_types['percent_cart'] = __( 'Percentage cart discount', 'your-language-domain' ); $coupon_discount_types['percent'] = __( 'Percentage product discount', 'your-language-domain' ); return $coupon_discount_types; }, 10, 1 ); add_filter( 'woocommerce_coupon_get_discount_amount', function( $discount_amount, $discounting_amount, $cart_item, $single, $coupon ) { if ( $coupon->is_type( 'percent_cart' ) ) { $discount = (float) $coupon->get_amount() * ( $discounting_amount / 100 ); $discount_amount = round( min( $discount, $discounting_amount ), wc_get_rounding_precision() ); } return $discount_amount; }, 10, 5 );
-
AuthorPosts
- You must be logged in to reply to this topic.