max discount value

  • Posts: 7
  • Thank you received: 1
12 hours 7 minutes ago #365288

-- 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

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

  • Posts: 83103
  • Thank you received: 13413
  • MODERATOR
9 hours 22 minutes ago #365289

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.

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

  • Posts: 7
  • Thank you received: 1
8 hours 44 minutes ago #365294

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.059 seconds
Powered by Kunena Forum