Error on adding products to cart with specific active discount
Hi
I have a client with an issue. They've created a discount code that triggers a very long discount with a lot of product rules, but it seems that every time the discount code is activated, the following error is shown when something is added to the cart.
c__DisplayClass9_0.b__0(IOrderLineRule rule) at System.Linq.Enumerable.d__17`2.MoveNext() at System.Linq.Enumerable.d__64`1.MoveNext() at System.Collections.Generic.List`1.InsertRange(Int32 index, IEnumerable`1 collection) at TeaCommerce.Api.Marketing.Models.Rules.RuleGroup.IsFulfilledBy(Order order, IEnumerable`1 previouslyFulfilledOrderLines) at TeaCommerce.Api.Marketing.Services.DiscountService.<>c__DisplayClass7_1.b__1(RuleGroup ruleGroup) at System.Linq.Enumerable.WhereSelectListIterator`2.MoveNext() at TeaCommerce.Api.Marketing.Services.DiscountService.ApplyDiscounts(Order order) at TeaCommerce.Api.Models.Order.Save() at TeaCommerce.Api.Web.TeaCommerceHelper.AddOrUpdateOrderLine(Int64 storeId, String productIdentifier, Nullable`1 quantity, IDictionary`2 properties, Boolean overwriteQuantity, String bundleIdentifier, String parentBundleIdentifier) at TeaCommerce.Api.Web.FormPostHandler.AddOrUpdateOrderLine(Int64 storeId, IDictionary`2 formFields, IDictionary`2 settings) at TeaCommerce.Api.Web.FormPostHandler.FormPost() at TeaCommerce.Umbraco.Web.RestExtensions.FormPost()]]>
I can't really understand much from the error above.
Hmm, could you look in your error log to see if there is more detail for this error? This looks to be the call stack, but it's not really saying what the exception is.
System.ArgumentException: The product doesn't have a store id associated with it - remember to add the Tea Commerce store picker to your Umbraco content tree
at TeaCommerce.Umbraco.Configuration.InformationExtractors.PublishedContentProductInformationExtractor.GetStoreId(IPublishedContent product, VariantPublishedContent variant)
at TeaCommerce.Umbraco.Configuration.InformationExtractors.PublishedContentProductInformationExtractor.GetSku(String productIdentifier)
at TeaCommerce.Api.Services.ProductService.GetSku(String productIdentifier)
at TeaCommerce.Umbraco.Configuration.Marketing.Models.ProductUtils.OrderLinesThatMatchProductOrProductCategory(IProductService productService, Int32 nodeId, IEnumerable`1 orderLines)
at TeaCommerce.Umbraco.Configuration.Marketing.Models.Rules.ProductRule.IsFulfilledBy(Order order, IEnumerable`1 previouslyFulfilledOrderLines)
at TeaCommerce.Api.Marketing.Models.Rules.RuleGroup.<>c__DisplayClass9_0.<IsFulfilledBy>b__0(IOrderLineRule rule)
at System.Linq.Enumerable.<SelectManyIterator>d__17`2.MoveNext()
at System.Linq.Enumerable.<DistinctIterator>d__64`1.MoveNext()
at System.Collections.Generic.List`1.InsertRange(Int32 index, IEnumerable`1 collection)
at TeaCommerce.Api.Marketing.Models.Rules.RuleGroup.IsFulfilledBy(Order order, IEnumerable`1 previouslyFulfilledOrderLines)
at TeaCommerce.Api.Marketing.Services.DiscountService.<>c__DisplayClass7_1.<ApplyDiscounts>b__1(RuleGroup ruleGroup)
at System.Linq.Enumerable.WhereSelectListIterator`2.MoveNext()
at TeaCommerce.Api.Marketing.Services.DiscountService.ApplyDiscounts(Order order)
at TeaCommerce.Api.Models.Order.Save()
at TeaCommerce.Api.Web.TeaCommerceHelper.AddOrUpdateOrderLine(Int64 storeId, String productIdentifier, Nullable`1 quantity, IDictionary`2 properties, Boolean overwriteQuantity, String bundleIdentifier, String parentBundleIdentifier)
at TeaCommerce.Api.Web.FormPostHandler.AddOrUpdateOrderLine(Int64 storeId, IDictionary`2 formFields, IDictionary`2 settings)
at TeaCommerce.Api.Web.FormPostHandler.FormPost()
2019-02-19 22:23:18,873 [P4672/D2/T129] ERROR TeaCommerce.Api.Web.FormPostHandler - FormPost error
--- Form data:
-- AddOrUpdateOrderLine = "productIdentifier, quantity"
-- returnUrl = "/apple-watch/apple-watch-series-4-gps-44mm-gold-aluminium-case-with-pink-sand-sport-band/?action=add_cart"
-- storeId = "1"
-- productIdentifier = "2478"
-- quantity = "1"
Hmm, do any of your products live outside of a the main site structure that has the store picker on it? Or could this rule be linked to a product that might have been trashed?
Hmm, although, if it's looking up variants, I would have thought that would have been for items that are in your basket so shouldn't be trashed 🤔
Ultimately though it seems to think either a product or a variant is sat outside of a node structure where there is no Ancestor with a store picker on it.
Alright. This website is not using product variants at all, but I'll try to look into it further and try to remove the product rules with removed products.
Side question: I could heavily simplify these discount rules, if only there was a way to include a whole product category, but exclude X products from this category. Is that possible?
It might not be variant related, sorry I used the wrong terminology. Ultimately though the product information extractor is trying to extract information from a product OR variant and the node it is trying to get the information from, doesn't appear to be within a store.
Error on adding products to cart with specific active discount
Hi
I have a client with an issue. They've created a discount code that triggers a very long discount with a lot of product rules, but it seems that every time the discount code is activated, the following error is shown when something is added to the cart.
I can't really understand much from the error above.
Hi MIkkel,
Hmm, could you look in your error log to see if there is more detail for this error? This looks to be the call stack, but it's not really saying what the exception is.
Matt
Hi Matt
This seems to be the exception :)
Hmm, do any of your products live outside of a the main site structure that has the store picker on it? Or could this rule be linked to a product that might have been trashed?
None of the products live outside the main structure, but it's very possible that one or more of the rules have products that have been trashed :-/
Hmm, although, if it's looking up variants, I would have thought that would have been for items that are in your basket so shouldn't be trashed 🤔
Ultimately though it seems to think either a product or a variant is sat outside of a node structure where there is no Ancestor with a store picker on it.
Alright. This website is not using product variants at all, but I'll try to look into it further and try to remove the product rules with removed products.
Side question: I could heavily simplify these discount rules, if only there was a way to include a whole product category, but exclude X products from this category. Is that possible?
Hi Mikkel,
It might not be variant related, sorry I used the wrong terminology. Ultimately though the product information extractor is trying to extract information from a product OR variant and the node it is trying to get the information from, doesn't appear to be within a store.
Regarding your other question, I don't think rules system is capable of doing that at the moment. It is possible for you to write your own rule if you wanted to try and create one. Take a look at the Rules here to see how it's done https://github.com/TeaCommerce/Tea-Commerce-for-Umbraco/tree/master/Source/TeaCommerce.Umbraco.Application/Marketing/Rules
is working on a reply...