I have setup complex variants and have the product being added to the cart, however, my product is the parent product to the variant for example:
Blue Glove x 1
What I want is the complex variant size to be shown in the cart for example:
Blue Glove x1
Glove Size: M
How do I go about getting the product variant reference so that i know if I add a Large or Medium they will both show up in the cart?
I guess i am a bit confused to if this should be the case or if I should simply be showing the product attribute in the cart and I actually have the correct product added to the cart?
Is the relationship such that a product and complex variant both have a product reference OR such that the product has a product reference and the complex variant is simply an attribute value that is used more for a packager to reference?
Essentially when adding to the cart, you'll want to call the AddProduct method that takes a productReference and a productVariantReference passing in the node keys for each of these.
When using the variants property editor, each unique combination of your product attributes is a "variant" and each will be given a key. You can pass this into the productVariantReference parameter and the parent product nodes key as the productReference.
Thanks for the reply, I may have been a little quick in my ticket.
This is using the Variant Editor. I managed to get this working modeling my solution after the Vendr demo store.
I used a combination of the AddProduct() prior to that though I used FindByAttributes() to get the proper variant and then binded the correct information to a model and proceeded from there.
Adding Complex Variants to Cart
Matt,
First thanks for your effort.
I have setup complex variants and have the product being added to the cart, however, my product is the parent product to the variant for example:
Blue Glove x 1
What I want is the complex variant size to be shown in the cart for example:
Blue Glove x1 Glove Size: M
How do I go about getting the product variant reference so that i know if I add a Large or Medium they will both show up in the cart?
I guess i am a bit confused to if this should be the case or if I should simply be showing the product attribute in the cart and I actually have the correct product added to the cart?
Is the relationship such that a product and complex variant both have a product reference OR such that the product has a product reference and the complex variant is simply an attribute value that is used more for a packager to reference?
I hope that makes sense to you?
Hi Kyle,
Is this using the variants property editor?
Essentially when adding to the cart, you'll want to call the
AddProduct
method that takes aproductReference
and aproductVariantReference
passing in the node keys for each of these.When using the variants property editor, each unique combination of your product attributes is a "variant" and each will be given a key. You can pass this into the
productVariantReference
parameter and the parent product nodes key as theproductReference
.You can see here in the demo store how it uses javascript to load in the variant based on the attribute dropdown selection and then stores the key in a hidden field https://github.com/vendrhub/vendr-demo-store/blob/v1/main/src/Vendr.DemoStore.Web/Views/ProductPage.cshtml#L60 this is then used when calling
AddProduct
on the current order https://github.com/vendrhub/vendr-demo-store/blob/v1/main/src/Vendr.DemoStore/Web/Controllers/CartSurfaceController.cs#L46Hope this helps
Matt
Matt,
Thanks for the reply, I may have been a little quick in my ticket.
This is using the Variant Editor. I managed to get this working modeling my solution after the Vendr demo store.
I used a combination of the
AddProduct()
prior to that though I usedFindByAttributes()
to get the proper variant and then binded the correct information to a model and proceeded from there.Thanks Matt
is working on a reply...