Add a button next to add to cart

can I add a button next to add to cart in variable products that only appears when the add to cart appears?
this is what I am thinking maybe

    /* To move request a quote button in the loop */
    if( class_exists('YITH_Request_Quote_Premium')){
      remove_action( 'woocommerce_after_shop_loop_item', array( YITH_Request_Quote_Premium(), 'add_button_shop' ), 15 );
      add_action( 'woocommerce_after_add_to_cart_button', array( YITH_Request_Quote_Premium(), 'add_button_shop' ), 5 );
    }

Hello @wicara,

Thanks for writing in!

Your code is incomplete. It might need to be updated like this:

// Add a new button
// =============================================================================
function add_button_shop(){
  // your button code
}

function add_a_new_button() {
  // To move request a quote button in the loop */
  if( class_exists('YITH_Request_Quote_Premium')){
    remove_action( 'woocommerce_after_shop_loop_item', array( YITH_Request_Quote_Premium(), 'add_button_shop' ), 15 );
    add_action( 'woocommerce_after_add_to_cart_button', array( YITH_Request_Quote_Premium(), 'add_button_shop' ), 5 );
  }
}
add_action('init', 'add_a_new_button');
// =============================================================================

This is merely a guide and will not work out of the box.

Please note that custom coding is outside the scope of our support. Issues that might arise from the use of custom code and further enhancements should be directed to a third party developer.

Regards.

1 Like

This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.