Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Proceed to Checkout is disabled if there is no billing or shipping in… #6

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion app/Http/Controllers/CartController.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,9 @@ public function index()
$total += $product->price * $cartItems[$product->id]['quantity'];
}

return view('cart.index', compact('cartItems', 'products', 'total'));
$user = auth()->user();

return view('cart.index', compact('cartItems', 'products', 'total', 'user'));
}

public function add(Request $request, Product $product)
Expand Down
4 changes: 4 additions & 0 deletions resources/css/app.css
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,10 @@
.btn-primary {
@apply text-white bg-purple-600 py-2 px-4 rounded shadow-md hover:bg-purple-700 active:bg-purple-800 transition-colors;
}

.btn-primary:disabled {
@apply bg-gray-400 hover:bg-gray-300;
}
}

body {
Expand Down
22 changes: 17 additions & 5 deletions resources/views/cart/index.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,6 @@ class="text-purple-600 hover:text-purple-500"
</div>
</template>
<!-- Product Item -->

<div class="border-t border-gray-300 pt-4">
<div class="flex justify-between">
<span class="font-semibold">Subtotal</span>
Expand All @@ -76,12 +75,25 @@ class="text-purple-600 hover:text-purple-500"
Shipping and taxes calculated at checkout.
</p>

<form action="{{route('cart.checkout')}}" method="post">
@csrf
<button type="submit" class="btn-primary w-full py-3 text-lg">
@if ( !Auth::check() || Auth::user()->shippingAddress != null && Auth::user()->billingAddress != null )
<form action="{{route('cart.checkout')}}" method="post" >
@csrf
<button type="submit" class="btn-primary w-full py-3 text-lg disabled">

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

disabled class is applied even when all checks are okay

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

referring to this line

Proceed to Checkout
</button>
</form>
@else
<div class="flex justify-center items-center pt-2 pb-2 px-1 mb-3 rounded border border-solid border-orange-600 w-full text-lg">
<svg class="h-5 w-5 fill-orange-500 mr-1"><path xmlns="http://www.w3.org/2000/svg" d="M19.64 16.36L11.53 2.3A1.85 1.85 0 0 0 10 1.21 1.85 1.85 0 0 0 8.48 2.3L.36 16.36C-.48 17.81.21 19 1.88 19h16.24c1.67 0 2.36-1.19 1.52-2.64zM11 16H9v-2h2zm0-4H9V6h2z"/></svg>
<p class="text-center">
To "Proceed to Checkout" you will have to update your <b>Billing and Shipping information</b>!
</p>
</div>
<button disabled class="btn-primary w-full py-3 text-lg">
Proceed to Checkout
</button>
</form>
@endif

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

closing form tag is missing


</div>
</div>
<!--/ Product Items -->
Expand Down