icon with button in woodmart
Wed Jun 12 2024 19:17:31 GMT+0000 (Coordinated Universal Time)
Saved by
@Promakers2611
function custom_external_add_to_cart_button($button, $product) {
if ($product->is_type('external')) {
// URL of the Amazon icon image
$icon_url = 'https://mejormovil.es/wp-content/themes/woodmart/images/amazon-icon.png';
$button_text = 'See Prices';
// Create the button HTML with the Amazon icon and new text
$button = sprintf(
'<a href="%s" class="button product_type_external add-to-cart-loop customize-unpreviewable" data-product_id="%s" aria-label="%s" rel="nofollow">
<img src="%s" style="width: 20px; height: auto; margin-right: 5px; vertical-align: middle;" alt="Amazon Icon"/> %s
</a>',
esc_url($product->add_to_cart_url()), // URL for the product
esc_attr($product->get_id()), // Product ID
esc_attr($product->add_to_cart_description()), // ARIA label
esc_url($icon_url), // Amazon icon URL
esc_html($button_text) // Button text
);
}
return $button;
}
add_filter('woocommerce_loop_add_to_cart_link', 'custom_external_add_to_cart_button', 10, 2);
content_copyCOPY
Comments