Repository Forums Support WooCommerce Extended Coupon Features PRO Matching products AND Products (not OR)

Topic Resolution: Resolved
Viewing 8 posts - 1 through 8 (of 8 total)
  • Author
    Posts
  • #235
    AbrazoTango
    Participant

    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)?

    #236
    Soft79
    Keymaster

    Hola AbrazoTango,

    can you please send me screenshots of the coupon settings?

    Are you sure you have selected ‘Auto Coupon’?

    #240
    AbrazoTango
    Participant

    Hi,

    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…

    #242
    Soft79
    Keymaster

    Hi,

    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.

    #252
    AbrazoTango
    Participant

    Hi,

    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;
    }
    }
    }

    #253
    AbrazoTango
    Participant

    PS : 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.

    #255
    Soft79
    Keymaster

    Yes, 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.

    #257
    Soft79
    Keymaster

    I 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.

Viewing 8 posts - 1 through 8 (of 8 total)
  • You must be logged in to reply to this topic.