Forum Replies Created

Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • in reply to: Matching products AND Products (not OR) #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.

    in reply to: Matching products AND Products (not OR) #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;
    }
    }
    }

    in reply to: Matching products AND Products (not OR) #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…

Viewing 3 posts - 1 through 3 (of 3 total)