Portal Engine Questions on portal engine and web parts.
Version 4.x > Portal Engine > Ecommerce- dynamiv shipping charge View modes: 
User avatar
Member
Member
eagleag - 12/10/2011 4:57:56 PM
   
Ecommerce- dynamiv shipping charge
Hi,

I would like to have only ONE shippiing option (is auto selected) that its CHARGE will be dynamic.
It depends on how many items a user buys.

This is what I tried:
1. ShoppingCartContent.ascx.cs -> caculate teh shipping I want to cahrge
ShoppingCartInfoObj.TotalShipping = getShippingPrice();
ShoppingCartInfoProvider.SetShoppingCartInfo(ShoppingCartInfoObj);

but along the seps it doesnt keep the value +
This line also made shipping clear and not be passed on.
 ShoppingCartInfoProvider.EvaluateShoppingCartContent(ShoppingCartInfoObj);


AND

1. create a SHIPPPING OPTION in cmsdesk
2. ShoppingCartContent.ascx.cs -> I try to update the charge for this SHIPPING OPTION for this user.

What is the correct way to do this?

User avatar
Kentico Consulting
Kentico Consulting
kentico_borisp - 12/12/2011 2:14:19 AM
   
RE:Ecommerce- dynamiv shipping charge
Hello,

Every time the EvaluateShoppingCartContent method is called, the shopping cart content is re-evaluated. That's why you need to calculate and set the custom shipping every time this method is called. For more information please check our documentation and the general setup.

Best regards,
Boris Pocatko

User avatar
Member
Member
eagleag - 12/12/2011 8:41:37 AM
   
RE:Ecommerce- dynamiv shipping charge
Hi,
Got it working so now shipping cart shows correct shipping price and on last step show shipping priice and Total price (whcih includes products + shipping).

When I go to cmsdesk-> tools-> ecomm -> order -> (order) -> INVOICE -> I see correct shipping + total.
but when i go to ITEMS tab shipping is wrong.
Example:
I have ONE PRODUCT with 4 Units of it and my shipping calculate sit as only ONE.

this is the custom code I use to loop throw products in order to calculate shipping (only doesnt work when in ORDER -> ITEM:

int length = CMS.Ecommerce.ECommerceContext.CurrentShoppingCart.CartItems.Count;
for (int i = 0; i < length; i++)
{
// DO NOT COUNT PRODUCT OPTIONS, if you do count them then you will get double the amount
if (!((CMS.Ecommerce.ShoppingCartItemInfo)(CMS.Ecommerce.ECommerceContext.CurrentShoppingCart.CartItems)).IsProductOption)
{
itemId = ((CMS.Ecommerce.ShoppingCartItemInfo)(CMS.Ecommerce.ECommerceContext.CurrentShoppingCart.CartItems)).CartItemGUID;//CMS.Ecommerce.ECommerceContext.CurrentShoppingCart.CartItems.CartItemID;
unitsTotal += CMS.Ecommerce.ECommerceContext.CurrentShoppingCart.GetShoppingCartItemInfo(itemId).CartItemUnits;
}
}


Thanks :)

User avatar
Kentico Consulting
Kentico Consulting
kentico_borisp - 1/3/2012 3:54:16 AM
   
RE:Ecommerce- dynamiv shipping charge
Hello,

The given table gets initialized in the EvaluateContent method in the ShoppingCartInfoProvider. So, if you override this method, you can alter the DataTable, which holds the items in the order according to your calculations.

    protected override void EvaluateContentInternal(ShoppingCartInfo cart)
{
base.EvaluateContentInternal(cart);

System.Data.DataTable dt = (System.Data.DataTable)cart.ContentTable;
}


Best regards,
Boris Pocatko