diff --git a/src/Core/Baskets/Factories/BasketLineFactory.php b/src/Core/Baskets/Factories/BasketLineFactory.php index b3cc70073..fbd33af42 100644 --- a/src/Core/Baskets/Factories/BasketLineFactory.php +++ b/src/Core/Baskets/Factories/BasketLineFactory.php @@ -109,9 +109,16 @@ public function get() foreach ($this->discounts->get() as $discount) { foreach ($discount->rewards as $reward) { - $method = 'apply'.ucfirst($reward->type); - if (method_exists($this, $method)) { - $line = $this->{$method}($line, $reward); + switch ($reward['type']) { + case 'percentage_amount': + $line = $this->applyPercentage($line, $reward); + break; + case 'fixed_amount': + $line = $this->applyFixedAmount($line, $reward); + break; + case 'to_fixed_price': + $line = $this->applyToFixedAmount($line, $reward); + break; } } } diff --git a/src/Http/Controllers/Baskets/BasketController.php b/src/Http/Controllers/Baskets/BasketController.php index 27e87b7c9..42fb540c5 100644 --- a/src/Http/Controllers/Baskets/BasketController.php +++ b/src/Http/Controllers/Baskets/BasketController.php @@ -79,7 +79,7 @@ public function addDiscount($basketId, AddDiscountRequest $request, DiscountServ $factory = $this->factory->init($basket); $factory->lines->discount($discount->set->discount); - $discount->uses ? $discount->increment('uses') : 1; + $discount->set->discount->increment('uses'); if (! $basket->discount($request->coupon)) { $basket->discounts()->attach($discount->set->discount->id, ['coupon' => $request->coupon]);