- Posts: 424
- Thank you received: 11
How to display coupon discount in price of product listing
- BluepointWebdesign
-
Topic Author
- Offline
Less
More
1 year 11 months ago #363974
by BluepointWebdesign
-- 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?
-- 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.
1 year 11 months ago #363975
by nicolas
Replied by nicolas on topic How to display coupon discount in price of product listing
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.
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.
- BluepointWebdesign
-
Topic Author
- Offline
Less
More
- Posts: 424
- Thank you received: 11
1 year 11 months ago #364068
by BluepointWebdesign
Replied by BluepointWebdesign on topic How to display coupon discount in price of product listing
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
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.
1 year 11 months ago #364071
by nicolas
Replied by nicolas on topic How to display coupon discount in price of product listing
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!
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.175 seconds