Support » Plugin: WooCommerce Extended Coupon Features FREE » Auto coupon does not apply to WooCommerce Bookings Booking Person Discount type

  • I would like to auto-apply a coupon to tour ticket products provided by the WooCommerce Bookings plugin.

    I installed https://wordpress.org/plugins/woocommerce-auto-added-coupons/ and everything works perfectly except that when “Auto coupon” is selected, the discount type “Booking Person Discount (Amount Off Per Person)” no longer applies automatically. Even when I try to apply the coupon code manually, I get the message that it applied, but the bottom line price does not change. The other discount types apply automatically; only this one provided by the Bookings plugin does not. When I uncheck “Auto coupon”, the same coupon does apply.

    Does anyone have an idea what would solve the issue?

    The page I need help with: [log in to see the link]

Viewing 11 replies - 1 through 11 (of 11 total)
  • Plugin Author Soft79

    (@josk79)

    Our plugin thinks the coupon doesn’t have a value because it’s not familiar with the ‘Booking Person Discount’ coupon-type. We can add this with a small snippet. I need to know the type-name that the booking plugin uses for this coupon.

    Can you please:
    1. temporarily enable Settings > Extended Coupon Features > Debug mode,
    2. Go to the edit-page of the mentioned coupon
    3. On the ‘Miscellaneous tab’ click ‘Coupon data as json’

    Please paste the result. You can disable debug mode afterwards.

    Does this provide what you need?

    {“result”:”ok”,”coupons”:{“3926”:{“id”:3926,”code”:”online-ticket”,”amount”:”3″,”date_created”:{“date”:”2019-06-12 12:11:49.000000″,”timezone_type”:3,”timezone”:”America\/Detroit”},”date_modified”:{“date”:”2019-06-12 12:38:39.000000″,”timezone_type”:3,”timezone”:”America\/Detroit”},”date_expires”:null,”discount_type”:”booking_person”,”description”:”Online ticket purchase discount”,”usage_count”:0,”individual_use”:false,”product_ids”:[1662,1658],”excluded_product_ids”:[],”usage_limit”:0,”usage_limit_per_user”:0,”limit_usage_to_x_items”:null,”free_shipping”:false,”product_categories”:[],”excluded_product_categories”:[],”exclude_sale_items”:false,”minimum_amount”:””,”maximum_amount”:””,”email_restrictions”:[],”used_by”:[],”virtual”:false,”meta_data”:[{“id”:25998,”key”:”_wjecf_products_and”,”value”:”no”},{“id”:25999,”key”:”_wjecf_categories_and”,”value”:”no”},{“id”:26001,”key”:”_wjecf_is_auto_coupon”,”value”:”yes”},{“id”:26002,”key”:”_wjecf_apply_silently”,”value”:”yes”},{“id”:26015,”key”:”_wjecf_excluded_customer_roles”,”value”:[“shop_manager”,”scheduler”]}]}}}

    adriannolt

    (@adriannolt)

    Hi, just checking if the above debug code tells you what you need to know?

    Plugin Author Soft79

    (@josk79)

    Yes, please apply this snippet to your child theme’s functions.php:

    
    add_filter(
      'wjecf_coupon_has_a_value',
      function( $has_a_value, $coupon ) {
        return $has_a_value || $coupon->is_type( 'booking_person' );
      }, 10, 2
    );
    

    Hi, I pasted the above code in my child theme’s functions.php. I cleared cache and did a round of testing, but did not notice any change in behavior. Here is the updated debug code:

    {"result":"ok","coupons":{"3926":{"id":3926,"code":"online-ticket","amount":"3","date_created":{"date":"2019-06-12 12:11:49.000000","timezone_type":3,"timezone":"America\/Detroit"},"date_modified":{"date":"2019-07-01 15:34:49.000000","timezone_type":3,"timezone":"America\/Detroit"},"date_expires":null,"discount_type":"booking_person","description":"Online ticket purchase discount","usage_count":0,"individual_use":false,"product_ids":[1662,1658],"excluded_product_ids":[],"usage_limit":0,"usage_limit_per_user":0,"limit_usage_to_x_items":null,"free_shipping":false,"product_categories":[],"excluded_product_categories":[],"exclude_sale_items":false,"minimum_amount":"","maximum_amount":"","email_restrictions":[],"used_by":[],"virtual":false,"meta_data":[{"id":25998,"key":"_wjecf_products_and","value":"no"},{"id":25999,"key":"_wjecf_categories_and","value":"no"},{"id":26001,"key":"_wjecf_is_auto_coupon","value":"yes"},{"id":26002,"key":"_wjecf_apply_silently","value":"no"},{"id":26015,"key":"_wjecf_excluded_customer_roles","value":["shop_manager","scheduler"]}]}}}

    Plugin Author Soft79

    (@josk79)

    Are you sure the snippet is pasted the right way?

    A dirty trick, tick the box ‘free shipping’ for the coupon. Does that help?

    Hi,

    I pasted the code again and tested. If I enable “Allow Free Shipping” on the coupon, the coupon automatically applies as it should. But without that box checked, it does not apply. (I guess if the free shipping is not applied to other products in the cart, it’s OK to mark a ticket as free shipping, since shipping would not apply to a ticket anyway.) Is that the solution to this, or is there more work to be done before we can mark this as resolved?

    Plugin Author Soft79

    (@josk79)

    Strange. Maybe the booking plugin does something strange behind the scenes.

    Replace the snippet by this:

    
    add_filter(
      'wjecf_coupon_has_a_value',
      function( $has_a_value, $coupon ) {
        return true;
      }, 10, 2
    );
    

    does it work without ‘free shipping’ checked then?

    No, that snippet works the same way. I need to check the “Allow Free Shipping” checkbox in order for the coupon to auto-apply.

    Plugin Author Soft79

    (@josk79)

    Just to be sure, can you please paste the contents of functions.php in https://pastebin.com/ and paste the url here?

    Hi,

    You may find it here: https://pastebin.com/65W1p33c

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