diff --git a/packages/core/src/Base/Traits/CachesProperties.php b/packages/core/src/Base/Traits/CachesProperties.php index 6949976111..de86478aa2 100644 --- a/packages/core/src/Base/Traits/CachesProperties.php +++ b/packages/core/src/Base/Traits/CachesProperties.php @@ -13,7 +13,7 @@ public static function bootCachesProperties() $model->restoreProperties(); }); } - + public function refresh() { parent::refresh(); diff --git a/packages/core/src/DiscountTypes/AbstractDiscountType.php b/packages/core/src/DiscountTypes/AbstractDiscountType.php index e83999e10c..63dcc91097 100644 --- a/packages/core/src/DiscountTypes/AbstractDiscountType.php +++ b/packages/core/src/DiscountTypes/AbstractDiscountType.php @@ -4,7 +4,6 @@ use Illuminate\Contracts\Auth\Authenticatable; use Illuminate\Support\Collection; -use Illuminate\Support\Facades\Auth; use Lunar\Base\DiscountTypeInterface; use Lunar\Base\ValueObjects\Cart\DiscountBreakdown; use Lunar\Models\Cart; diff --git a/packages/core/src/DiscountTypes/BuyXGetY.php b/packages/core/src/DiscountTypes/BuyXGetY.php index 0e667c44b5..2cf3fdcfca 100644 --- a/packages/core/src/DiscountTypes/BuyXGetY.php +++ b/packages/core/src/DiscountTypes/BuyXGetY.php @@ -77,7 +77,6 @@ public function apply(Cart $cart): Cart $maxRewardQty ); - if (! $totalRewardQty) { return $cart; } @@ -95,7 +94,6 @@ public function apply(Cart $cart): Cart }); })->sortBy('subTotal.value'); - foreach ($rewardLines as $rewardLine) { if (! $remainingRewardQty) { continue; @@ -103,11 +101,10 @@ public function apply(Cart $cart): Cart $remainder = $rewardLine->quantity % $remainingRewardQty; - $qtyToAllocate = (int) round(($remainingRewardQty - $remainder) / $rewardLine->quantity); - if (!$remainder && $remainingRewardQty < $rewardLine->quantity) { - $qtyToAllocate = $remainingRewardQty; + if (! $remainder && $remainingRewardQty < $rewardLine->quantity) { + $qtyToAllocate = $remainingRewardQty; } if (! $qtyToAllocate) { @@ -119,7 +116,6 @@ public function apply(Cart $cart): Cart quantity: $qtyToAllocate )); - $conditionQtyToAllocate = $qtyToAllocate * $rewardQty; $conditions->each(function ($conditionLine) use ($affectedLines, &$conditionQtyToAllocate) { if (! $conditionQtyToAllocate) { diff --git a/packages/core/tests/Unit/DiscountTypes/BuyXGetYTest.php b/packages/core/tests/Unit/DiscountTypes/BuyXGetYTest.php index 5f9d9cf552..9c52fa53e4 100644 --- a/packages/core/tests/Unit/DiscountTypes/BuyXGetYTest.php +++ b/packages/core/tests/Unit/DiscountTypes/BuyXGetYTest.php @@ -490,7 +490,6 @@ public function can_apply_multiple_different_discounts() /** * Discount set up. */ - $discountA = Discount::factory()->create([ 'type' => BuyXGetY::class, 'priority' => 1,