From 0b257a476171c86215b65986237ba54200961743 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20Fox?= Date: Thu, 8 Oct 2026 12:13:18 +0200 Subject: [PATCH] fix(cart): hide Edit when there is nothing to configure Drops the mount() change and its test, as suggested in review. --- app/Livewire/Products/Checkout.php | 2 +- tests/Feature/CheckoutTest.php | 22 ---------------------- themes/default/views/cart.blade.php | 2 ++ 3 files changed, 3 insertions(+), 23 deletions(-) diff --git a/app/Livewire/Products/Checkout.php b/app/Livewire/Products/Checkout.php index 64e54a9..bac7185 100644 --- a/app/Livewire/Products/Checkout.php +++ b/app/Livewire/Products/Checkout.php @@ -92,7 +92,7 @@ class Checkout extends Component // As there is only one plan, config options and checkout config, we can directly call the checkout method to avoid confusion // This is only done when the user is not editing the cart item - if ($this->product->plans->count() === 1 && empty($this->configOptions) && empty($this->checkoutConfig) && !$this->cartProductKey) { + if ($this->product->plans->count() === 1 && empty($this->configOptions) && empty($this->checkoutConfig)) { $this->checkout(); } } diff --git a/tests/Feature/CheckoutTest.php b/tests/Feature/CheckoutTest.php index 30e5d2d..aa79abb 100644 --- a/tests/Feature/CheckoutTest.php +++ b/tests/Feature/CheckoutTest.php @@ -72,28 +72,6 @@ class CheckoutTest extends TestCase ]); } - public function test_checkout_page_does_not_redirect_if_one_plan_when_editing_cart_item(): void - { - $this->get(route('products.checkout', [ - $this->product->product->category->slug, - $this->product->product->slug, - ]))->assertRedirect(route('cart')); - - $cart = Cart::where('currency_code', 'USD')->firstOrFail(); - $item = $cart->items()->firstOrFail(); - - Once::flush(); - - $response = $this->withCookie('cart', $cart->ulid)->get(route('products.checkout', [ - $this->product->product->category->slug, - $this->product->product->slug, - 'edit' => $item->id, - ])); - - $response->assertStatus(200); - $response->assertSee($this->product->product->name); - } - public function test_checkout_page_with_multiple_plans(): void { // Add plan diff --git a/themes/default/views/cart.blade.php b/themes/default/views/cart.blade.php index 3d4e0d0..570233f 100644 --- a/themes/default/views/cart.blade.php +++ b/themes/default/views/cart.blade.php @@ -40,12 +40,14 @@ @endif + @if ($item->product->plans->count() > 1 || $item->product->configOptions->isNotEmpty() || !empty($item->checkout_config)) {{ __('product.edit') }} + @endif