From a cursory overview, the cross-sells are added via the same ajax add to cart script as regular shop loop archive products and I don’t see a way to distinguish between when it’s a cross-sell and when it’s not. You could run a script conditionally only on the cart page, and then listen to the added_to_cart trigger, which might then only be happening for cross sells (assuming you don’t have other ajax add to cart buttons on the cart page)
Or it appears that the add to cart button is passed as a variable to the added_to_cart
trigger. You may be able to do some DOM manipulation there to see if it was part of the cross sells div. Totally wild guess:
$( document.body ).on( 'added_to_cart', function( event, fragments, cart_hash, $button ){
if( $button.closest( 'div.cross-sells' ) ) {
// was a cross-sell added to the cart
}
});
Related Posts:
- Apply jquery script to only woocommerce product pages and categories
- woocommerce target button with class after ajax update
- Woocommerce checkout field maxlength, make input number field only (postcode)
- Auto scroll to id on page load on all pages except home page. Only do this on mobile
- Hide ‘add to cart’ when certain value in dropdown is selected
- How to run a function every 5 minutes?
- How to display custom field in woocommerce orders in admin panel?
- Woocommerce add to simple product attribute programmatically [closed]
- ajax live search for post title
- How to Acheive the custom woocommerce category template
- Remove product description from product archive page
- Hide some items from Screen options in dashboard for products
- Display a function using AJAX
- Can you use admin pages functionality on the frontend of your site
- Creating loop within functions.php
- How to load some jquery code to make validation in the theme customizer?
- Display WooCommerce subscriptions for user [closed]
- Increment price for Woocommerce Minicart [closed]
- Change woocommerce products weight varation based its product category or tags? [closed]
- jquery won’t load in footer
- change in form-checkout.php by using code in functions.php
- Set quantity of woocommerce product on page visit [closed]
- Replace menu links with # and add name to its li
- WooCommerce – Reset quantity input field when variation changes
- How to load jQuery in the footer – nothing works for me
- How can I remove the main description text box in a Woocommerce product editor page? I only use the “Product short description” text box [closed]
- Wp_query function to search from product_title ‘OR’ product tags name
- Allow Post Author to be 0 on Update
- Trouble with adding a wp_enqueue_script on wordpress
- WP Ajax Function Always Returning undefined
- Scripts not appending to element in AJAX call – why?
- Pass Category Name, Description and Photo into variables to pass to jQuery
- Remove the product category module block from the Woocommerce product page
- How to change the order of Jquery in the footer of my theme?
- how to en-queue jQuery to load before the tag
- Attempt to change jQuery version caused White Screen of Death
- Change CSS for logged in users
- Always the Latest google jQuery instead of default WordPress jQuery
- Add a jQuery Function
- jQuery does not work
- Functions when woocommerce isn’t installed
- How to change this simple code so that it sends the email notification after payment in WooCommerce?
- Changing parent element’s class or style
- Enqueuing latest version of jQuery into a child theme returns a blank screen
- echo custom fields with AJAX
- Adding jQuery datepicker to Custom Post Type Metabox [closed]
- replace text in Sort Box
- Woocommerce image sizes missing from Appearance › Customize but not declared by theme
- add referrer to woo
- Way to redirect all Product Sub Category to its Main category Page?
- Where is this JQuery coming from?
- How add body_class from wp_termmeta
- WordPress can’t get jquery/unslider to work
- Adding product to WooCommerce cart [closed]
- Add loggedout class on body using a function or JS
- Are innerHTML elements visible to jQuery functions?
- Why a SlideShow (made using JQuery FlexSlider) can’t work if I load it form functions.php but work if I load it from my footer.php file? [closed]
- Creating multiple category drop down
- How to add php within jquery
- Help with IF has focus then… statment
- Execute PHP code only with specific user role
- Woocommerce Variable Product Dropdown for Custom Shop Template
- How to hide content on mobile in the functions.php file – woocommerce
- How to hide WooCommerce product title and short description to non logged in users?
- localize_script but data changes dependent on product ID
- Populate Product Regular Price with a calculated ACF Field Value
- removing description tabs – single product page – breaks footer
- Link product attribute value to a URL – woocommerce
- Remove text after a dot and a colon in Woocommerce product title
- Help with with my function for wordpress
- Remove clickable Link of WordPress Site Logo from Woocommerce Single Product page
- Problems adding a new field to product in cart
- Images with overlay
- How to use `foreach()` in ajax call
- Variable function names
- Override plugin function to show invoices even if not logged in
- How To Display Author Popup on Entry Meta (Genesis Framework)?
- how can I change the read more link destinations and direct all to the same page?
- Woocommerce custom calculation function
- button to toggle css styling / div visibility?
- add product thumbnail to checkout page only and include variation name
- WordPress Ajaxifying not working properly
- Move product attributes after summary on single product page
- Which method is more correct for removing WooCommerce Extensions menu item?
- Load scripts into an AJAX div
- Load scripts into an AJAX div
- Automatic add space if user enters number(any digit)
- WordPress Jquery+scripts enqueue issue
- Insert menu into theme location depending on user logged in/out status
- Moving CDN jQuery to footer does not work?
- Adding a jQuery rotator function
- Why are some custom javascript files working but some are not
- WordPress Javascript Widget jQuery Dependency Issue
- How to use different jquery function of idangero swiper dependant on page template?
- How do I get my nav menu to show sub pages?
- Having problems loading Jquery in functions.php
- add variable to actions/functions across different files (woocommerce)
- reusing code in function and running it with loop
- sort by date in users
- Is it possible to set the first image from a gallery as the product image, rather than the featured image?