'Adding button after add to cart button WooCommerce
I am trying to add a button to my product pages that when clicked it will scroll down to the description tab. I looked at another topic and grabbed the code below, but it is just taking me back to the same page instead of going down to the tab.
add_action('woocommerce_after_add_to_cart_button','cmk_additional_button');
function cmk_additional_button() {
$productID = get_the_ID();
$yourCustomLinkValue = get_post_meta($productID,'#tab-decription',true);
echo '<a href="'.$yourCustomLinkValue.'">Read More About Item</a>';
}
The description tab does have the id of #tab-description
I also tied this code, but all it does is refresh the page.
add_action('woocommerce_after_add_to_cart_button','cmk_additional_button');
function cmk_additional_button() {
echo '<a href="#tab-description"><button type="submit" class="button alt">Read More About This Item</button></a>';
}
Solution 1:[1]
I was able to accomplish what I needed by adding the code directly to the add-to-cart file.
<a href="#tab-description"><button type="submit" class="button alt">Read More About This Item</button></a>
plugins/woocommerce/templates/single-product/add-to-cart/simple.php
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | WebbieWorks |
