Repository › Forums › Support › WooCommerce Extended Coupon Features PRO › Matching products AND Products (not OR)
- This topic has 7 replies, 2 voices, and was last updated 8 years, 7 months ago by Soft79.
-
AuthorPosts
-
December 17, 2015 at 1:55 pm #235AbrazoTangoParticipant
Hi,
I’m trying to link a coupon to the presence in the basket of 2 products. To obtain this, I selected the 2 products in the “usage restriction” tab and checked the check box on “Matching products AND Products (not OR)”.
In fact the coupon is not applied even if the 2 products are in the basket.
Any chance to correct this small bug (but important for us)?
December 17, 2015 at 2:00 pm #236Soft79KeymasterHola AbrazoTango,
can you please send me screenshots of the coupon settings?
Are you sure you have selected ‘Auto Coupon’?
December 21, 2015 at 10:01 am #240AbrazoTangoParticipantHi,
Yes I selected “auto coupon”.
(the website is not public yet).
Just setup 2 products in your “usage restriction” and check box on “Matching products AND Products (not OR)”. The auto coupon is not applied…
December 22, 2015 at 4:51 pm #242Soft79KeymasterHi,
are the products variable products by any chance? Does the coupon work if you don’t select AND?
Can I debug the issue on your environment? I’m not able to reproduce it here.
December 28, 2015 at 1:23 am #252AbrazoTangoParticipantHi,
The coupon works with no “AND”. In that case, with one of the 2 products, or both, the coupon is applied once.
This became critical for us because we plan to open our shop the 1st of January.
I tried to understand your code and I don’t understand why “variation_id” is used to compare all products in the cart (and seems to rempace the “product_id”?
//Test if ALL products are in the cart (if AND-operator selected in stead of the default OR)
$products_and = get_post_meta( $coupon->id, ‘_wjecf_products_and’, true ) == ‘yes’;
if ( $products_and && sizeof( $coupon->product_ids ) > 1 ) { // We use > 1, because if size == 1, ‘AND’ makes no difference
//Get array of all cart product and variation ids
$cart_item_ids = array();
foreach( WC()->cart->get_cart() as $cart_item_key => $cart_item ) {
$cart_item_ids[] = $cart_item[‘product_id’];
$cart_item_ids[] = $cart_item[‘variation_id’];
}
//check if every single product is in the cart
foreach( $coupon->product_ids as $product_id ) {
if ( ! in_array( $product_id, $cart_item_ids ) ) {
return false;
}
}
}December 28, 2015 at 1:35 am #253AbrazoTangoParticipantPS : I’m using WPML to manage our website in multiple languages. This could be the reason of the issue…???
Each product are dupplicated by WPML for each language.
December 28, 2015 at 7:58 am #255Soft79KeymasterYes, WPML is te issue then. Currently I don’t have a WPML test environment. Could you please send me a zip with the WPML plugins you are using (WPML, String translations, WPML for WooCommerce etc…) and I will take a look.
December 28, 2015 at 7:26 pm #257Soft79KeymasterI just sent you a snippet that should fix the issue with WPML. Please let me know if it works and I will implement it in the next release.
-
AuthorPosts
- You must be logged in to reply to this topic.