Browse Source

[UPDT] Percentage discount calculation fixed

pull/36/head
Rakesh Chawda 8 years ago
parent
commit
f4e43b2fe0
  1. 11
      website_coupon/controllers/main.py

11
website_coupon/controllers/main.py

@ -113,6 +113,17 @@ class WebsiteCoupon(http.Controller):
return request.redirect("/shop/cart?coupon_not_available=3")
elif type == 'percentage':
# coupon type is percentage -------------------------------------
if voucher_type == 'product':
for line in order.order_line:
if line.product_id.name == categ_id.name:
amount_final = (voucher_val / 100) * line.price_total
break
elif voucher_type == 'category':
amount_final = 0
for line in order.order_line:
if line.product_id.categ_id.name == product_id.name:
amount_final += (voucher_val / 100) * line.price_total
elif voucher_type == 'all':
amount_final = (voucher_val/100) * order.amount_total
res = coupon_product.product_tmpl_id.write({'list_price': -amount_final})
value = order._cart_update(product_id=coupon_product.id, set_qty=1, add_qty=1)

Loading…
Cancel
Save