I am getting a price cant be null error because price is not set for product. but I need to be able to have products where prices are not set as they will be comming from an external system.
I tried the folloing check before adding to basket
The problem is though I will not be setting the price from within ucommerce I realy wanted to have the option to leave the price blank and still be able to add to cart.
I was trying to set a defaul;t value of 1 above because it seems that you can not add a product to the basket without a price.
this is my first time using ucommerce so some basic questions. If I override this class where would I put the code. also where does this get called is it automatically from within TransactionLibrary.AddToBasket. I would need to return 0 if no price added to product. if you could point me in the right direction please
You implement the IPricingService, and write your own price fetching logic. You then register the custom implementation in the components.config.
You can find an example here:
Link
adding product to basket error
when adding a product to basket
TransactionLibrary.AddToBasket(1, product.Sku);
TransactionLibrary.ExecuteBasketPipeline();
I am getting a price cant be null error because price is not set for product. but I need to be able to have products where prices are not set as they will be comming from an external system.
I tried the folloing check before adding to basket
PriceCalculation price = CatalogLibrary.CalculatePrice(product);
if (price.YourPrice == null)
{
var priceGroup = PriceGroup.SingleOrDefault(x => x.Name == "EUR 15 pct");
var productPrice = new PriceGroupPrice
{
Product = product,
PriceGroup = priceGroup,
Price = 1m
};
productPrice.Save();
//product = Product.All().Single(x => x.Sku == sku);
}
TransactionLibrary.AddToBasket(1, product.Sku);
TransactionLibrary.ExecuteBasketPipeline();
this does indeed set the price however the page still crashes. but the nexttime you try to add the product it works ok.
even tried reloading product after adding price (commented out above) but still no joy.
any sugestions.
If i understand the problem correctly, you need to integrate the external pricing service into uCommerce, by overriding the IPricingService: http://www.ucommerce.net/docs/html/T_UCommerce_Catalog_IPricingService.htm
The problem is though I will not be setting the price from within ucommerce I realy wanted to have the option to leave the price blank and still be able to add to cart.
I was trying to set a defaul;t value of 1 above because it seems that you can not add a product to the basket without a price.
Yeah, but uCommerce uses the IPricingService to fetch the price, so if you override the default pricing engine, that would fix the problem :)
this is my first time using ucommerce so some basic questions. If I override this class where would I put the code. also where does this get called is it automatically from within TransactionLibrary.AddToBasket. I would need to return 0 if no price added to product. if you could point me in the right direction please
You implement the IPricingService, and write your own price fetching logic. You then register the custom implementation in the components.config. You can find an example here: Link
thanks
is working on a reply...