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.

  • Wouter 49 posts 76 karma points
    Dec 05, 2013 @ 14:33
    Wouter
    0

    Basket.PurchaseOrder.TaxTotal always zero

    Hi,

    I have a product catelog with multiple products. The catelog is linked on a price group of 21%. The show prices with VAT option is checked. The product(s) in question are linked to this catelog, and on the price tab, the prices are filled.

    On my cart-page, I use UCommerce.Runtime.SiteContext.Current.OrderContext.GetBasket(); to fetch the basket. But, when i use myBasket.PurchaseOrder.TaxTotal the total is always zero?

    I expect this to be the total VAT price, so: 21% of the product price in the active basket (when one product is added). Am I missing something has this never worked (this way)?

    Using: Umbraco v4.11.9 & uCommerce (Version=3.6.1.13149).

  • Morten Skjoldager 440 posts 1499 karma points
    Dec 05, 2013 @ 14:34
    Morten Skjoldager
    0

    How do you add products to the basket ? 

  • Wouter 49 posts 76 karma points
    Dec 05, 2013 @ 15:19
    Wouter
    0
    public string AddProduct(string productid, string quantity)
            {
                int nrofproducts = 0;
    
                try {
                    Basket basket = basket = SiteContext.Current.OrderContext.GetBasket();
    
                    if (basket != null) {
                        Product product = Product.All().Single(x => x.Sku == productid);
    
                        bool emptyPrices = product.PriceGroupPrices.Where(p => p.Price <= 0).Any();
                        if (!emptyPrices) {
                            PurchaseOrder order = basket.PurchaseOrder;
                            PriceGroup pricegroup = SiteContext.Current.CatalogContext.CurrentCatalog.PriceGroup;
                            order.AddProduct(pricegroup, product, Convert.ToInt16(quantity));
    
                            // Exec basket pipeline to update totals
                            UCommerce.Xslt.Library.ExecuteBasketPipeline();
                        }
    
                        foreach (OrderLine orderl in basket.PurchaseOrder.OrderLines) {
                            nrofproducts += orderl.Quantity;
                        }
                    } else {
                        ExceptionHelper.LogException("Unable to retrieve shopping basket from site-context!");
                    }
                }
                catch (Exception ex) {
                    ExceptionHelper.LogException(ex, "Error in webservice AddProduct");
                }
    
                return nrofproducts.ToString();
            }
  • Morten Skjoldager 440 posts 1499 karma points
    Dec 06, 2013 @ 10:01
    Morten Skjoldager
    0

    Hi Wouter, 

    You should use TransactionLibrary.AddToBasket. It will do all the magic for you. 

    You can easily just send ind a productId but you can also run on currentproduct if you do this on a product page:

    SiteContext.Current.CatalogContext.CurrentProduct 

    I might be missing some context though. Can you elaborate a little bit of what you're trying to achieve here? 

    At the end of the method you can return order.OrderLines.Sum(x => x.Quantity); which will give you the total amount rather that doing a foreach :) 

    Try refactoring the code and let me know if this solves the problem.

    Hope this helps. 

    Regards

    Morten

  • Wouter 49 posts 76 karma points
    Dec 09, 2013 @ 11:21
    Wouter
    0

    Thank you for your reply. TransactionLibrary.AddToBasket does not seem to work though, the numers are still zero. I guess I made a mistake somewhere else. I'll dig into it and if I find why I'll post it here.

  • Morten Skjoldager 440 posts 1499 karma points
    Dec 09, 2013 @ 12:59
    Morten Skjoldager
    0

    Did you comment out the pipeline methods in the basket pipeline configuration file?

    When you use SiteContext.Current.CatalogContext.CurrentPriceGroup; then what is the VAT rate on that? What is configured on the catalog related to pricegroup and VAT? 

Please Sign in or register to post replies

Write your reply to:

Draft