Press Ctrl / CMD + C to copy this to your clipboard.
This post will be reported to the moderators as potential spam to be looked at
I've read the following threads but I still don't understand how to override the AddToBasket() method to use a different price.
I have a bunch of products, and all these products have variants. However, NONE of my products have a price. ALL the prices are associated to a variantSku. There are 1000s of variants, and all of them have different sizes. The price is associated to the size. There could be 1-to-many variants per product.
I created a custom field (Price) inside the variant. When adding to a basket,
TransactionLibrary.AddToBasket(quantity, variant.Sku, variant.VariantSku, true);
I need to be able to pass the price, OR I need to be able to tell the IPricingService to use the variant.variantSku to access the custom data field for price instead from within that variant, rather than the variant.Price
Threads that I've read through:
Here's a product and one of it's associated variants so you can get an idea of my issue.
Is there a reason you don't use the normal price on the variant?
(pressing the "dollar bill" icon for each variant?
The IPricingService is the correct way to override the default behaviour of price extraction, but im a little curious about way you can't use the build-in field here :)
I......did not know that was there haha. I'll look into that tonight when I get home. Thanks for pointing that out I would of never noticed it. Always thought the icons (similar to Umbraco) were meant for updating, deleting, etc. Never thought to look otherwise.
I'm glad it is there though, b/c I always thought it was weird for such a big application (uCommerce) not to allow prices for variants, and only for products, hence the reason why I created the custom field.
Thanks and I'll keep you updated.
Thanks for that tip, can't believe I missed that. One question I have is that there's (2) price groups in there (when I click on that "dollar sign", EUR and US Dollar. I do not need the EUR.
How do I assign this PriceGroupPrice with the appropriate properties to each variant?
Is the below code correct?
uCommerceVariant = new Product()
DisplayOnSite = true,
VariantSku = subVariant.sku,
Sku = uCommerceProduct.Sku,
Name = subVariant.itemDescription,
AllowOrdering = true,
ProductDefinition = uCommerceProduct.ProductDefinition
var groupPrice = PriceGroupPrice.Find(x => x.PriceGroup.Name.Equals("US Dollar")).FirstOrDefault();
groupPrice.Price = 44.44m;
groupPrice.Product = uCommerceVariant;
I've also noticed that in the variant's pricing, the "US Dollar" is stored w/ 4 decimal places. Is this correct?
Your code looks about right, although you need to create a new object if a PriceGroupPrice is not found.
The high precision for prices is used in case you're dealing with very low unit prices where high precision start to matter :)
Hope this helps.
Yup I got this working the other night, basically did what you said, if found, update, if not, create new.
Thanks for the replies guys!
is working on a reply...
Write your reply to:
Image will be uploaded when post is submitted