added update card count

This commit is contained in:
mrNikto9 2024-07-24 09:49:09 +05:00
parent c4d08a268b
commit 561834d109
4 changed files with 11 additions and 3 deletions

View File

@ -4,6 +4,7 @@
<div class="icon-wrapper">
<img src="{{ bagisto_asset('icons/icon (cart).svg') }}" alt="cart" />
</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>
</div>

View File

@ -370,6 +370,9 @@
function showPopup(data = null) {
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
document.querySelector('.add-product-item-header h4').textContent = data.name;
document.querySelector('.add-product-item-price').textContent = data.price;

View File

@ -283,7 +283,7 @@
<a href="{{ route('shop.checkout.cart.index') }}" class="nav-link">
<div class="icon-wrapper">
<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>
</a>
</div>

View File

@ -10,6 +10,7 @@ use Webkul\Customer\Repositories\WishlistRepository;
use Webkul\Product\Repositories\ProductRepository;
use Webkul\CartRule\Repositories\CartRuleCouponRepository;
use Webkul\Product\Facades\ProductImage;
// use Webkul\Checkout\Facades\Cart as WebkulCart;
class CartController extends Controller
{
@ -132,12 +133,15 @@ class CartController extends Controller
$productImage = ProductImage::getProductBaseImage($product)['medium_image_url'];
$priceHTML = core()->currency($product->price);
$cart = Cart::getCart();
return response()->json([
'message' => 'Product added to cart successfully',
'product' => [
'name' => $product->name,
'image' => $productImage,
'price' => $priceHTML,
'count_cart_item' => $cart->items->count(),
]
], 200);