Fix error 500 on the checkout page, small code refactor and total display fix (#963)
* fix: replaced number_format by round because this caused error 500 on checkout * refactor: code has been made more readable * fix: incorrect display of total on checkout
This commit is contained in:
parent
396d255f6b
commit
4bf534ad50
|
@ -80,7 +80,9 @@ class ShopProduct extends Model
|
||||||
|
|
||||||
public function getPriceAfterDiscount()
|
public function getPriceAfterDiscount()
|
||||||
{
|
{
|
||||||
return number_format($this->price - ($this->price * PartnerDiscount::getDiscount() / 100), 2);
|
$discountRate = PartnerDiscount::getDiscount() / 100;
|
||||||
|
$discountedPrice = $this->price * (1 - $discountRate);
|
||||||
|
return round($discountedPrice, 2);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -90,7 +92,8 @@ class ShopProduct extends Model
|
||||||
*/
|
*/
|
||||||
public function getTaxValue()
|
public function getTaxValue()
|
||||||
{
|
{
|
||||||
return number_format($this->getPriceAfterDiscount() * $this->getTaxPercent() / 100, 2);
|
$taxValue = $this->getPriceAfterDiscount() * $this->getTaxPercent() / 100;
|
||||||
|
return round($taxValue, 2);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -100,6 +103,7 @@ class ShopProduct extends Model
|
||||||
*/
|
*/
|
||||||
public function getTotalPrice()
|
public function getTotalPrice()
|
||||||
{
|
{
|
||||||
return number_format($this->getPriceAfterDiscount() + $this->getTaxValue(), 2);
|
$total = $this->getPriceAfterDiscount() + $this->getTaxValue();
|
||||||
|
return round($total, 2);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -237,7 +237,7 @@
|
||||||
payment_method: '',
|
payment_method: '',
|
||||||
coupon_code: '',
|
coupon_code: '',
|
||||||
submitted: false,
|
submitted: false,
|
||||||
totalPrice: {{ $discountedprice }},
|
totalPrice: {{ $total }},
|
||||||
couponDiscountedValue: 0,
|
couponDiscountedValue: 0,
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue