What is Ajax add to cart? Adding to the cart without a page reload
Published , by the PrintBlob team.
Ajax add to cart puts an item in the shopping cart in the background, without loading a new page: the customer stays where they are, the cart icon updates, and often a mini cart slides open to show what was added. The name comes from Ajax, the technique of a page talking to the server without reloading.
Without it, pressing Add to cart sends the whole page to the server, which answers with a new page, often the cart. That costs a page load and takes the customer away from the product they were looking at.
How it works in WooCommerce
WooCommerce has Ajax add to cart built in for the buttons on shop and category pages, switched on under WooCommerce › Settings › Products with “Enable Ajax add to cart buttons on archives”. Its script sends the item to WooCommerce, and WooCommerce answers with fresh cart fragments: the pieces of the page that show the cart, such as the count in the header and the contents of the mini cart, which the script puts in place.
Around the add, WooCommerce’s script announces two events on the page: adding_to_cart before it adds and added_to_cart after. Themes, page builders’ cart widgets and side-cart plugins listen to them to open their mini cart, show a notice or update a counter.
WooCommerce’s block-based Cart, Checkout and Mini-Cart use the Store API instead, and announce adds with an event of their own. The blocks also listen to added_to_cart, so an add announced the classic way reaches them too.
Next to these, WooCommerce has a setting that skips Ajax entirely: “Redirect to cart page after successful addition”, which sends the customer to the cart after every add.
Why it matters for a product designer
A product designer adds to the cart with its own button, after saving the customer’s design. If it adds through the Store API and announces the add only to the blocks, a classic theme’s mini cart does not hear it: the item is in the cart, but the header still shows 0 until the next page. A designer that sends what WooCommerce’s own Ajax add to cart sends works with both kinds of theme.
In PrintBlob
Since version 1.7.1, PrintBlob’s designer sends adding_to_cart, refreshes WooCommerce’s cart fragments and sends added_to_cart with them, as WooCommerce does, and goes to the cart instead when the shop asks for that. The checks for this and other theme problems are in product designer problems in WooCommerce themes.
Sources
- WooCommerce: Configuring WooCommerce settings, Products, read 11 Nov 2026
- WooCommerce source: assets/js/frontend/add-to-cart.js, read 11 Nov 2026