Skip to content

Commit

Permalink
[FIX] show discount percentage when percentage is near 0
Browse files Browse the repository at this point in the history
  • Loading branch information
cpintofonseca committed Dec 4, 2023
1 parent 9068ce1 commit 25eda9e
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions graphql_vuestorefront/models/product.py
Original file line number Diff line number Diff line change
Expand Up @@ -101,15 +101,20 @@ def _get_combination_info(self, combination=False, product_id=False, add_qty=1,
combination=combination, product_id=product_id, add_qty=add_qty, pricelist=pricelist,
parent_combination=parent_combination, only_template=only_template)

discount = 0
discount = 0.00
discount_perc = 0
if combination_info['has_discounted_price'] and product_id:
discount = combination_info['list_price'] - combination_info['price']
discount_perc = combination_info['list_price'] and (discount * 100 / combination_info['list_price']) or 0

if discount_perc:
discount_perc = int(round(discount_perc, 0))
if not discount_perc:
discount_perc = 1

combination_info.update({
'discount': round(discount, 2),
'discount_perc': int(round(discount_perc, 2)),
'discount_perc': discount_perc,
})

return combination_info
Expand Down

0 comments on commit 25eda9e

Please sign in to comment.