add_filter('woocommerce_loop_add_to_cart_link','__wcmmax_add2cart');
function __wcmmax_add2cart($link) {
global $product;
$product_id = $product->id;
$product_sku = $product->get_sku();
$mmaxEnable = get_post_meta($product_id, '_wc_mmax_prd_opt_enable', true);
$minQty = get_post_meta($product_id, '_wc_mmax_min', true);
$ajax_cart_en = 'yes' === get_option( 'woocommerce_enable_ajax_add_to_cart' );
if ($ajax_cart_en && $mmaxEnable == 0) { $ajax_class = 'ajax_add_to_cart'; }
$link = sprintf( '<a href="%s" rel="nofollow" data-product_id="%s" data-product_sku="%s" data-quantity="%s" class="button %s product_type_%s %s">%s</a>',
esc_url( $product->add_to_cart_url().'&quantity='.$minQty ),
esc_attr( $product->id ),
esc_attr( $product->get_sku() ),
esc_attr( isset( $minQty ) ? $minQty : 1 ),
$product->is_purchasable() && $product->is_in_stock() ? 'add_to_cart_button' : '',
esc_attr( $product->product_type ),
esc_attr( $ajax_class ),
'<i class="p-icon icon-bag2" data-rel="tooltip" title="Add to cart"></i>'
);
return $link;
}
add the above piece of code at the bottom of theme functions i.e., in the functions.php in your activated theme. after activating the plugin
-
This reply was modified 4 years, 6 months ago by Ashok G.