Skip to content

Instantly share code, notes, and snippets.

@acanza
Created February 5, 2016 12:36
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save acanza/188ee0347efaa7800032 to your computer and use it in GitHub Desktop.
Save acanza/188ee0347efaa7800032 to your computer and use it in GitHub Desktop.
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