Skip to content

Commit

Permalink
Getting the correct discount
Browse files Browse the repository at this point in the history
  • Loading branch information
lukepolo committed Nov 6, 2015
1 parent 6082de5 commit 04c1454
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/Cart.php
Original file line number Diff line number Diff line change
Expand Up @@ -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');
Expand Down
10 changes: 8 additions & 2 deletions src/CartItem.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

}
Expand Down

0 comments on commit 04c1454

Please sign in to comment.