Fix Non-Purchasable Simple Product in Product Loop

add_to_cart_button class is only applied if the product is purchasable
This commit is contained in:
justinstern 2014-01-09 21:38:05 -05:00
parent 656663ba47
commit e96a6ae3f3
1 changed files with 3 additions and 2 deletions

View File

@ -12,11 +12,12 @@ if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
global $product;
echo apply_filters( 'woocommerce_loop_add_to_cart_link',
sprintf( '<a href="%s" rel="nofollow" data-product_id="%s" data-product_sku="%s" class="button add_to_cart_button product_type_%s">%s</a>',
sprintf( '<a href="%s" rel="nofollow" data-product_id="%s" data-product_sku="%s" class="button %s product_type_%s">%s</a>',
esc_url( $product->add_to_cart_url() ),
esc_attr( $product->id ),
esc_attr( $product->get_sku() ),
$product->is_purchasable() ? 'add_to_cart_button' : '',
esc_attr( $product->product_type ),
esc_html( $product->add_to_cart_text() )
),
$product );
$product );