Heres a nice article describing how to do this, but a very different approach to yours :
https://aceplugins.com/ajax-add-to-cart-button-on-the-product-page-woocommerce/
Since you know how many items are being added to the cart (1 based on your link) you could just fake some addition and upate the cart icon value
Assuming the cart icon number has an id “cart-icon’ Eg :
function addToCart(p_id) {
$.get('?add-to-cart=" + p_id, function() {
// SO IF YOU ALREADY HAD 3 IN CART IT WILL NOW BE 4
$("#cart-icon').text( $('#cart-icon').text() + 1);
});
}
Related Posts:
- Change add to cart text if a product is in cart on WooCommerce
- Set a specific default stock quantity on all WooCommerce new products
- How to implement Handling Fee like the Shipping on Cart and Checkout page on WooCommerce [closed]
- Update html tag class values based on Woocommerce product attribute dropdown selection [closed]
- Woocommerce checkout page reload on up dating shipping method
- Woocommerce Moving Review Below add to cart breaks button
- Force uppercase on some WooCommerce checkout fields input
- In WooCommerce product archive, how can you also set the quantity to be added to cart by typing, instead of just by using +/-?
- jquery.validation.js is not working in woocommerce checkout page form
- WooCommerce event works in jQuery but not in JavaScript
- How to Remove Active css from woocommerce variation?
- Ajax add to cart not updating Elementor mini cart totals
- Dynamic product total add to cart amount
- How to add php variable inside wc_enqueue_js(‘jQuery’) function?
- Running JavaScript after using WooCommerce Filter Plugin
- Format number to 2 decimal places
- Can’t add Select2 to select in variable product (admin)
- Woocommerce Flexslider touch functionality on desktop not working
- Retrieve Woocommerce Cart Url with javascript/jquery [closed]
- Removing ‘woocommerce-no-js’ class from body
- How do I fix this “Uncaught ReferenceError: woodmartThemeModule is not defined”?
- Where is the “default attribute” values located in the phpMyAdmin in Woocommerce?
- Changing Woocommerce price display [closed]
- Which WooCommerce hook do I need to use to place the coupon field after the checkout sidebar
- WooCommerce Cart – Group Products By Category
- WooCommerce – update order item price and recalculate totals
- WooCommerce change price in cart [closed]
- Categories not shown in admin after adding woocommerce products via wp wc cli
- Enabling autosave when plugin disabled
- WooCommerce email text based on category && shipping zone && payment method [closed]
- woocommerce – get_image_size() deprecated [closed]
- WooCommerce Shop Orders by Date
- Show list of woo commerce orders where particular zip code exists using pre_get_posts?
- How to handle Woocommerce API credentials
- Woocommerce Shipping label just hangs
- Modifying a .js Function for Print [QZ Tray, WooCommerce POS]
- adding a script with type=”module” to woocommerce admin area
- Redirect customer to login page (with other signup plugin) if user not logged in when proceeding to checkout
- Featured image for product listings, but another image as the product image?
- user password reset e-mail
- Extending the woocommerce product export functionality
- Woo Related Products How to override the plugin script?
- Woocommerce how to alter shipping tax before checkout
- Line break on Product details [closed]
- WooCommerce add class name in the list [closed]
- How to display Woocommerce variations prices and descriptions
- Adding Transaction-Specific Conversion Tracking from Adwords into WooCommerce
- New field on checkout is shown but it’s not saved on the order details [closed]
- How to rewrite product permalinks in Woocommerce to use category slugs
- Woocommerce altered my homepage, and I can’t figure out how to revert it [closed]
- Woocommerce – Problem sorting and filtering products with different tax rates by price [closed]
- Why does my loop breaks the css below?
- How to add order status class to the body tag?
- Woocommerce – Change the template?
- Wooocommerce disable check_cart_item_stock if cart item has specific meta
- WP/WooCommerce multisite with polylang, product duplication between websites [closed]
- Show password while you are typing it on the “my account” login page
- Functions.php change for Woocommerce not working
- /page/ is not working with a custom permalink structure (WooCommerce)
- WooCommerce Bookings Plugin Not Saving Order ID
- Woocommerce Register Error
- Where is this text in a wordpress email coming from? Want to change/remove
- Add starts rating in woocommerce product comment from backend
- Need to check if user has completed a woo commerce payment
- Woocommerce show field in product if product-tag is “VET” else hide
- How to make a “subtitle” for each Woocommerce product
- Create Product with Woocommerce API, but Variations are not linked
- How to reduce checkout loading time of `?wc-ajax=checkout`
- unable to customize query to get filtered products by meta_key
- Woocommerce + Google Analytics (Conversion Rate Not Working)
- send order detail to swiftpos
- WordPress Woocommerce REST API JSON Error
- data-value for custom woocommerce field showing in code but not visable on page load
- Update user meta when customer update their first name
- Dynamic subdomains for woocommerce affiliate sales but NO multisite. Is that possible?
- Woocommerce posts and products links works only once and then get 404 error
- How can we find a WooCommerce shop bottleneck? (only when cart is full)
- Limit image resolution on upload file for specific field
- Woocommerce pagination problem- page/2 = 404 solution
- Woocommerce , how to set billing_address via JS?
- Using admin email in billing address
- Overriding Plugin function in your child theme
- Enable Payment gateway if ACF checkbox in user profile is checked
- How do you reactive related products on WooCommerce when it has been disabled?
- Display product variations in shop page
- How can I locate where the actions are defined? [duplicate]
- Shortcodes in billing fields doesn’t work
- Update a user meta key based on WooCommerce product purchase
- How to fix spacing in address tab in my account page
- show multiple product photos on WooCommerce single page
- How to get _POST variable on WooCommerce product page (form on homepage)
- How do I put woocommerce cart page to my checkout page? [closed]
- Search box missing Woocommerce Product Bundle Extension
- DatePicker in Woocommerce (My Account) Registration [closed]
- problems with an object product wooCommerce [closed]
- CSS url rules not relative to css path in account endpoint areas. IE. subscriptions
- registration_errors not working
- Detect Product Type with code
- Verify if woocommerce supports this design [closed]
- Hook for Woocommerce checkout fields