Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


These support forums are now closed for new topics and comments.
Please head on over to http://eureka.ucommerce.net/ for support.

  • lj 81 posts 425 karma points
    Aug 22, 2013 @ 17:11
    lj
    0

    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.

     

  • Nickolaj Lundgreen 233 posts 1132 karma points
    Aug 22, 2013 @ 18:39
    Nickolaj Lundgreen
    0

    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

  • lj 81 posts 425 karma points
    Aug 23, 2013 @ 10:02
    lj
    0

    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.

  • Nickolaj Lundgreen 233 posts 1132 karma points
    Aug 23, 2013 @ 10:06
    Nickolaj Lundgreen
    0

    Yeah, but uCommerce uses the IPricingService to fetch the price, so if you override the default pricing engine, that would fix the problem :)

  • lj 81 posts 425 karma points
    Aug 23, 2013 @ 10:22
    lj
    0

    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

  • Nickolaj Lundgreen 233 posts 1132 karma points
    Aug 23, 2013 @ 10:28
    Nickolaj Lundgreen
    100

    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

  • lj 81 posts 425 karma points
    Aug 23, 2013 @ 10:30
    lj
    0

    thanks

Please Sign in or register to post replies

Write your reply to:

Draft