skip to Main Content

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

3

Answers


  1. 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>'; 
    }
    
    Login or Signup to reply.
  2. 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.

    Login or Signup to reply.
  3. 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

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search