Trying to make cross-sells and upsells addable to the cart while viewing the cart.
Documentation and other existing themes I've found only show how to do so while on a product page, using shop:onAddToCart.
Having initially tried that, I was finding that trying to reload the cart-page partial afterwards would result in nothing at all being shown in the cart until the user reloads the page. I contacted support and received this response:
Hey Marc,
I changed the data-ajax-handler from shop:onAddToCart to shop:cart.
Reasons for this:
It also handles upsell card adds, given the upsellId and productId parameters.
It yields cart variables, which are rendered in the temlaplates you specified.
shop:onAddToCart does not offer these variables in rendering the requested templates.
This should now work - please test to confirm, and let me know if you have any questions.Thanks,Andy
--
This does indeed work, but at the time I was only trying to provide upsells on the cart page. Now that I'm also trying to provide cross-sells, I'm finding that sending the request with shop:cart doesn't seem to work on either the product page OR the cart page. The product simply isn't added to the cart.
Trying to make cross-sells and upsells addable to the cart while viewing the cart.
Documentation and other existing themes I've found only show how to do so while on a product page, using shop:onAddToCart.
Having initially tried that, I was finding that trying to reload the cart-page partial afterwards would result in nothing at all being shown in the cart until the user reloads the page. I contacted support and received this response:
This does indeed work, but at the time I was only trying to provide upsells on the cart page. Now that I'm also trying to provide cross-sells, I'm finding that sending the request with shop:cart doesn't seem to work on either the product page OR the cart page. The product simply isn't added to the cart.
Suggestions?