Auto Apply Coupon

  • Posts: 63
  • Thank you received: 1
  • Hikashop Business
6 years 4 months ago #283836

Hello,

We need to check if X coupon is active and if so apply another Coupon. Whats the best plugin method to hook into to do this?

Many thanks

Please Log in or Create an account to join the conversation.

  • Posts: 81509
  • Thank you received: 13064
  • MODERATOR
6 years 4 months ago #283837

Hi,

The best is to use the cart API of HikaShop:
www.hikashop.com/support/documentation/6...fterCartProductsLoad
With the onAfterCartProductsLoad trigger, you can simply set the coupon code in the cart_coupon attribute of the $cart object given to you and HikaShop will load it automatically for you in the cart provided that the coupon code is valid.
Basically, it would do the same as the "auto load in cart if possible" setting of the coupons.
If you want something more complex, you might want to use the "additional" system instead of the coupon system.
You will have a lot more liberty.
You can use that plugin as an example:
www.hikashop.com/forum/taxes/873285-fix-tax-import.html#190511

Please Log in or Create an account to join the conversation.

  • Posts: 63
  • Thank you received: 1
  • Hikashop Business
6 years 3 months ago #284884

Yes the problem with this was you only support 1 coupon. But Since this coupon was to provide freeshipping I've been able to auto-zero the shipping if X Y or Z coupon is in using the onAfterCartShippingLoad function.

Thanks for your pointers!

Please Log in or Create an account to join the conversation.

Time to create page: 0.058 seconds
Powered by Kunena Forum