If you have a search widget on the cart page which is wrapped in a div
(the default wrapper for widgets) the ajax cart would try to update on
search submit. This change ensures the search form is excluded on
`submit_click`.
Some themes add internal HTML to links, so this adjusts
to use currentTarget, which should always be the node on which
the event is subscribed instead of the target which triggered
the event.
Fixes#10813
This adds a "clicked" attribute to clicked form buttons,
which augments Safari specifically since it sets activeElement
to the page body when a button is clicked.
The server shows a different page for the cart
when the cart is completely empty. The Cart AJAX
update subverted this and caused issue #10736 as
a result. Not to mention, the page just didn't look
good or functional with no items left in the cart.
This commit forces a reload any time the cart becomes
empty, which shows the empty page generated from
the server.
Fixes#10736
The cart was not getting updated in all cases
when products were removed or shipping was
updated. This ensures those changes update the
cart as well.
Fixes#10734
The previous jQuery selector was on div.woocommerce,
which was also selecting other divs on the page.
This is more specific to the cart table on the page.
This update actually takes the code and refactors it into
two object handlers, cart and cart_shipping.
Also, more block comments are added to each function.
The coupon and update cart logic was tripping on each other
between the click handling and form submit handling.
This commit combines the event handler, then splits off from there.
Since the code is built to use a form submit for all the quanitities
already, I just made this an ajax call instead of a whole page call.
The result is the exactly the same and the .woocommerce div is replaced
with the resulting HTML.
Adds an ajax call for applying coupons while on the cart
screen (not checkout, as it already has this.)
This is the first commit to add ajax calls to the cart update
functions. See issue #6734
If there are more variations than the threshold allows (set to 20
currently) this loads the matching variation via ajax instead of inline
in the HTML. #8477
For a more detailed explaination of why this is helpful, see
Issue #4202. In short, from a dev ops perspective, if we want to build /
concatonate our front end scripts into a single application.js file, we
need to ensure scripts first check for dependent global object helpers
before trying to use them. For example, there are several objects
(created via PHP using `wp_localize_script`) which generate objects such
as `wc_single_product_params`. These objects will not exist on most
other pages, however these scripts attempt to execute code that
references these objects.