Malin revisó este gist . Ir a la revisión
1 file changed, 18 insertions
custom-add-to-cart-button.php(archivo creado)
| @@ -0,0 +1,18 @@ | |||
| 1 | + | /* START custom add to cart button on home */ | |
| 2 | + | function custom_add_to_cart_button_with_icon() { | |
| 3 | + | // Remove the default add to cart button | |
| 4 | + | remove_action('woocommerce_after_shop_loop_item', 'woocommerce_template_loop_add_to_cart', 10); | |
| 5 | + | ||
| 6 | + | // Add the new custom button | |
| 7 | + | add_action('woocommerce_after_shop_loop_item', 'woocommerce_template_loop_add_to_cart_with_icon', 10); | |
| 8 | + | } | |
| 9 | + | ||
| 10 | + | function woocommerce_template_loop_add_to_cart_with_icon() { | |
| 11 | + | global $product; | |
| 12 | + | echo sprintf('<a href="%s" class="button add_to_cart_button" style="display:inline-block; background-image:url(\'https://staging.qrh.app/wp-content/uploads/2024/03/XL-2.png\'); width: 48px; height: 48px; background-size: cover;"></a>', esc_url($product->add_to_cart_url())); | |
| 13 | + | } | |
| 14 | + | ||
| 15 | + | add_action('init', 'custom_add_to_cart_button_with_icon'); | |
| 16 | + | ||
| 17 | + | ||
| 18 | + | /* END custom add to cart button on home */ | |
Siguiente
Anterior