Hello. I wanted to inquire if anyone has a method for having two buttons on a product page. The one button is “add to cart” but the other button is “add sample” and they BOTH add to cart but one of them adds a sample product which is free. I have attached a screenshot of a sample. Any help would be appreciated.
Hope you are doing well.
‘add sample’ button click then can add other specific product
it will manage by other product id and variants id
Thanks
Greetings! A free sample item can be made as a product variant or a separate product, as hawkscode suggested. It would not be displayed anywhere, but when added to cart it would be free and with the designation “sample”. If you need help implementing this solution, I would be happy to help. 2 hours of work for free, that’s enough to solve this task.
Thank you so much @timkuts Yeah, I do see that I can add the “sample” product as a separate product and it’s basically at zero cost. However, when it comes to having TWO buttons (one for the paid product and one for the add sample product) on the product page, that’s where I’m lost.
There’s a lot of sub-decisions for something like this almost any way would require an advanced theme customization to work through actual needs and based on theme.
Such as if the sample button is in the product form you will may javascript to toggle the variant id sent to the cart if trying to use the form instead of a direct link.
For OS2.0 You may be able to pull this off just using cart permalinks in custom-liquid block/section outside of the product form.
Crude example for use with a custom-liquid block in a product context
To go to cart
[{{product.first_available_variant.title}}](https://{{shop.domain}}/cart/add?id={{product.first_available_variant.id}}&quantity=1
)
To have a link that goes to checkout
[{{product.first_available_variant.title}}](https://{{shop.domain}}/cart/{{product.first_available_variant.id}}:1
)
Styling left as exercise for the reader|implementer
An alternative is to do this on the /cart page by modifying the existing gift-wrap customization
https://help.shopify.com/en/manual/online-store/themes/themes-by-shopify/vintage-themes/customizing-vintage-themes/add-gift-wrap-option or modify it to work on product pages.
Thank you immensely Paul. And I love the sample. I’m going to give that a try and see what happens with those examples.
