Shopify themes, liquid, logos, and UX
How can I add an extra 'add to cart button' to my product page. I would like it to go straight to cart not a link to the product page.
URL: Hygiadental.com
PW: Melek
Hi @jeffreym
Please create a Custom liquid section then add this code to Liquid.
<div>
<button type="button" class="button button--primary atc-second">Add to cart</button>
</div>
<script>
document.addEventListener('DOMContentLoaded', function() {
var atcSecondButton = document.querySelector('.atc-second');
if (atcSecondButton) {
atcSecondButton.addEventListener('click', function() {
var productFormSubmitButton = document.querySelector('.product-form__submit');
if (productFormSubmitButton) {
productFormSubmitButton.click();
}
});
}
});
</script>
- Helpful? Like and Accept solution! or Buy me coffee
- Ryviu - Reviews & QA app: Collect product reviews, import reviews from AliExpress, Amazon, Etsy, Walmart, Shopee, Dhgate and CSV.
- Lookfy Gallery: Lookbook Image: Easy and fast to create Photo Gallery, Lookbook, Shop The Look.
- Ryviu: Aliexpress Reviews - AliExpress Reviews Importer, one-click import aliexpress reviews, export reviews to CSV file.
- Reelfy‑Shoppable Videos+Reels: Create shoppable videos to engage customers and drive more sales.
- Enjoy 1 month of Shopify for $1. Sign up now.
Hi thank you, This has added an add to cart button though I would also like it to activate the add to cart function. What the link is doing is taking me back to the top of the product page.
You can do that by adding this value to link of button
#MainContent
- Helpful? Like and Accept solution! or Buy me coffee
- Ryviu - Reviews & QA app: Collect product reviews, import reviews from AliExpress, Amazon, Etsy, Walmart, Shopee, Dhgate and CSV.
- Lookfy Gallery: Lookbook Image: Easy and fast to create Photo Gallery, Lookbook, Shop The Look.
- Ryviu: Aliexpress Reviews - AliExpress Reviews Importer, one-click import aliexpress reviews, export reviews to CSV file.
- Reelfy‑Shoppable Videos+Reels: Create shoppable videos to engage customers and drive more sales.
- Enjoy 1 month of Shopify for $1. Sign up now.
can you put it in for me as supposed to be? Nothing is happening on my end
Sorry, I did not explain clearly. I mean, please add the link I mentioned to button you got on your product page
- Helpful? Like and Accept solution! or Buy me coffee
- Ryviu - Reviews & QA app: Collect product reviews, import reviews from AliExpress, Amazon, Etsy, Walmart, Shopee, Dhgate and CSV.
- Lookfy Gallery: Lookbook Image: Easy and fast to create Photo Gallery, Lookbook, Shop The Look.
- Ryviu: Aliexpress Reviews - AliExpress Reviews Importer, one-click import aliexpress reviews, export reviews to CSV file.
- Reelfy‑Shoppable Videos+Reels: Create shoppable videos to engage customers and drive more sales.
- Enjoy 1 month of Shopify for $1. Sign up now.
Hello @jeffreym
You can add code by following these steps
1. Go to Online Store -> Theme -> Open Customize.
2. Open your Product template.
3. Add new section from custom.liquid
4. Paste the below code from custom.liquid section
<div class="center">
<button id="ProductSubmitButton-template--17256408449124__main" type="submit" name="add" form="product-form-template--17256408449124__main" class="button button--primary" aria-haspopup="dialog">
<span>Add to cart</span>
<div class="loading__spinner hidden">
<svg aria-hidden="true" focusable="false" class="spinner" viewBox="0 0 66 66" xmlns="http://www.w3.org/2000/svg">
<circle class="path" fill="none" stroke-width="6" cx="33" cy="33" r="30"></circle>
</svg>
</div>
</button>
</duv>
Was my reply helpful? Click Like to let me know!
Was your question answered? Mark it as an Accepted Solution.
Hi thankyou, This has added an add to cart button though I would also like it to activate the add to cart function. What the link is doing is taking me back to the top of the product page.
Starting a B2B store is a big undertaking that requires careful planning and execution. W...
By JasonH Sep 23, 2024By investing 30 minutes of your time, you can unlock the potential for increased sales,...
By Jacqui Sep 11, 2024We appreciate the diverse ways you participate in and engage with the Shopify Communi...
By JasonH Sep 9, 2024