Put a custom button in product grid below add to cart

This topic has 6 replies, 2 voices, and was last updated 1 years, 9 months ago ago by ramvidal

  • Avatar: ramvidal
    ramvidal
    Participant
    March 2, 2023 at 12:07

    Hi , can help me for put a custom button in a product grid…is possible to add different buttons in each product??

    https://prnt.sc/ClTqivNGDqD0

    5 Answers
    Avatar: Rose Tyler
    Rose Tyler
    Support staff
    March 2, 2023 at 16:49

    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

    Avatar: ramvidal
    ramvidal
    Participant
    March 2, 2023 at 21:57

    Really the best service. The best theme. Thanks !

    I worked with Divi, oxygen, builder, betheme , woodmart and more

    Avatar: ramvidal
    ramvidal
    Participant
    March 2, 2023 at 22:45

    HOW CAN I GAIN A LITTLE SPACE PLEASE AND CHANGE THE BUTTON COLOR?
    https://prnt.sc/dz6OPDaQDyfY

    Avatar: Rose Tyler
    Rose Tyler
    Support staff
    March 3, 2023 at 11:09

    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

    Avatar: ramvidal
    ramvidal
    Participant
    March 4, 2023 at 23:49

    thanks

  • Viewing 6 results - 1 through 6 (of 6 total)

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

We're using our own and third-party cookies to improve your experience and our website. Keep on browsing to accept our cookie policy.