Skip to content

Commit

Permalink
🍺
Browse files Browse the repository at this point in the history
  • Loading branch information
alecritson committed Mar 24, 2023
1 parent 6f28e8d commit 04a1887
Show file tree
Hide file tree
Showing 4 changed files with 3 additions and 9 deletions.
2 changes: 1 addition & 1 deletion packages/core/src/Base/Traits/CachesProperties.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ public static function bootCachesProperties()
$model->restoreProperties();
});
}

public function refresh()
{
parent::refresh();
Expand Down
1 change: 0 additions & 1 deletion packages/core/src/DiscountTypes/AbstractDiscountType.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
8 changes: 2 additions & 6 deletions packages/core/src/DiscountTypes/BuyXGetY.php
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,6 @@ public function apply(Cart $cart): Cart
$maxRewardQty
);


if (! $totalRewardQty) {
return $cart;
}
Expand All @@ -95,19 +94,17 @@ public function apply(Cart $cart): Cart
});
})->sortBy('subTotal.value');


foreach ($rewardLines as $rewardLine) {
if (! $remainingRewardQty) {
continue;
}

$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) {
Expand All @@ -119,7 +116,6 @@ public function apply(Cart $cart): Cart
quantity: $qtyToAllocate
));


$conditionQtyToAllocate = $qtyToAllocate * $rewardQty;
$conditions->each(function ($conditionLine) use ($affectedLines, &$conditionQtyToAllocate) {
if (! $conditionQtyToAllocate) {
Expand Down
1 change: 0 additions & 1 deletion packages/core/tests/Unit/DiscountTypes/BuyXGetYTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -490,7 +490,6 @@ public function can_apply_multiple_different_discounts()
/**
* Discount set up.
*/

$discountA = Discount::factory()->create([
'type' => BuyXGetY::class,
'priority' => 1,
Expand Down

0 comments on commit 04a1887

Please sign in to comment.