- Posts: 23
- Thank you received: 5
max discount value
1 year 8 months ago #365288
by mizso676
max discount value was created by mizso676
-- HikaShop version -- : 5.0.3
-- Joomla version -- : 4.4.3
-- PHP version -- : 8.1.3
-- Browser(s) name and version -- : Chrome latest
Hi guys!
The following is my problem and the task to be solved: I need to set a maximum value for discounts per product, which overrides any preset Hikashop category discounts. What I have:
- A custom field where the value for each product is received from a CRM system (e.g., 30%). The custom field is named "maxkedvezmeny."
- Predefined Hikashop category discounts (e.g., the maximum discount that can be applied is 40%).
However, since not all products within the category can have a 40% discount, the system needs to consider the 30% value from the "maxkedvezmeny" field.
This was previously solved by a developer, and it worked, but it was deleted during a recent update.
Here is the translation:
If I am correct, I need to modify the currency.php file to override the Hikashop discount values when the "maxkedvezmeny" field is smaller than the discount value calculated by Hikashop.
Thanks in advance
-- Joomla version -- : 4.4.3
-- PHP version -- : 8.1.3
-- Browser(s) name and version -- : Chrome latest
Hi guys!
The following is my problem and the task to be solved: I need to set a maximum value for discounts per product, which overrides any preset Hikashop category discounts. What I have:
- A custom field where the value for each product is received from a CRM system (e.g., 30%). The custom field is named "maxkedvezmeny."
- Predefined Hikashop category discounts (e.g., the maximum discount that can be applied is 40%).
However, since not all products within the category can have a 40% discount, the system needs to consider the 30% value from the "maxkedvezmeny" field.
This was previously solved by a developer, and it worked, but it was deleted during a recent update.
Here is the translation:
If I am correct, I need to modify the currency.php file to override the Hikashop discount values when the "maxkedvezmeny" field is smaller than the discount value calculated by Hikashop.
Thanks in advance
Please Log in or Create an account to join the conversation.
1 year 8 months ago #365289
by nicolas
Replied by nicolas on topic max discount value
Hi,
I really don't recommend modifying the currency.php file directly.
You'll end up losing your changes next time you update HikaShop.
A proper way to do it is to create a small plugin ( www.hikashop.com/support/documentation/6...r-documentation.html ) and implement, for example, the onAfterLoadProductPriceDiscount event:
www.hikashop.com/support/documentation/6...ProductPriceDiscount
That way, when the discounts are being loaded, you can check the maxkedvezmeny value of each product and discard the discounts with a percentage value higher, or dynamically reduce their percentage, or clone the discount per product to be able to have different percentages of the same discount based on that maxkedvezmeny value.
I really don't recommend modifying the currency.php file directly.
You'll end up losing your changes next time you update HikaShop.
A proper way to do it is to create a small plugin ( www.hikashop.com/support/documentation/6...r-documentation.html ) and implement, for example, the onAfterLoadProductPriceDiscount event:
www.hikashop.com/support/documentation/6...ProductPriceDiscount
That way, when the discounts are being loaded, you can check the maxkedvezmeny value of each product and discard the discounts with a percentage value higher, or dynamically reduce their percentage, or clone the discount per product to be able to have different percentages of the same discount based on that maxkedvezmeny value.
Please Log in or Create an account to join the conversation.
1 year 8 months ago #365294
by mizso676
Replied by mizso676 on topic max discount value
Thanks for your help, I've made it through currency.php, now trying to create a plugin!
The following user(s) said Thank You: Philip
Please Log in or Create an account to join the conversation.
Time to create page: 0.215 seconds