Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Modifica el estilo del shortcode del botón de compra.
add_filter( 'woocommerce_loop_add_to_cart_link', 'apply_add_to_cart_shop_style' );
function apply_add_to_cart_shop_style(){
global $product;
if( !is_shop() && !is_product() ){
echo sprintf( '<a href="%s" rel="nofollow" data-product_id="%s" data-product_sku="%s" data-quantity="%s" class="%s_%s button alt">%s</a>',
esc_url( $product->add_to_cart_url() ),
esc_attr( $product->id ),
esc_attr( $product->get_sku() ),
esc_attr( isset( $quantity ) ? $quantity : 1 ),
esc_attr( $product->product_type ),
$product->is_purchasable() && $product->is_in_stock() ? 'add_to_cart_button' : '',
esc_html( $product->add_to_cart_text() )
);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.