How can I include selected variants and offer details in my cart?

I would like to add to the cart the information of the offer chosen by the user. They have the possibility to make 2 choices of variants.

And I would like to send the information such as the price = ‘secondOfferAmount,’ the title = ‘STANDARD OFFER,’ and the variants they will choose

{% when ‘select_variants’ %}

{% assign secondOfferAmount = secondBase | divided_by: 100 %}

STANDARD OFFER

{{ secondOffer }} {{ shop.currency }} {{ secondOfferAmount }} {{ shop.currency }}

Box of surgical masks (x1)

{%- for option in product.options_with_values -%} {%- assign option_name = 'option' | append: forloop.index -%} {%- if product.variants[0][option_name] -%}
{{ option.name }}
{%- endif -%} {%- endfor -%}
{%- for option in product.options_with_values -%} {%- assign option_name = 'option' | append: forloop.index -%} {%- if product.variants[0][option_name] -%}
{{ option.name }}
{%- endif -%} {%- endfor -%}

Reduction de {{ block.settings.percentage_second }}%

How to proceed to add the titles and the selected variants?

1 Like

can you provide link to your store?

1 Like

Okay, here is the link https://bankfarjunk.myshopify.com/, and it’s on the product page, but I’m still in development mode

can you also provide the password?

1 Like

okay here is the password
rautri

okay here is the password
rautri

@Pusko do you mean you want to add product upsells to your themes cart?

This will vary wildly by theme especially matching the design , and also trying to let the customer pick the options on the cart if there’s more than 1 option.

From your wall of code it looks like you’ve forgotten to add the variant.id as a hidden input so it’s submitted to the cart when the add to cart button is press.

If you need this customization then contact me directly by mail for services.
Please always provide context and clear details of what’s need and examples: store url, theme name, post url(s) , or any further detail.
Contact Info in signature.

2 Likes

Hi @Pusko ,

It looks like you are statically adding the three option? Are these three variants? Shopify requires variant id to add products to the cart. Also I dont see any JS that can perform the Add to cart functinality.

As this is a custom functionality, this will require custom coding.

Actually, the choice is up to the user. They can choose the option with just one variant or the second offer with the possibility of choosing 2 variants, or even the third offer with the possibility of choosing 3 variants.

I’ve just updated the code where I added the ‘Add to Cart’ button to the second offer. You can see it now

Do you want me to write to you using this email, paull.newton+shopifyforum@gmail.com?

You product https://bankfarjunk.myshopify.com/products/produit-2 only has one default variant. And it looks like you are trying to make this product have three variants? For this you must first add variants to your product.

1 Like

Check this links https://bankfarjunk.myshopify.com/products/sauvage

there are many variant

Actually, this product only has a default variant. If u want to discuss about variants in a detail manner, you can contact personally.

Contact Info in signature.

Replace produit-2 to sauvage or change the link to https://bankfarjunk.myshopify.com/products/sauvage

this product has many variantq

This product does have multiple variants. also the customer can purchase any variant they want by selecting it.