Adding selected product variants options to Orderline/checkout area
Hi
Sorry to bombard the support section with questions.
When a user selects their product variants from the products page, we have a series of 4 dropdowns, for instance:
Bundle = 10
Paper Type = Textured
Foil = Gold
How can I show these selected values in the basket?
Do I add them as bundles? Or am I missing how to access the selected variant option when in the basket?
Dp they need appending as properties to the OrderLine?
Id like the admin to see what they have selected and also the confirmation emails to follow suit, as well as the back office to see selected variant options for that particular product.
The requested service
'TeaCommerce.Umbraco.Configuration.Variants.Services.IVariantService`2[[System.Collections.Generic.IEnumerable`1[[Umbraco.Core.Models.IPublishedContent,
Umbraco.Core, Version=1.0.7180.24662, Culture=neutral, PublicKeyToken=null]], mscorlib, Version=4.0.0.0, Culture=neutral,
PublicKeyToken=b77a5c561934e089],[TeaCommerce.Umbraco.Configuration.Variants.Models.VariantPublishedContent,
TeaCommerce.Umbraco.Configuration, Version=3.3.7207.28303, Culture=neutral, PublicKeyToken=null]]'
has not been registered. To avoid this exception, either register a component to provide the service,
check for service registration using IsRegistered(), or use the ResolveOptional() method to resolve an optional dependency.
Seems to be when I call:
var variant = TC.GetVariant(1, productType, prod1split, true);
Any ideas on how to get the variant to go into the confirmation email and the order in the back office?
It might be easier to store the selected variant values in the order lines properties collection. That way you don’t have to keep looking them up. You can add properties as part of the AddOrUpdateOrderline API
Can I call an external class maybe and pass the IPubishedContent Product to it, let it do it's searching and return a list of the variant in a Dictionary String or something similar?
Is it just that it's inside the Macro Partial it's cant access the Variant?
It's just we have a non-triditional setup which has 2 product landing pages for the same product. Hard to explain here, but you view the product, select variants, then go to customize it, that's where the AddOrUpdateOrderline update happens.
Adding it to the properties at this stage would need a bit of refactoring time which we dont have, but if thats the only way i'll do it that way, was just looking for a quick win on it for now.
I think the issue is that the email templates are rendered in a thread where the TC DI container isn't available (ie, it's not a regular web request). I think the simplest option will be to store them on the orderline and read them from there.
I've gone with something like this, to get it out of the scope of the macrosScript.
edit-order.cshtml
if (productType.Any())
{
var variantList = TC_GetChosenVariantsHelper.VariantSelctor(productType.FirstOrDefault(), prodVarId);
if (variantList.Any())
{
foreach (var variantCombo in variantList)
{
<p>
@variantCombo.VariantName<br/>
<strong>
@variantCombo.VariantDetail
</strong>
</p>
}
}
}
Then in the helper did this:
public static List<SelectedVariants> VariantSelctor(IPublishedContent product, string variantId)
{
List<SelectedVariants> variantList = new List<SelectedVariants>();
var variant = TC.GetVariant(1, product, variantId, true);
if (variant != null)
{
foreach (var varcombo in variant.Combination)
{
SelectedVariants v = new SelectedVariants();
v.VariantDetail = varcombo.Name;
v.VariantName = varcombo.GroupName;
variantList.Add(v);
}
}
return variantList;
}
A little hacky I know, but needed something quick as it's going Live,
In the future, I think I'll add them to the properties, but this fixes it short term for me.
Adding selected product variants options to Orderline/checkout area
Hi
Sorry to bombard the support section with questions.
When a user selects their product variants from the products page, we have a series of 4 dropdowns, for instance:
How can I show these selected values in the basket?
Do I add them as bundles? Or am I missing how to access the selected variant option when in the basket?
Dp they need appending as properties to the OrderLine?
Id like the admin to see what they have selected and also the confirmation emails to follow suit, as well as the back office to see selected variant options for that particular product.
Ok, think I've figured it out :)
'Model' being the IPublishedContent Product itself.
I assume I can then loop over the variant combo that's been selected.
Ok hit another little snag, so in the basket, I can output the variant selected fine,
However in the:
I'm getting:
Seems to be when I call:
Any ideas on how to get the variant to go into the confirmation email and the order in the back office?
Hi Neil,
It might be easier to store the selected variant values in the order lines properties collection. That way you don’t have to keep looking them up. You can add properties as part of the AddOrUpdateOrderline API
https://docs.teacommerce.net/3.4.0/api/order-line/#addorupdateorderline
Once stored in the properties collection, it should then be available wherever the order line is available.
Ah Ok.
Can I call an external class maybe and pass the IPubishedContent Product to it, let it do it's searching and return a list of the variant in a Dictionary String or something similar?
Is it just that it's inside the Macro Partial it's cant access the Variant?
It's just we have a non-triditional setup which has 2 product landing pages for the same product. Hard to explain here, but you view the product, select variants, then go to customize it, that's where the AddOrUpdateOrderline update happens.
Adding it to the properties at this stage would need a bit of refactoring time which we dont have, but if thats the only way i'll do it that way, was just looking for a quick win on it for now.
Hi Neil,
I think the issue is that the email templates are rendered in a thread where the TC DI container isn't available (ie, it's not a regular web request). I think the simplest option will be to store them on the orderline and read them from there.
Matt
HI Matt
I've gone with something like this, to get it out of the scope of the macrosScript.
edit-order.cshtml
Then in the helper did this:
A little hacky I know, but needed something quick as it's going Live, In the future, I think I'll add them to the properties, but this fixes it short term for me.
Haha, nice!
No judgement here. Sometimes needs must.
Glad you got something working
Matt
is working on a reply...