Topic Resolution: Resolved
Viewing 11 posts - 1 through 11 (of 11 total)
  • Author
    Posts
  • #2905
    Noone
    Participant

    I got this plugin for a simple reason : to apply a 35% discount to the pizza category in the shop but only when one pizza is selected

    I already have a bogo plugin im running pw logo and have this setup :

    – It works when i choose just the pizza option and when i change the quantity to 2 it goes to bogo

    THE ISSUE: im having is when one of the other products in the bogo are selected it still gives the precentage discount and not the bogo one as desired.

    Please help!!!

    #2906
    Soft79
    Keymaster

    I’m sorry, but I don’t understand your post very well. What bogo plugin are you using? What do you want to achieve with our plugin and what is failing? Please give an example or instructions to reproduce in your store.

    #2907
    Noone
    Participant

    Oops here is what i want to achieve:

    so i want to give 35% of the first pizza put into the cart
    when someone adds another item or adds a second pizza i don’t want this to apply anymore

    #2908
    Soft79
    Keymaster

    Set Max Quantity of matching products to: 1

    Then the discount will only apply if there is 1 matching item in the cart.

    #2909
    Noone
    Participant

    ok and the other issue is:

    I want it to apply when there is only one item not just a matching item

    So example:

    1 Pizza
    1 Donair

    I do not want it to apply then

    #2910
    Soft79
    Keymaster

    That is not possible out of the box and would require a custom script to invalidate the coupon if amount of items in cart > 1

    #2911
    Noone
    Participant

    are you able to provide that by any chance please
    I did so much work to try to do it without paying because im tight on funds
    and i read a lot of reviews and read this on the details so i believed this can be achieved:

    Restrict coupon by a combination of products

    #2912
    Soft79
    Keymaster

    I will see if I have a spare minute tomorrow. I’m not at my dev PC currently.

    #2913
    Noone
    Participant

    ok thank you thank you thank you thank you

    #2914
    Soft79
    Keymaster

    Try pasting this in functions.php:

    
    add_filter('woocommerce_coupon_is_valid', function ( $valid, $coupon, $wc_discounts = null ) {
        $wrap_coupon = WJECF_Wrap( $coupon );
        if ( $valid && $wrap_coupon->get_code() == 'your_coupon_code' ) {
            $items = WJECF_WC()->get_discount_items( $wc_discounts );
    
            $qty = 0;
            foreach( $items as $item_key => $item ) {
                if ( $item->product === false ) continue;
                $qty += $item->quantity;
                if ($qty > 1) throw new Exception( WC_Coupon::E_WC_COUPON_NOT_APPLICABLE ); // Max amount of items is 1
            }
        }
        return $valid;
    }, 10, 3 );
    

    Replace your_coupon_code with the actual coupon code.
    Then the coupon will invalidate if amount of items in cart > 1

    #2916
    Noone
    Participant

    Thank you so much i feel like I got more than my monies worth!

    5 Star customer service!!!!!!

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