Wrong result on discount + coupon

  • Posts: 32
  • Thank you received: 2
  • Hikashop Business
1 year 3 months ago #350005

-- url of the page with the problem -- : www.erboristeriazambrini.it/
-- HikaShop version -- : 4.7.1
-- Joomla version -- : 3.10.11
-- PHP version -- : 7.4
-- Browser(s) name and version -- : All

Hi,
there is an error applying discount and coupon on the same product.
Example:
I've got a product 100€
This product has a discount 20% = 80€ Correct
I've made a 30% coupon with the field Coupon handling of discounted products set as Override discounted products.
The result isn't 70€ but 76€. Why?
If I unpublish the discount the result is correct 70€
If I set the discount as 10% the result is 73€
It seems that the discount value is applied to the coupon value.
100 - [(100 * 30%) - 20%] = 76
100 - [(100 * 30%) - 10%] = 73

Thank you

Last edit: 1 year 3 months ago by nico1979.

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

  • Posts: 81852
  • Thank you received: 13140
  • MODERATOR
1 year 3 months ago #350009

Hi,

I think there is indeed an issue in that calculation mode.
Change the code:

$coupon->discount_flat_amount += ($coupon->discount_percent_amount * $product->prices[0]->$price) / 100;
to:
$coupon->discount_flat_amount += ($coupon->discount_percent_amount * $product->prices[0]->$price_without_discount) / 100;
(several places) in the file administrator/components/com_hikashop/classes/discount.php and it should calculate based on the initial price and not the discounted price.

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

Time to create page: 0.053 seconds
Powered by Kunena Forum