fix(checkout): don't skip the edit page of a one-plan product in the cart
This commit is contained in:
1 parent
963b96fed9
commit
40c8d613ba
2 files changed
+23
-1
No files matched your search
@@ -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
|
// 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
|
// 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)) {
|
if ($this->product->plans->count() === 1 && empty($this->configOptions) && empty($this->checkoutConfig) && !$this->cartProductKey) {
|
||||||
$this->checkout();
|
$this->checkout();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -72,6 +72,28 @@ 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
|
public function test_checkout_page_with_multiple_plans(): void
|
||||||
{
|
{
|
||||||
// Add plan
|
// Add plan
|
||||||
|
|||||||
Reference in new issue
Block a user