Page 1 of 1
Source Code Question
Posted: Tue Mar 13, 2012 4:41 pm
by jasonhendee
Why was there not a "_CalculatedCogs" variable added to the CommerceBuilder.Products.ProductVariant.cs class?
It's easy enough to simply add and calculate with the rest of them, but with the other "_Calculated..." variables, it just seems like this one may have simply been overlooked?
Any fellow source code holders have any thoughts on this one? I don't see how I can break anything by adding it, and my initial testing works as expected.
Re: Source Code Question
Posted: Wed Mar 14, 2012 6:28 am
by jmestep
I haven't looked at it, but if it is a calculated field based on other variables, it wouldn't be a good idea to have it in the source code because then it couldn't be customized later. For example, on shipping method rates there is something calculated in the source code (don't remember what) and we had a client who wanted one variant of a product to be available for free shipping, but the other variants to not be available. So I tried to take the weight off the one variant thru checkout and couldn't because of whatever was calculated within the source code and sent across to the shipping provider.
Re: Source Code Question
Posted: Wed Mar 14, 2012 11:23 am
by jasonhendee
The SQL table [ac_OptionChoices] contains fields called [PriceModifier], [CogsModifier], [WeightModifier] & [SkuModifier]. Of these four very relevant "modifier" fields, only the COGS is not calculated in the ProductVariant class, based on a product's currently selected options (in the CalculateVariant() method). So when a product with options - that each have their own COGS defined - gets added to the basket and finalized in an order, the true COGS for that line item does not get calculated.
So I was simply proposing that this variable/field was mistakenly left out of said class. When would you not want to properly calculate the true COGS if it's defined per option in the database? And I guess due to the nature of this field, and the already-present iteration through a product's currently selected options in the ProductVariant class, I don't know where else such a customization would be made to make sure it's properly encapsulated.