-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Componentes para cupon y cart, categorias en show product
- Loading branch information
1 parent
d22eb69
commit bdf7a5b
Showing
18 changed files
with
178 additions
and
108 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
<?php | ||
|
||
namespace App\Http\Livewire; | ||
|
||
use Cart; | ||
use App\Coupon; | ||
use Livewire\Component; | ||
|
||
class ApplyCoupon extends Component | ||
{ | ||
public $couponCode = ''; | ||
|
||
public function applyCoupon() | ||
{ | ||
$couponCode = $this->couponCode; | ||
|
||
$couponData = Coupon::where('code', $couponCode)->first(); | ||
|
||
if (!$couponData) { | ||
$this->emit('cartUpdated', 'error', 'Coupon does not exist'); | ||
} else { | ||
// coupon logic | ||
$condition = new \Darryldecode\Cart\CartCondition(array( | ||
'name' => $couponData->name, | ||
'type' => $couponData->type, | ||
'target' => 'total', // this condition will be applied to cart's subtotal when getSubTotal() is called. | ||
'value' => $couponData->value, | ||
)); | ||
|
||
Cart::session(auth()->id())->condition($condition); // for a speicifc user's cart | ||
|
||
$this->emit('cartUpdated', 'message', 'Coupon applied!'); | ||
} | ||
} | ||
|
||
public function render() | ||
{ | ||
return view('livewire.apply-coupon'); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
<?php | ||
|
||
namespace App\Http\Livewire; | ||
|
||
use Livewire\Component; | ||
use Cart; | ||
|
||
class CartBox extends Component | ||
{ | ||
public $cartItems = []; | ||
|
||
public function mount() | ||
{ | ||
$this->cartItems = Cart::session(auth()->id())->getContent()->toArray(); | ||
} | ||
|
||
public function render() | ||
{ | ||
return view('livewire.cart-box'); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
<div> | ||
<div class="coupon-all"> | ||
<div class="coupon"> | ||
<h4>Have you a coupon?</h4> | ||
<form wire:submit.prevent="applyCoupon"> | ||
<input id="coupon_code" class="input-text" name="coupon_code" placeholder="Coupon code" type="text" | ||
wire:model="couponCode"> | ||
<input class="button" name="apply_coupon" value="Apply coupon" type="submit"> | ||
</form> | ||
</div> | ||
</div> | ||
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
<div> | ||
<ul class="cart-dropdown"> | ||
@if (count($cartItems) > 0 ) | ||
@foreach ($cartItems as $item) | ||
<li class="single-product-cart"> | ||
<div class="cart-img"> | ||
<a href="{{ route('product.show', $item['id']) }}"><img src="{{ asset('img/'.$item['associatedModel']['cover_img']) }}" alt=""></a> | ||
</div> | ||
<div class="cart-title"> | ||
<h5><a href="{{ route('product.show', $item['id']) }}">{{ $item['name'] }}</a></h5> | ||
<span>${{ Cart::session(auth()->id())->get($item['id'])->price }} x {{ $item['quantity'] }}</span> | ||
</div> | ||
<div class="cart-delete"> | ||
<livewire:cart-update-form :item="$item" :key="$item['id']" /> | ||
<a href="{{ route('cart.destroy', $item['id']) }}"><i class="ti-trash"></i></a> | ||
</div> | ||
</li> | ||
@endforeach | ||
@else | ||
<li class="single-product-cart"> | ||
<h5 class="text-center">Add produts to the cart</h5> | ||
</li> | ||
@endif | ||
|
||
<li class="cart-btn-wrapper"> | ||
<a class="cart-btn btn-hover" href="{{route('cart.index')}}">View cart</a> | ||
<a class="cart-btn btn-hover" href="{{route('cart.checkout')}}">Checkout</a> | ||
</li> | ||
</ul> | ||
</div> |
Oops, something went wrong.