Portal Engine Questions on portal engine and web parts.
Version 5.x > Portal Engine > Using CustomEcommerceProvider project to recalculate shopping cart View modes: 
User avatar
Member
Member
jake_5798-msn - 4/16/2011 2:49:03 AM
   
Using CustomEcommerceProvider project to recalculate shopping cart
Hi,

I'm using the CustomEcommerceProvider project and I need to do the following:

- Iterate the shopping cart items
- For each item I need to manually set a NEW skuPrice
- Update the cart so taxes, etc are recalculated

I am using the following class: CustomShoppingCartInfoProvider
I am using the following method: EvaluateShoppingCartContent

I have gotten as far as to do all of the above steps. The only issue I have is that when I update the cart item (ShoppingCartItemInfo) and write it back to the cart, the price does not change (original price remains).

Thank you.


User avatar
Kentico Developer
Kentico Developer
kentico_helenag - 4/19/2011 2:20:03 AM
   
RE:Using CustomEcommerceProvider project to recalculate shopping cart
Hello,


If you want to change the current items in the shopping cart, you need to change the shoppingCart.ShoppingCartContentTable object. For example:


public void EvaluateShoppingCartContent(object _shoppingCart)
{
ShoppingCartInfoProvider.EvaluateShoppingCartContent((CMS.Ecommerce.ShoppingCartInfo)_shoppingCart);
CMS.Ecommerce.ShoppingCartInfo shoppingCart = (CMS.Ecommerce.ShoppingCartInfo)_shoppingCart;

foreach (DataRow dr in shoppingCart.ShoppingCartContentTable.Rows)
{
DataHelper.SetDataRowValue(dr, "SKUPrice", 1.23);
}

}

and set up the taxes and other calculations in the similar way.

It is not possible to set up the properties to shopping cart object directly in this case.


Best regards,
Helena Grulichova

User avatar
Member
Member
jake_5798-msn - 4/19/2011 6:19:32 PM
   
RE:Using CustomEcommerceProvider project to recalculate shopping cart
Thank you for your help. That makes sense. Hopefully in a next version the API will allow for updating the shopping cart directly. This would be particularly useful when wanting to implement custom discounts. For example '2 for 1', 'buy 2 of product x and get product y at 1/2 price', etc.

User avatar
Kentico Developer
Kentico Developer
kentico_helenag - 4/20/2011 2:05:27 PM
   
RE:Using CustomEcommerceProvider project to recalculate shopping cart
Hello,

we are considering the more flexible system of prices to next versions. I understand the current possibilities are rather limited.


Best regards,
Helena Grulichova

User avatar
Member
Member
poostwoud-gmail - 10/17/2011 9:48:39 AM
   
RE:Using CustomEcommerceProvider project to recalculate shopping cart
Hello Helena,

I've noticed this thread and I've been having the same problem as well. Do you know if this is resolved in version 6?

Hope to hear from you.

Best regards,

User avatar
Member
Member
poostwoud-gmail - 10/17/2011 9:56:53 AM
   
RE:Using CustomEcommerceProvider project to recalculate shopping cart
@jake_5798-msn,

Did you find any workaround for this?

Best regards,


User avatar
Member
Member
jake_5798-msn - 10/18/2011 6:01:20 PM
   
RE:Using CustomEcommerceProvider project to recalculate shopping cart
Hi,

I actually did find a work-around. I'm not sure if it will help you (depends on the issue you're having I guess) but for my issue, yes it worked.

In parallel to the cart functionality, I kept my own price in a variable all the way through each step of the cart. So if the cart price was $100, I was calculating my own discounts and had $80 as the total (for example).

In the shopping cart steps, in particular:

ShoppingCartPreview.ascx.cs

I manually wrote to the COM_Order table and updated the order price:

UPDATE COM_Order Set OrderTotalPrice = @myCustomPrice

This was done in the [public override bool ProcessStep()] method.

Use with caution. I don't recommend this as I'm not sure if it will have negative implications in your application. It's a bit of a hack. But having said that, for my problem it works 100% for several months now.

Cheers,

Jake


So after Kentico wrote the