From 04c145475669c91aeaae4ce78c0830dfe4b0714d Mon Sep 17 00:00:00 2001 From: Luke Policinski Date: Fri, 6 Nov 2015 17:09:04 +0000 Subject: [PATCH] Getting the correct discount --- src/Cart.php | 2 +- src/CartItem.php | 10 ++++++++-- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/src/Cart.php b/src/Cart.php index b77e87b..b88403e 100644 --- a/src/Cart.php +++ b/src/Cart.php @@ -20,7 +20,7 @@ class Cart public $internationalFormat; protected $instance; - function __construct($instance) + public function __construct($instance) { $this->instance = $instance; $this->tax = config('laracart.tax'); diff --git a/src/CartItem.php b/src/CartItem.php index c86efe1..da0c805 100644 --- a/src/CartItem.php +++ b/src/CartItem.php @@ -294,10 +294,16 @@ public function subItemsTotal($tax = false, $format = true) */ public function getDiscount($format = true) { + if(\LaraCart::findCoupon($this->code)) { + $discount = $this->discount; + } else { + $discount = 0; + } + if($format) { - return \LaraCart::formatMoney($this->discount, $this->locale, $this->internationalFormat); + return \LaraCart::formatMoney($discount, $this->locale, $this->internationalFormat); } else { - return $this->discount; + return $discount; } }