How to display coupon discount in price of product listing

  • Posts: 412
  • Thank you received: 9
  • Hikaserial Subscription Hikashop Business
1 month 4 weeks ago #363974

-- HikaShop version -- : 5.1.1
-- Joomla version -- : 5.2
-- PHP version -- : 8.1

Made discount(coupon) only one time useable per user and want to display the normal price with strike through and price with discount of coupon. So user only get one time 50% of and next times they pay full price. Only discount gives them everytime the discount of 50% so i have to use coupon..

Can you help me with this?

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

  • Posts: 83007
  • Thank you received: 13398
  • MODERATOR
1 month 4 weeks ago #363975

Hi,

That won't be easy. As coupons apply on carts, not on products, the coupon information is not loaded, and the amount of the discount is not applied.
And the system doesn't have the necessary code adapted to be able to load the coupons which could apply to a cart based on a particular product. So basically, you need to write your own PHP code, loading the coupons from the database for the current product, while checking, with another query whether the coupon has already been used by this user in a previous order, before you can calculate the discount amount, and apply it to the price of the product.
You're looking at 30 lines of code minimum.
You could place the code in a view override of product / listing_price via the menu Display>Views.

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

  • Posts: 412
  • Thank you received: 9
  • Hikaserial Subscription Hikashop Business
1 month 3 weeks ago #364068

Hi Nicolas,

Thanks for your answer how to accomplish this. I have choosen to approach it a different way. I made a plugin called discount control.
This plugin now checks when user logs in if he allready ordered the product before with discount, if so the discount is removed from the product.
But when user didn't buy the product he can get the discount. So for subscriptions, when customer lets subscription expire then a next day he won't get the discount because he allready had it. Maybe this is also interesting for other hikashop users. Then they surely can contact me.

Regards,
Mark

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

  • Posts: 83007
  • Thank you received: 13398
  • MODERATOR
1 month 3 weeks ago #364071

Hi,

Indeed, dynamically authorizing the discounts or not based on past orders via the correct event is much nicer.
I think you went with the better solution here!

The following user(s) said Thank You: BluepointWebdesign

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

Time to create page: 0.058 seconds
Powered by Kunena Forum