usman kashif
usman kashif

Reputation: 1

add custom button on single product page for woocommerce

I have spent the majority of the day trying to figure out how to adjust the single product page using woocommerce.

I would like to add a custom button next to the "Add to cart" button that would be a custom link that says "More Info". I am working on an shop website where there are numerous components to an products, so I want there to be an option that says "More Info" so they can go ahead check detail on vandor website. (I will have custom fields for each). The More Info button won't be on all products, and the link will be different for each. I don't think this is the best way to do it, but don't have another solution right now. I use elemontor Pro to create product page i can add botton in their but how i will add my botton custom link when i add new product Please help me to solve it

Upvotes: 0

Views: 2800

Answers (4)

Ajeet Vadheeya
Ajeet Vadheeya

Reputation: 1

Place this code in your active themes functions.php file

add_action('woocommerce_product_single_add_to_cart_text', 'product_single_page_button_text_change'); function product_single_page_button_text_change(){ echo 'Add To Bucket'; }

Upvotes: 0

Firat
Firat

Reputation: 13

If you use the Elementor pro, you can add a button for a single product page. Also, you said you have custom fields for each, you can add dynamic URLs.

screenshot

Upvotes: 0

Aniket Panchal
Aniket Panchal

Reputation: 166

You can use the Woocommerce hook woocommerce_after_add_to_cart_button to add any custom HTML or button besides the "Add to Cart" button.

Put below code to the function.php file which is located in your child theme directory.

function add_content_after_addtocart() {
    echo '<a href="PUT_VENDOR_WEBSITE_LINK_HERE">More Info</a>';
}
add_action( 'woocommerce_after_add_to_cart_button', 'add_content_after_addtocart' );

Note: If child theme is not exists, please create it by taking some help from the theme documentation. It will prevent to loss data while you update with the parent theme.

Upvotes: 1

Shakeel Ahmad
Shakeel Ahmad

Reputation: 349

You can use this hook in your function.php of active theme

add_action( 'woocommerce_after_add_to_cart_button', 'details_custom_button', 10 );
function details_custom_button() {
  echo '<a href="#link-here"><button type="button" class="button back-woo-button">Name Here </button></a>'; 
}

Upvotes: 1

Related Questions