Hi.
I need to create a product template where the buyer can select several options (main product) and add 2-3 accessories (one is required).
After press the add to cart button and send all these products to the cart. Applications are not interesting. I would like to implement all this through the template code.
Should this be done via ajax? Has anyone done something similar - please let me know.
I also need to change the price in the template (total) when choosing accessories. An interesting task. I would be grateful for tips on how best to do this.
This is an advanced customization whose details will very wildly between themes.
See the cart ajax api here:
https://shopify.dev/docs/themes/ajax-api/reference/cart
This can also be done using cart permalinks
https://shopify.dev/apps/channels/cart-permalinks/cart-permalinks
Main approach is to first learn to build the url manually to add separate products to a cart.
Then move to JavaScript to start serializing forms to the cart endpoints.