Reply To: Product buttom
Support Forums › Kampina › Product buttom › Reply To: Product buttom
January 18, 2026 at 11:30 am
#256
Keymaster
Hi Gisele,
We use the woocommerce_loop_add_to_cart_link hook to modify the button. You can add the following function to functions.php, and it will override ours, because we wrap it with:
if ( ! function_exists( 'kampina_woocommerce_loop_add_to_cart_link' ) ) :
/**
* Function for <code>woocommerce_loop_add_to_cart_link</code> filter-hook.
*
* @param string $html
* @param object $product
* @param array $args
*
* @return string
*/
function kampina_woocommerce_loop_add_to_cart_link( $html, $product, $args ) {
$button_text = $product->add_to_cart_text();
$svg_icons = '<svg class="icon-arrow" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 16" width="16" height="16">
<path d="M15.691,8.703l-4,4c-0.375,0.406-1.031,0.406-1.406,0c-0.406-0.375-0.406-1.031,0-1.406l2.281-2.312H1.004c-0.562,0-1-0.438-1-1c0-0.594,0.438-1,1-1h11.563l-2.281-2.281c-0.406-0.375-0.406-1.031,0-1.406c0.375-0.406,1.031-0.406,1.406,0l4,4C16.098,7.672,16.098,8.328,15.691,8.703z" fill="currentColor"/>
</svg>';
switch ( $product->get_type() ) {
case 'simple':
$svg_icons .= '<svg class="icon-load" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 16" width="16" height="16">
<path d="M3,8c0-0.828-0.672-1.5-1.5-1.5S0,7.172,0,8s0.672,1.5,1.5,1.5S3,8.828,3,8z M3.403,1.903c-0.828,0-1.5,0.672-1.5,1.5s0.672,1.501,1.5,1.501s1.5-0.672,1.5-1.5S4.231,1.903,3.403,1.903z M3.403,11.097c-0.828,0-1.5,0.672-1.5,1.5s0.672,1.5,1.5,1.5s1.5-0.672,1.5-1.5S4.231,11.097,3.403,11.097z M8,13c-0.828,0-1.5,0.672-1.5,1.5S7.172,16,8,16s1.5-0.672,1.5-1.5S8.828,13,8,13z M14.5,6.5C13.672,6.5,13,7.172,13,8s0.672,1.5,1.5,1.5S16,8.828,16,8S15.328,6.5,14.5,6.5z M12.597,11.097c-0.828,0-1.5,0.672-1.5,1.5s0.672,1.5,1.5,1.5s1.5-0.672,1.5-1.5S13.425,11.097,12.597,11.097z M8,0C7.172,0,6.5,0.672,6.5,1.5S7.172,3,8,3s1.5-0.672,1.5-1.5S8.828,0,8,0z" fill="currentColor"/>
</svg>';
$svg_icons .= '<svg class="icon-check" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 16" width="16" height="16">
<path d="M5.033,13.986L5.033,13.986c-0.267-0.001-0.526-0.103-0.715-0.292L0.295,9.671c-0.393-0.393-0.393-1.029,0-1.422c0.393-0.393,1.029-0.393,1.422,0l3.312,3.313l9.254-9.253c0.393-0.393,1.029-0.393,1.422,0c0.393,0.393,0.393,1.029,0,1.422l-9.958,9.957C5.559,13.876,5.299,13.986,5.033,13.986z" fill="currentColor"/>
</svg>';
break;
case 'variable':
$button_text = apply_filters( 'woocommerce_product_add_to_cart_text', $product->is_purchasable() ? __( 'Check Availability', 'kampina' ) : __( 'Read more', 'kampina' ), $product );
break;
}
$html = sprintf(
'<a href="%s" data-quantity="%s" class="%s" %s>%s%s</a>',
esc_url( $product->add_to_cart_url() ),
esc_attr( isset( $args['quantity'] ) ? $args['quantity'] : 1 ),
esc_attr( isset( $args['class'] ) ? $args['class'] : 'button' ),
isset( $args['attributes'] ) ? wc_implode_html_attributes( $args['attributes'] ) : '',
esc_html( $button_text ),
wp_kses( $svg_icons, 'kampina-svg' )
);
return $html;
}
Best Regards,
TigriWeb Team