Repository Forums Support WooCommerce Extended Coupon Features PRO Restriction AND product

Topic Resolution: Resolved
Viewing 10 posts - 16 through 25 (of 25 total)
  • Author
    Posts
  • #3937
    Soft79
    Keymaster

    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.

    #3942
    pere
    Participant

    Hi!

    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…

    #3944
    Soft79
    Keymaster

    You deleted the coupons. Please send me a coupon code with AND restriction to test with.

    #3945
    pere
    Participant

    You have pack 99 (the one with (AND) . and buy 2 yin yan / buy 2 karma (OR)

    #3946
    Soft79
    Keymaster

    It doesn’t look like you’ve applied the patch. Are you sure you saved it correctly?

    #3947
    pere
    Participant

    Hi!

    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:

    https://imgur.com/a/R48Cl7Y

    #3948
    pere
    Participant

    I just deactivated Pack 99, to avoid orders with soo much discount. You can test with other 2

    #3949
    Soft79
    Keymaster

    Change discount types to cart discount.

    You can delete the FREE plugin.

    #3954
    pere
    Participant

    Hi!

    Now it seems to work! But is there anyway to do that with percentage? Because i work with multicurrency.

    Many thank’s again!

    #3966
    Soft79
    Keymaster

    The 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 );
    
Viewing 10 posts - 16 through 25 (of 25 total)
  • You must be logged in to reply to this topic.