Portal Engine Questions on portal engine and web parts.
Version 6.x > Portal Engine > URGENT: Do you store Tax value per item in OrderItemInfo? How to get it? View modes: 
User avatar
Member
Member
knottano-gmail - 5/7/2012 4:15:48 AM
   
URGENT: Do you store Tax value per item in OrderItemInfo? How to get it?
Hi,

I am getting OrderItemInfo object but I cannot get the Tax value from this object.

In the CMS Desk > E-commerce > Orders > Order Detail > Items ... you show the item with Tax correctly but when I retrieve it by code. I don't know how to get the Tax value.

Could you please tell me how to retrieve the Tax value in detail for me?

Thank you very much,
Knott

User avatar
Kentico Support
Kentico Support
kentico_zdenekc - 5/10/2012 3:50:03 AM
   
RE:URGENT: Do you store Tax value per item in OrderItemInfo? How to get it?
Hi,

unfortunately, the Tax values are not stored within OrderItem(Info), so you cannot get the value directly from it.
You could first obtain the ShoppingCart object based on the Order, using

ShoppingCartInfoProvider.GetShoppingCartInfoFromOrder(int orderId)

then you could get the tax of each ShoppingCartItem using properties UnitTotalTax or UnitTotalTaxInMainCurrency


There is also an option to add a custom field to the OrderItem system table and save the tax value during SetOrderItemInfo execution (in the customized provider).
Maybe even easiest approach would be to add the same custom field to both OrderItem and ShoppingCartItem tables.
In that case, the customization of the ShoppingCartItemInfoProvider would be quite easy, you would just copy the value of the UnitTotalTax to the custom field (using item.SetValue()) in the overriden CalculateUnitTotalTax method, before you just return the value...
When the ShoppingCartItem is stored, the field value will be automatically copied to the OrderItem field of the same name.

Then you could get it in your Invoice directly using a data macro {%fieldname%} and using the OrderItem.GetValue("customtaxfieldname") method...

We will hopefully implement this by default in the next versions, but currently, you'll have to use the customization. I would recommend to read about v.6.0 Ecommerce customizations in New Ecommerce customization model blogpost.

Hope this will be helpful.
Regards,
Zdenek