added update card count
This commit is contained in:
parent
c4d08a268b
commit
561834d109
|
|
@ -4,6 +4,7 @@
|
||||||
<div class="icon-wrapper">
|
<div class="icon-wrapper">
|
||||||
<img src="{{ bagisto_asset('icons/icon (cart).svg') }}" alt="cart" />
|
<img src="{{ bagisto_asset('icons/icon (cart).svg') }}" alt="cart" />
|
||||||
</div>
|
</div>
|
||||||
<span>{{__('shop::app.checkout.cart.title')}} @if($cart)({{ $cart->items->count() }})@endif</span>
|
<span>{{__('shop::app.checkout.cart.title')}} <span class="count-cart-item">@if($cart)({{ $cart->items->count() }})@endif<span></span>
|
||||||
|
|
||||||
</a>
|
</a>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
||||||
|
|
@ -370,6 +370,9 @@
|
||||||
function showPopup(data = null) {
|
function showPopup(data = null) {
|
||||||
if (data === null) return;
|
if (data === null) return;
|
||||||
|
|
||||||
|
document.querySelector('.count-cart-item').textContent = '('+data.count_cart_item+')';
|
||||||
|
document.querySelector('.cart-quantity').textContent = data.count_cart_item;
|
||||||
|
|
||||||
// Update the popup content with the product data
|
// Update the popup content with the product data
|
||||||
document.querySelector('.add-product-item-header h4').textContent = data.name;
|
document.querySelector('.add-product-item-header h4').textContent = data.name;
|
||||||
document.querySelector('.add-product-item-price').textContent = data.price;
|
document.querySelector('.add-product-item-price').textContent = data.price;
|
||||||
|
|
|
||||||
|
|
@ -283,7 +283,7 @@
|
||||||
<a href="{{ route('shop.checkout.cart.index') }}" class="nav-link">
|
<a href="{{ route('shop.checkout.cart.index') }}" class="nav-link">
|
||||||
<div class="icon-wrapper">
|
<div class="icon-wrapper">
|
||||||
<img src="{{ bagisto_asset('icons/cart.svg') }}" alt="cart" />
|
<img src="{{ bagisto_asset('icons/cart.svg') }}" alt="cart" />
|
||||||
@if(isset($cart))<span class="cart-quantity">{{ $cart->items->count() }}</span>@endif
|
<span class="cart-quantity">@if(isset($cart)){{ $cart->items->count() }}@endif</span>
|
||||||
</div>
|
</div>
|
||||||
</a>
|
</a>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
||||||
|
|
@ -10,6 +10,7 @@ use Webkul\Customer\Repositories\WishlistRepository;
|
||||||
use Webkul\Product\Repositories\ProductRepository;
|
use Webkul\Product\Repositories\ProductRepository;
|
||||||
use Webkul\CartRule\Repositories\CartRuleCouponRepository;
|
use Webkul\CartRule\Repositories\CartRuleCouponRepository;
|
||||||
use Webkul\Product\Facades\ProductImage;
|
use Webkul\Product\Facades\ProductImage;
|
||||||
|
// use Webkul\Checkout\Facades\Cart as WebkulCart;
|
||||||
|
|
||||||
class CartController extends Controller
|
class CartController extends Controller
|
||||||
{
|
{
|
||||||
|
|
@ -92,7 +93,7 @@ class CartController extends Controller
|
||||||
// return redirect()->back();
|
// return redirect()->back();
|
||||||
// }
|
// }
|
||||||
|
|
||||||
public function add($id)
|
public function add($id)
|
||||||
{
|
{
|
||||||
|
|
||||||
$product = $this->productRepository->findOrFail($id);
|
$product = $this->productRepository->findOrFail($id);
|
||||||
|
|
@ -132,12 +133,15 @@ class CartController extends Controller
|
||||||
$productImage = ProductImage::getProductBaseImage($product)['medium_image_url'];
|
$productImage = ProductImage::getProductBaseImage($product)['medium_image_url'];
|
||||||
$priceHTML = core()->currency($product->price);
|
$priceHTML = core()->currency($product->price);
|
||||||
|
|
||||||
|
$cart = Cart::getCart();
|
||||||
|
|
||||||
return response()->json([
|
return response()->json([
|
||||||
'message' => 'Product added to cart successfully',
|
'message' => 'Product added to cart successfully',
|
||||||
'product' => [
|
'product' => [
|
||||||
'name' => $product->name,
|
'name' => $product->name,
|
||||||
'image' => $productImage,
|
'image' => $productImage,
|
||||||
'price' => $priceHTML,
|
'price' => $priceHTML,
|
||||||
|
'count_cart_item' => $cart->items->count(),
|
||||||
]
|
]
|
||||||
], 200);
|
], 200);
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue