diff --git a/assets/js/frontend/add-to-cart.js b/assets/js/frontend/add-to-cart.js
index 1c41dc79358..542ab06f8f2 100644
--- a/assets/js/frontend/add-to-cart.js
+++ b/assets/js/frontend/add-to-cart.js
@@ -12,7 +12,7 @@ jQuery( function( $ ) {
// AJAX add to cart request
var $thisbutton = $( this );
- if ( $thisbutton.is( '.product_type_simple' ) ) {
+ if ( $thisbutton.is( '.ajax_add_to_cart' ) ) {
if ( ! $thisbutton.attr( 'data-product_id' ) ) {
return true;
diff --git a/includes/abstracts/abstract-wc-product.php b/includes/abstracts/abstract-wc-product.php
index b1adf014ad4..0075747fa7a 100644
--- a/includes/abstracts/abstract-wc-product.php
+++ b/includes/abstracts/abstract-wc-product.php
@@ -750,6 +750,17 @@ class WC_Product {
return apply_filters( 'woocommerce_is_purchasable', $purchasable, $this );
}
+ /**
+ * Returns whether or not the product can be added to the cart via ajax
+ *
+ * @since 2.4.9
+ * @return bool
+ */
+ public function supports_ajax_add_to_cart() {
+ return apply_filters( 'woocommerce_product_supports_ajax_add_to_cart', $this->is_type( 'simple' ), $this );
+ }
+
+
/**
* Set a products price dynamically.
*
diff --git a/templates/loop/add-to-cart.php b/templates/loop/add-to-cart.php
index 46fc02b1e1c..04dd5e03285 100644
--- a/templates/loop/add-to-cart.php
+++ b/templates/loop/add-to-cart.php
@@ -12,7 +12,7 @@
* @see http://docs.woothemes.com/document/template-structure/
* @author WooThemes
* @package WooCommerce/Templates
- * @version 2.1.0
+ * @version 2.4.9
*/
if ( ! defined( 'ABSPATH' ) ) {
@@ -22,12 +22,13 @@ if ( ! defined( 'ABSPATH' ) ) {
global $product;
echo apply_filters( 'woocommerce_loop_add_to_cart_link',
- sprintf( '%s',
+ sprintf( '%s',
esc_url( $product->add_to_cart_url() ),
esc_attr( $product->id ),
esc_attr( $product->get_sku() ),
esc_attr( isset( $quantity ) ? $quantity : 1 ),
$product->is_purchasable() && $product->is_in_stock() ? 'add_to_cart_button' : '',
+ $product->supports_ajax_add_to_cart() ? 'ajax_add_to_cart' : '',
esc_attr( $product->product_type ),
esc_html( $product->add_to_cart_text() )
),