How can i trigger a complete relaculations of tax on the basket. ?
Im using UCommerce.Api.CatalogLibrary.ChangePriceGroup(priceGroup, true) to change the pricegroup.
But items already in the basket, maintains the tax from when first added to the basket.
I have tried TransactionLibrary.ExecuteBasketPipeline() , and read somewhere that the recalc tax is only done when new items are added to the basket. But is does not seam to have a effect on the items already in the basket.
I found that if I change the PriceGroup with the UCommerce.Api.CatalogLibrary.ChangePriceGroup(priceGroup, true), and delete all orderlines and re-add them again, the total tax is correct.
/// This is some dirty hacking shit.. !!
try
{
List<OrderLine> oldOrderlines = new List<OrderLine>();
oldOrderlines.AddRange(order.OrderLines);
foreach (OrderLine ol in oldOrderlines)
{
order.RemoveOrderLine(ol);
}
foreach (OrderLine ol in oldOrderlines)
{
TransactionLibrary.AddToBasket(ol.Quantity, ol.Sku, ol.VariantSku, addToExistingLine: false);
}
order.Save();
TransactionLibrary.ExecuteBasketPipeline();
}
catch (Exception ex)
{
Response.Write(ex.Message);
}
I really dont like the way of handling this. How can i trigger a calculate tax on all products in the basket ?
Hi Lasse, you're right, that is a bad behaviour :)
We are looking into this right now.
The best way forward would be to do it like this (on top of my head):
I think you would have to override the CatalogLibrary yourself, and when change pricegroup is called, then you could call the code underneath. See on docs here how to achieve it:
I know the answer has been marked as accepted, but I have a followup to this. I am using uCommerce 6.6.3 and as far as I can see in the source code, the api does call the TryUpdatePricingToMatchNewPriceGroup subroutine. But the price isn't updated when I call the function. I can see the PriceGroup is changed correctly and if I manipulate the basket by adding another product of the same type it recalculates the entire basket. Am I missing something?
ChangePriceGroup and recalculate tax
Hi there
How can i trigger a complete relaculations of tax on the basket. ?
Im using UCommerce.Api.CatalogLibrary.ChangePriceGroup(priceGroup, true) to change the pricegroup.
But items already in the basket, maintains the tax from when first added to the basket.
I have tried TransactionLibrary.ExecuteBasketPipeline() , and read somewhere that the recalc tax is only done when new items are added to the basket. But is does not seam to have a effect on the items already in the basket.
Can some one point me in the right direction.
Thank you in advance.
I found that if I change the PriceGroup with the UCommerce.Api.CatalogLibrary.ChangePriceGroup(priceGroup, true), and delete all orderlines and re-add them again, the total tax is correct.
I really dont like the way of handling this. How can i trigger a calculate tax on all products in the basket ?
Hi Lasse, you're right, that is a bad behaviour :)
We are looking into this right now.
The best way forward would be to do it like this (on top of my head):
I think you would have to override the CatalogLibrary yourself, and when change pricegroup is called, then you could call the code underneath. See on docs here how to achieve it:
http://docs.ucommerce.net/ucommerce/v6.6/extending-ucommerce/override-default-behavior-in-the-api.html (same method applies to CatalogLibrary).
Hope this helps
Best regards
Morten
I know the answer has been marked as accepted, but I have a followup to this. I am using uCommerce 6.6.3 and as far as I can see in the source code, the api does call the TryUpdatePricingToMatchNewPriceGroup subroutine. But the price isn't updated when I call the function. I can see the PriceGroup is changed correctly and if I manipulate the basket by adding another product of the same type it recalculates the entire basket. Am I missing something?
I am calling it like this:
UCommerce.Api.CatalogLibrary.ChangePriceGroup(priceGroup, true);
is working on a reply...