Add product to basket with NULL price - use variant price instead
I've read the following threads but I still don't understand how to override the AddToBasket() method to use a different price.
Overview:
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,
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
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 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?
Add product to basket with NULL price - use variant price instead
I've read the following threads but I still don't understand how to override the
AddToBasket()
method to use a different price.Overview:
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,
I need to be able to pass the price, OR I need to be able to tell the
IPricingService
to use thevariant.variantSku
to access the custom data field forprice
instead from within that variant, rather than thevariant.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.
Hi Rob
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.
Nickolaj -
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?
I've also noticed that in the variant's pricing, the "US Dollar" is stored w/ 4 decimal places. Is this correct?
Hi Rob,
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.
Søren -
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...