This topic has 6 replies, 2 voices, and was last updated 1 years, 9 months ago ago by ramvidal
Hi , can help me for put a custom button in a product grid…is possible to add different buttons in each product??
Hello, Ramvidal,
You may add next custom php code to your child-theme/functions.php:
add_filter('etheme_product_grid_list_product_elements', function($elements) {
$elements['custom_button'] = esc_html__( 'Custom button', 'xstore-child' );
return $elements;
});
add_action( 'etheme_product_grid_list_product_element_render', function($key, $product, $edit_mode, $main_class) {
if ( $key == 'custom_button' ) { ?>
<a href="https://custom_url.com" target="_blank" class="btn"><?php echo esc_html__('Custom text', 'xstore-child'); ?></a>
<?php }
}, 10, 4 );
The result you will get is next:
1/ https://prnt.sc/MzMFEN301XzZ – custom button switcher for Products grid/Products list/Products carousel Elementor widgets.
2/ https://prnt.sc/xH76Ve3cGyXs – On activating switcher of “Custom button”
Waiting for your feedback!
Kind Regards,
8theme team
Really the best service. The best theme. Thanks !
I worked with Divi, oxygen, builder, betheme , woodmart and more
HOW CAN I GAIN A LITTLE SPACE PLEASE AND CHANGE THE BUTTON COLOR?
https://prnt.sc/dz6OPDaQDyfY
Hello, Ramvidal,
Please change the following code
add_action( 'etheme_product_grid_list_product_element_render', function($key, $product, $edit_mode, $main_class) {
if ( $key == 'custom_button' ) { ?>
<a href="https://custom_url.com" target="_blank" class="btn"><?php echo esc_html__('Custom text', 'xstore-child'); ?></a>
<?php }
}, 10, 4 );
to this
add_action( 'etheme_product_grid_list_product_element_render', function($key, $product, $edit_mode, $main_class) {
if ( $key == 'custom_button' ) { ?>
<a href="https://custom_url.com" target="_blank" class="btn my_custom-button-class"><?php echo esc_html__('Custom text', 'xstore-child'); ?></a>
<?php }
}, 10, 4 );
Then go to this section https://prnt.sc/tVcpVf786A9m and enter the next code
.my_custom-button-class{
margin-top: 10px;
}
there you can control the value of the space.
Kind Regards,
8theme team
thanks
Tagged: add to cart, best, button, custom, grid, product, themes, woocommerce
The issue related to '‘put a custom button in product grid below add to cart’' has been successfully resolved, and the topic is now closed for further responses