I want to add an add to cart button to my complementary products in my Ride theme.
Hi @cleankits
Yes. In the Ride theme if by âcomplementary productsâ you mean the Complementary products / Product recommendations section on the product page, you can add an Add to cart button to each recommended product.
I can guide you through the exact Liquid changes. The cleanest approach is usually:
-
Find the complementary-products section/snippet.
-
Identify the product card used for each recommended product.
-
Add a small form using the productâs **
-
first available variant.
-
Submit it with Shopifyâs
/cart/addendpoint. -
Optionally make it AJAX so the product is added without leaving the product page.
If you want, send me the code of your complementary-products section/snippet (or upload the relevant Ride theme file), and Iâll tell you exactly where to add the Add to Cart button and give you the ready-to-paste code.
You should not need custom Liquid for this on Ride. Complementary products is a block on the product information section. In the theme editor, open the product template, click Complementary products, and turn on Enable quick add button.
If the complementary item has variants, the button shows Choose options instead of Add to cart. The products themselves are picked in Search & Discovery.
Yes, you can add an Add to Cart button to the complementary products in the Ride theme. Youâll need to modify the product card/section and submit the selected variant to Shopifyâs cart endpoint. If you share the relevant Liquid code, I can point out the exact change.
find the product.liquid or product recommendation theme file
insert this code
{%- form 'product', block_product -%}<button type="submit" class="button complementary-atc-btn" {% if block_product.selected_or_first_available_variant.available == false %}disabled{% endif %}>{% if block_product.selected_or_first_available_variant.available %}Add to cart{% else %}Sold out{% endif %}{%- endform -%}
you will also need to add this js
document.addEventListener('submit', function (e) {
const form = e.target.closest('product-form form');
if (!form || !form.closest('.complementary-products, [data-complementary]')) return;
e.preventDefault();
const formData = new FormData(form);
fetch('/cart/add.js', {
method: 'POST',
body: formData,
headers: { 'Accept': 'application/json' }
})
.then((res) => res.json())
.then((data) => {
if (data.status) {
alert(data.description || 'Could not add to cart');
return;
}
document.dispatchEvent(new CustomEvent('cart:refresh'));
})
.catch((err) => console.error(err));
});
Recommended method is that in customizer you will definately find an option to add
cart button
share store url, so that will be able to help you
I enabled quick add but there is no change at all
Hey! A few things worth checking since toggling âquick addâ alone sometimes doesnât visually change anything :
- Make sure you clicked Save in the theme editor and then checked your live/published site (not just the editor preview) - sometimes changes donât show up until you save and refresh.
- The complementary products block usually comes from Shopifyâs Search & Discovery app (added as an app block on your product page), and it has its own separate âshow quick addâ toggle inside that blockâs settings - this is different from any general quick-add setting in your theme. Double check you toggled it on that specific block.
- If your products have multiple variants (size/color etc.), the button might show âSelect optionsâ instead of a direct âAdd to cartâ - thatâs expected behavior, not a bug.
If none of that helps, try a hard refresh (Ctrl+Shift+R) in case itâs just a caching issue.
Hi @cleankits, following up on the quick add toggle not doing anything, thatâs usually not a bug, it just means the block has nothing to show yet.
Two things worth checking before touching any code:
- Have you actually picked complementary products for this specific product? Thatâs separate from the theme editor. Go to Products, open this product, click the ⌠(More actions) menu, then Edit product recommendations, and scroll to Complementary products. If that list is empty, the block on the storefront has nothing to display no matter what you toggle in the customizer.
- After turning on quick add, did you click Save in the theme editor, and are you checking the published live store rather than just the preview? Sometimes it looks unchanged simply because of caching or an unsaved draft.
If youâve already got products picked there and itâs still not showing the button, let me know, and we can look at whether this specific Ride theme version even has that setting. Some older versions donât, in which case it needs a small code fix instead.
Tim from Sonder Sites in Melbourne.
The Ride quick-add toggle only paints a button if Search and Discovery already has complementary products assigned on that exact product. Theme editor settings will not invent the list. Open the product, More actions, Edit product recommendations, and check Complementary products. If that list is empty, the block has nothing to attach a button to.
If products are assigned and the button still does not show after a save and a hard refresh on the published theme, you are likely on a Ride version where that setting does not exist, or the complementary block is the Search and Discovery app block rather than the theme block. Those are two different toggles.
Do not paste a custom form into the section until those two checks fail. A hand-rolled /cart/add form on complementary cards often fights Rideâs existing product form and you end up with the wrong variant in the cart.
If you share the Ride version number and a product URL that already has complementary items assigned, I can tell you which of those two cases you are in. Happy to help.