From 26d70d7e6494b2b542ed093351741f7dd700da7d Mon Sep 17 00:00:00 2001 From: Matt Floyd Date: Mon, 30 Sep 2024 05:17:44 -0400 Subject: [PATCH 01/12] Fix docblock return types (#1968) --- packages/core/src/Pipelines/Cart/ApplyDiscounts.php | 2 +- packages/core/src/Pipelines/Cart/ApplyShipping.php | 2 +- packages/core/src/Pipelines/Cart/Calculate.php | 2 +- packages/core/src/Pipelines/Cart/CalculateLines.php | 2 +- packages/core/src/Pipelines/Cart/CalculateTax.php | 2 +- .../core/src/Pipelines/Order/Creation/CleanUpOrderLines.php | 2 +- .../core/src/Pipelines/Order/Creation/CreateOrderAddresses.php | 2 +- packages/core/src/Pipelines/Order/Creation/CreateOrderLines.php | 2 +- .../core/src/Pipelines/Order/Creation/CreateShippingLine.php | 2 +- .../core/src/Pipelines/Order/Creation/FillOrderFromCart.php | 2 +- .../core/src/Pipelines/Order/Creation/MapDiscountBreakdown.php | 2 +- 11 files changed, 11 insertions(+), 11 deletions(-) diff --git a/packages/core/src/Pipelines/Cart/ApplyDiscounts.php b/packages/core/src/Pipelines/Cart/ApplyDiscounts.php index bf84f14e21..bd0570b132 100644 --- a/packages/core/src/Pipelines/Cart/ApplyDiscounts.php +++ b/packages/core/src/Pipelines/Cart/ApplyDiscounts.php @@ -11,7 +11,7 @@ final class ApplyDiscounts /** * Called just before cart totals are calculated. * - * @return void + * @return mixed */ public function handle(Cart $cart, Closure $next) { diff --git a/packages/core/src/Pipelines/Cart/ApplyShipping.php b/packages/core/src/Pipelines/Cart/ApplyShipping.php index da69179466..d516fc7adf 100644 --- a/packages/core/src/Pipelines/Cart/ApplyShipping.php +++ b/packages/core/src/Pipelines/Cart/ApplyShipping.php @@ -14,7 +14,7 @@ final class ApplyShipping /** * Called just before cart totals are calculated. * - * @return void + * @return mixed */ public function handle(Cart $cart, Closure $next) { diff --git a/packages/core/src/Pipelines/Cart/Calculate.php b/packages/core/src/Pipelines/Cart/Calculate.php index 353f519729..18c4520a31 100644 --- a/packages/core/src/Pipelines/Cart/Calculate.php +++ b/packages/core/src/Pipelines/Cart/Calculate.php @@ -11,7 +11,7 @@ class Calculate /** * Called just before cart totals are calculated. * - * @return void + * @return mixed */ public function handle(Cart $cart, Closure $next) { diff --git a/packages/core/src/Pipelines/Cart/CalculateLines.php b/packages/core/src/Pipelines/Cart/CalculateLines.php index 06599eb189..176b678cc9 100644 --- a/packages/core/src/Pipelines/Cart/CalculateLines.php +++ b/packages/core/src/Pipelines/Cart/CalculateLines.php @@ -12,7 +12,7 @@ class CalculateLines /** * Called just before cart totals are calculated. * - * @return void + * @return mixed */ public function handle(Cart $cart, Closure $next) { diff --git a/packages/core/src/Pipelines/Cart/CalculateTax.php b/packages/core/src/Pipelines/Cart/CalculateTax.php index 78890c7046..6927e071d2 100644 --- a/packages/core/src/Pipelines/Cart/CalculateTax.php +++ b/packages/core/src/Pipelines/Cart/CalculateTax.php @@ -15,7 +15,7 @@ class CalculateTax /** * Called just before cart totals are calculated. * - * @return void + * @return mixed */ public function handle(Cart $cart, Closure $next) { diff --git a/packages/core/src/Pipelines/Order/Creation/CleanUpOrderLines.php b/packages/core/src/Pipelines/Order/Creation/CleanUpOrderLines.php index 452697cfa4..0d6dcebbdb 100644 --- a/packages/core/src/Pipelines/Order/Creation/CleanUpOrderLines.php +++ b/packages/core/src/Pipelines/Order/Creation/CleanUpOrderLines.php @@ -8,7 +8,7 @@ class CleanUpOrderLines { /** - * @return Closure + * @return mixed */ public function handle(Order $order, Closure $next) { diff --git a/packages/core/src/Pipelines/Order/Creation/CreateOrderAddresses.php b/packages/core/src/Pipelines/Order/Creation/CreateOrderAddresses.php index b6b36ab243..c296933661 100644 --- a/packages/core/src/Pipelines/Order/Creation/CreateOrderAddresses.php +++ b/packages/core/src/Pipelines/Order/Creation/CreateOrderAddresses.php @@ -9,7 +9,7 @@ class CreateOrderAddresses { /** - * @return Closure + * @return mixed */ public function handle(Order $order, Closure $next) { diff --git a/packages/core/src/Pipelines/Order/Creation/CreateOrderLines.php b/packages/core/src/Pipelines/Order/Creation/CreateOrderLines.php index f1015e09c7..93400d5f62 100644 --- a/packages/core/src/Pipelines/Order/Creation/CreateOrderLines.php +++ b/packages/core/src/Pipelines/Order/Creation/CreateOrderLines.php @@ -9,7 +9,7 @@ class CreateOrderLines { /** - * @return Closure + * @return mixed */ public function handle(Order $order, Closure $next) { diff --git a/packages/core/src/Pipelines/Order/Creation/CreateShippingLine.php b/packages/core/src/Pipelines/Order/Creation/CreateShippingLine.php index a879de275d..234fdf3e86 100644 --- a/packages/core/src/Pipelines/Order/Creation/CreateShippingLine.php +++ b/packages/core/src/Pipelines/Order/Creation/CreateShippingLine.php @@ -10,7 +10,7 @@ class CreateShippingLine { /** - * @return Closure + * @return mixed */ public function handle(Order $order, Closure $next) { diff --git a/packages/core/src/Pipelines/Order/Creation/FillOrderFromCart.php b/packages/core/src/Pipelines/Order/Creation/FillOrderFromCart.php index e05dd673ab..4671eb15d7 100644 --- a/packages/core/src/Pipelines/Order/Creation/FillOrderFromCart.php +++ b/packages/core/src/Pipelines/Order/Creation/FillOrderFromCart.php @@ -10,7 +10,7 @@ class FillOrderFromCart { /** - * @return Closure + * @return mixed */ public function handle(Order $order, Closure $next) { diff --git a/packages/core/src/Pipelines/Order/Creation/MapDiscountBreakdown.php b/packages/core/src/Pipelines/Order/Creation/MapDiscountBreakdown.php index f4953c8fa2..fd92f7a6e5 100644 --- a/packages/core/src/Pipelines/Order/Creation/MapDiscountBreakdown.php +++ b/packages/core/src/Pipelines/Order/Creation/MapDiscountBreakdown.php @@ -8,7 +8,7 @@ class MapDiscountBreakdown { /** - * @return Closure + * @return mixed */ public function handle(Order $order, Closure $next) { From 3d66fb2927a31475cc2cc9ed83f39d169eb52886 Mon Sep 17 00:00:00 2001 From: Glenn Jacobs Date: Mon, 7 Oct 2024 10:39:30 +0100 Subject: [PATCH 02/12] Update alpha mentions to beta (#1980) Seems we missed a few mentions when moving to beta. This looks to resolve them. --- README.md | 2 +- docs/admin/overview.md | 4 ++-- docs/core/installation.md | 6 +++--- docs/core/overview.md | 6 +++--- 4 files changed, 9 insertions(+), 9 deletions(-) diff --git a/README.md b/README.md index 61c8a203b1..7ec01edf64 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,7 @@

Lunar

> [!CAUTION] -> Version 1.x is currently in alpha release. We recommend this version for new projects, however, it is not feature-complete and therefore may not be deemed production-ready. +> Version 1.x is currently in beta release. We recommend this version for new projects, however, it is not feature-complete and therefore may not be deemed production-ready. [Lunar](https://lunarphp.io) is a set of Laravel packages that bring functionality akin to Shopify and other e-commerce platforms to diff --git a/docs/admin/overview.md b/docs/admin/overview.md index c2a3e40158..d2f0003abe 100644 --- a/docs/admin/overview.md +++ b/docs/admin/overview.md @@ -1,8 +1,8 @@ # Introduction -::: danger Alpha Release +::: danger Beta Release Although many Lunar sites have been launched using v1.x, you may not consider this version production-ready for your own -use and should exercise the same amount of caution as you would with any software in an alpha state. 🚀 +use and should exercise the same amount of caution as you would with any software in an beta state. 🚀 ::: Lunar's admin panel is powered by Filament v3. It allows you to easily extend the admin panel to suit your project. diff --git a/docs/core/installation.md b/docs/core/installation.md index 9633b8b4dc..cd572157ac 100644 --- a/docs/core/installation.md +++ b/docs/core/installation.md @@ -1,8 +1,8 @@ # Installation -::: danger Alpha Release +::: danger Beta Release Although many Lunar sites have been launched using v1.x, you may not consider this version production-ready for your own -use and should exercise the same amount of caution as you would with any software in an alpha state. 🚀 +use and should exercise the same amount of caution as you would with any software in an beta state. 🚀 ::: ## Requirements @@ -20,7 +20,7 @@ use and should exercise the same amount of caution as you would with any softwar ### Composer Require Package ```sh -composer require lunarphp/lunar:"^1.0.0-alpha" -W +composer require lunarphp/lunar:"^1.0.0-beta" -W ``` ::: tip diff --git a/docs/core/overview.md b/docs/core/overview.md index bbdb47fdb1..d274fa5781 100644 --- a/docs/core/overview.md +++ b/docs/core/overview.md @@ -1,8 +1,8 @@ # Welcome to Lunar! -::: danger Alpha Release -Although many Lunar sites have been launched using v1.x, you may not consider this version production-ready for your own -use and should exercise the same amount of caution as you would with any software in an alpha state. 🚀 +::: danger Beta Release +Although many Lunar sites have been launched using v1.x, you may not consider this version production-ready for your own +use and should exercise the same amount of caution as you would with any software in an beta state. 🚀 ::: We are delighted you are considering Lunar for your project. We've spent a lot of time developing this package to bring headless e-commerce functionality to Laravel. From ab7f6d5ebeb5533498ff13c36155534f181adad6 Mon Sep 17 00:00:00 2001 From: Lionel Guichard Date: Mon, 21 Oct 2024 08:56:10 +0200 Subject: [PATCH 03/12] Fix: case sensitivity typo (#1991) --- packages/admin/src/Support/Forms/Components/Attributes.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/admin/src/Support/Forms/Components/Attributes.php b/packages/admin/src/Support/Forms/Components/Attributes.php index 8df4b49223..429b3fde61 100644 --- a/packages/admin/src/Support/Forms/Components/Attributes.php +++ b/packages/admin/src/Support/Forms/Components/Attributes.php @@ -86,7 +86,7 @@ protected function setUp(): void } foreach ($state as $key => $value) { - if (! $value instanceof \Lunar\Base\Fieldtype) { + if (! $value instanceof \Lunar\Base\FieldType) { continue; } From ac92f140819f4ce0a73ffddcd9eb676ae82ed9a2 Mon Sep 17 00:00:00 2001 From: wychoong <67364036+wychoong@users.noreply.github.com> Date: Mon, 21 Oct 2024 14:57:00 +0800 Subject: [PATCH 04/12] Fix `class_implements` error on string 'product_variant' (#1964) fixes #1942 fix `class_implements` error on string 'product_variant' Co-authored-by: Alec Ritson --- packages/core/src/Observers/OrderLineObserver.php | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/packages/core/src/Observers/OrderLineObserver.php b/packages/core/src/Observers/OrderLineObserver.php index 967607dd53..af384a4281 100644 --- a/packages/core/src/Observers/OrderLineObserver.php +++ b/packages/core/src/Observers/OrderLineObserver.php @@ -32,8 +32,12 @@ public function creating(OrderLine $orderLine) */ public function updating(OrderLine $orderLine) { - if (! in_array(Purchasable::class, class_implements($orderLine->purchasable_type, true))) { - throw new NonPurchasableItemException($orderLine->purchasable_type); + $purchasableModel = class_exists($orderLine->purchasable_type) ? + $orderLine->purchasable_type : + Relation::getMorphedModel($orderLine->purchasable_type); + + if (! $purchasableModel || ! in_array(Purchasable::class, class_implements($purchasableModel, true))) { + throw new NonPurchasableItemException($purchasableModel); } } } From 694014e8940c303e2b3e3b6e5e3cc5fbf5639788 Mon Sep 17 00:00:00 2001 From: Aidas Klimas Date: Mon, 21 Oct 2024 15:09:30 +0800 Subject: [PATCH 05/12] Fix Order relation manager url generation (#1995) --- .../RelationManagers/OrdersRelationManager.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/packages/admin/src/Filament/Resources/CustomerResource/RelationManagers/OrdersRelationManager.php b/packages/admin/src/Filament/Resources/CustomerResource/RelationManagers/OrdersRelationManager.php index 5598f7863e..99b114b773 100644 --- a/packages/admin/src/Filament/Resources/CustomerResource/RelationManagers/OrdersRelationManager.php +++ b/packages/admin/src/Filament/Resources/CustomerResource/RelationManagers/OrdersRelationManager.php @@ -6,6 +6,7 @@ use Filament\Tables\Table; use Lunar\Admin\Filament\Resources\OrderResource; use Lunar\Admin\Support\RelationManagers\BaseRelationManager; +use Lunar\Admin\Filament\Resources\OrderResource\Pages\ManageOrder; use Lunar\Models\Order; class OrdersRelationManager extends BaseRelationManager @@ -18,7 +19,7 @@ public function getDefaultTable(Table $table): Table OrderResource::getTableColumns() )->actions([ Tables\Actions\Action::make('viewOrder') - ->url(fn (Order $record): string => route('filament.lunar.resources.orders.order', $record)), + ->url(fn (Order $record): string => ManageOrder::getUrl(['record' => $record])), ]); } } From 19858f375dd1b90e21301e836bdef55d493b4d90 Mon Sep 17 00:00:00 2001 From: Lionel Guichard Date: Mon, 21 Oct 2024 09:09:56 +0200 Subject: [PATCH 06/12] Fix Missing morphName in database state (#1990) --- .../core/database/state/EnsureMediaCollectionsAreRenamed.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/core/database/state/EnsureMediaCollectionsAreRenamed.php b/packages/core/database/state/EnsureMediaCollectionsAreRenamed.php index 9701b71553..3993a6bea0 100644 --- a/packages/core/database/state/EnsureMediaCollectionsAreRenamed.php +++ b/packages/core/database/state/EnsureMediaCollectionsAreRenamed.php @@ -35,7 +35,7 @@ protected function shouldRun() protected function getOutdatedMediaQuery() { return DB::table(app(config('media-library.media_model'))->getTable()) - ->whereIn('model_type', [Product::class, Collection::class, Brand::class]) + ->whereIn('model_type', [Product::morphName(), Collection::morphName(), Brand::morphName()]) ->where('collection_name', 'products'); } } From b4418b854fa7a24910d77e10f39a0cc11bfbd11a Mon Sep 17 00:00:00 2001 From: Ryan Mitchell Date: Mon, 21 Oct 2024 08:10:49 +0100 Subject: [PATCH 07/12] Fix unsupported operand type on discounts (#1984) --- packages/core/src/DiscountTypes/AbstractDiscountType.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/core/src/DiscountTypes/AbstractDiscountType.php b/packages/core/src/DiscountTypes/AbstractDiscountType.php index 8e0d3305b5..868313bb49 100644 --- a/packages/core/src/DiscountTypes/AbstractDiscountType.php +++ b/packages/core/src/DiscountTypes/AbstractDiscountType.php @@ -64,7 +64,7 @@ protected function checkDiscountConditions(Cart $cart): bool $validCoupon = $cartCoupon ? ($cartCoupon === $conditionCoupon) : blank($conditionCoupon); - $minSpend = ($data['min_prices'][$cart->currency->code] ?? 0) / $cart->currency->factor; + $minSpend = (int) ($data['min_prices'][$cart->currency->code] ?? 0) / (int) $cart->currency->factor; $minSpend = (int) bcmul($minSpend, $cart->currency->factor); $lines = $this->getEligibleLines($cart); From 5266054468e09de4994427bfa61c5331ab9bea6f Mon Sep 17 00:00:00 2001 From: Aidas Klimas Date: Tue, 22 Oct 2024 14:56:48 +0800 Subject: [PATCH 08/12] Fix create product url (#1999) same as https://github.com/lunarphp/lunar/pull/1995 Co-authored-by: Aidas Klimas --- .../Filament/Resources/ProductResource/Pages/ListProducts.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/admin/src/Filament/Resources/ProductResource/Pages/ListProducts.php b/packages/admin/src/Filament/Resources/ProductResource/Pages/ListProducts.php index f02e59b67f..f994e004ee 100644 --- a/packages/admin/src/Filament/Resources/ProductResource/Pages/ListProducts.php +++ b/packages/admin/src/Filament/Resources/ProductResource/Pages/ListProducts.php @@ -27,7 +27,7 @@ protected function getDefaultHeaderActions(): array static::createActionFormInputs() )->using( fn (array $data, string $model) => static::createRecord($data, $model) - )->successRedirectUrl(fn (Model $record): string => route('filament.lunar.resources.products.edit', [ + )->successRedirectUrl(fn (Model $record): string => ProductResource::getUrl('edit', [ 'record' => $record, ])), ]; From d01de0dccf254ae4d63d160d8c43b0386911bef9 Mon Sep 17 00:00:00 2001 From: Ryan Mitchell Date: Mon, 28 Oct 2024 11:09:43 +0000 Subject: [PATCH 09/12] Make Product name and SKU searchable (#1986) --- .../RelationManagers/OrdersRelationManager.php | 2 +- packages/admin/src/Filament/Resources/ProductResource.php | 6 ++++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/packages/admin/src/Filament/Resources/CustomerResource/RelationManagers/OrdersRelationManager.php b/packages/admin/src/Filament/Resources/CustomerResource/RelationManagers/OrdersRelationManager.php index 99b114b773..b01eea5116 100644 --- a/packages/admin/src/Filament/Resources/CustomerResource/RelationManagers/OrdersRelationManager.php +++ b/packages/admin/src/Filament/Resources/CustomerResource/RelationManagers/OrdersRelationManager.php @@ -5,8 +5,8 @@ use Filament\Tables; use Filament\Tables\Table; use Lunar\Admin\Filament\Resources\OrderResource; -use Lunar\Admin\Support\RelationManagers\BaseRelationManager; use Lunar\Admin\Filament\Resources\OrderResource\Pages\ManageOrder; +use Lunar\Admin\Support\RelationManagers\BaseRelationManager; use Lunar\Models\Order; class OrdersRelationManager extends BaseRelationManager diff --git a/packages/admin/src/Filament/Resources/ProductResource.php b/packages/admin/src/Filament/Resources/ProductResource.php index 724c09a1a9..7627d533da 100644 --- a/packages/admin/src/Filament/Resources/ProductResource.php +++ b/packages/admin/src/Filament/Resources/ProductResource.php @@ -300,7 +300,8 @@ public static function getNameTableColumn(): Tables\Columns\Column ->attributeData() ->limitedTooltip() ->limit(50) - ->label(__('lunarpanel::product.table.name.label')); + ->label(__('lunarpanel::product.table.name.label')) + ->searchable(); } public static function getSkuTableColumn(): Tables\Columns\Column @@ -323,7 +324,8 @@ public static function getSkuTableColumn(): Tables\Columns\Column }) ->listWithLineBreaks() ->limitList(1) - ->toggleable(); + ->toggleable() + ->searchable(); } public static function getDefaultRelations(): array From e97122ea4b6cd904fb1fca38f8f91a8fa0ef1520 Mon Sep 17 00:00:00 2001 From: Lionel Guichard Date: Tue, 5 Nov 2024 10:38:13 +0100 Subject: [PATCH 10/12] Fix Rule unique slug url use morph class (#1983) --- .../src/Support/Resources/Pages/ManageUrlsRelatedRecords.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/admin/src/Support/Resources/Pages/ManageUrlsRelatedRecords.php b/packages/admin/src/Support/Resources/Pages/ManageUrlsRelatedRecords.php index 3d8cc834d0..d644f000e1 100644 --- a/packages/admin/src/Support/Resources/Pages/ManageUrlsRelatedRecords.php +++ b/packages/admin/src/Support/Resources/Pages/ManageUrlsRelatedRecords.php @@ -55,7 +55,7 @@ public function form(Form $form): Form ignoreRecord: true, modifyRuleUsing: function (Unique $rule, callable $get) { return $rule - ->where('element_type', static::$model) + ->where('element_type', (new static::$model)->getMorphClass()) ->where('language_id', $get('language_id')); } ) From 0b2d76ec604760029ca25256fdffaf9d86c622a7 Mon Sep 17 00:00:00 2001 From: tvlokven <113194867+tvlokven@users.noreply.github.com> Date: Tue, 5 Nov 2024 10:43:14 +0100 Subject: [PATCH 11/12] =?UTF-8?q?Fix=20an=20issue=20where=20the=20AmountOf?= =?UTF-8?q?f=20percentage=20is=20cast=20to=20an=20int,=20even=20t=E2=80=A6?= =?UTF-8?q?=20(#2004)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The admin panel allows you to enter a decimal value when creating an AmountOff Discount with a percentage discount. However, it gets cast to an int in the AmountOff class, which results in the percentage being rounded and the discount amount being slightly off. You could argue that usually percentage discounts are given as whole numbers, but since the admin panel already supports decimal values, I think this should be changed. Fixes #2003 --------- Co-authored-by: tim Co-authored-by: Author Co-authored-by: Alec Ritson --- packages/core/src/DiscountTypes/AmountOff.php | 2 +- .../core/Unit/DiscountTypes/AmountOffTest.php | 35 +++++++++++++------ 2 files changed, 25 insertions(+), 12 deletions(-) diff --git a/packages/core/src/DiscountTypes/AmountOff.php b/packages/core/src/DiscountTypes/AmountOff.php index 105bca64e9..a915a6f48d 100644 --- a/packages/core/src/DiscountTypes/AmountOff.php +++ b/packages/core/src/DiscountTypes/AmountOff.php @@ -224,7 +224,7 @@ protected function getEligibleLines(Cart $cart): \Illuminate\Support\Collection /** * Apply the percentage to the cart line. */ - private function applyPercentage(int $value, Cart $cart): Cart + private function applyPercentage(float $value, Cart $cart): Cart { $lines = $this->getEligibleLines($cart); diff --git a/tests/core/Unit/DiscountTypes/AmountOffTest.php b/tests/core/Unit/DiscountTypes/AmountOffTest.php index 06e9a03b74..f7729fc83e 100644 --- a/tests/core/Unit/DiscountTypes/AmountOffTest.php +++ b/tests/core/Unit/DiscountTypes/AmountOffTest.php @@ -784,7 +784,16 @@ expect($lastLine->discountTotal->value)->toEqual(333); }); -test('can apply percentage discount', function () { +test('can apply percentage discount', function ( + string $coupon, + float $percentage, + int $discountTotalForOne, + int $taxTotalForOne, + int $totalForOne, + int $discountTotalForTwo, + int $taxTotalForTwo, + int $totalForTwo +) { $customerGroup = CustomerGroup::getDefault(); $channel = Channel::getDefault(); @@ -794,7 +803,7 @@ $cart = Cart::factory()->create([ 'channel_id' => $channel->id, 'currency_id' => $currency->id, - 'coupon_code' => '10PERCENTOFF', + 'coupon_code' => $coupon, ]); $purchasable = ProductVariant::factory()->create(); @@ -816,9 +825,9 @@ $discount = Discount::factory()->create([ 'type' => AmountOff::class, 'name' => 'Test Coupon', - 'coupon' => '10PERCENTOFF', + 'coupon' => $coupon, 'data' => [ - 'percentage' => 10, + 'percentage' => $percentage, 'fixed_value' => false, ], ]); @@ -843,9 +852,9 @@ $cart = $cart->calculate(); - expect($cart->discountTotal->value)->toEqual(100); - expect($cart->taxTotal->value)->toEqual(180); - expect($cart->total->value)->toEqual(1080); + expect($cart->discountTotal->value)->toEqual($discountTotalForOne); + expect($cart->taxTotal->value)->toEqual($taxTotalForOne); + expect($cart->total->value)->toEqual($totalForOne); $cart->lines()->delete(); @@ -857,10 +866,14 @@ $cart = $cart->refresh()->calculate(); - expect($cart->discountTotal->value)->toEqual(200); - expect($cart->taxTotal->value)->toEqual(360); - expect($cart->total->value)->toEqual(2160); -}); + expect($cart->discountTotal->value)->toEqual($discountTotalForTwo); + expect($cart->taxTotal->value)->toEqual($taxTotalForTwo); + expect($cart->total->value)->toEqual($totalForTwo); +})->with([ + '10% Discount' => ['10PERCENTOFF', 10, 100, 180, 1080, 200, 360, 2160], + '10.25% Discount' => ['10PT25PERCENTOFF', 10.25, 103, 179, 1076, 205, 359, 2154], + '10.5% Discount' => ['10PT5PERCENTOFF', 10.5, 105, 179, 1074, 210, 358, 2148], +]); test('can only same discount to line once', function () { $customerGroup = CustomerGroup::getDefault(); From 4635e1c06c2263c0188a545065a727b4f2045d3c Mon Sep 17 00:00:00 2001 From: Andrea De Luca <53230888+se09deluca@users.noreply.github.com> Date: Thu, 7 Nov 2024 09:52:15 +0100 Subject: [PATCH 12/12] Fix: typo in blade variable name (#2015) The pdf/order.blade.php file expects the variable that holds the order data to be named 'record'. 'order' should be the old variable name (before 1.x) --- .../src/Filament/Resources/OrderResource/Pages/EditOrder.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/admin/src/Filament/Resources/OrderResource/Pages/EditOrder.php b/packages/admin/src/Filament/Resources/OrderResource/Pages/EditOrder.php index 7faee4a2f4..818581b64c 100644 --- a/packages/admin/src/Filament/Resources/OrderResource/Pages/EditOrder.php +++ b/packages/admin/src/Filament/Resources/OrderResource/Pages/EditOrder.php @@ -44,7 +44,7 @@ protected function getDefaultHeaderActions(): array return response()->streamDownload(function () { echo Pdf::loadView('lunarpanel::pdf.order', [ - 'order' => $this->record, + 'record' => $this->record, ])->stream(); }, name: "Order-{$this->record->reference}.pdf"); }),