Kentico E-commerce - Custom field on cart/order line items being overwritten

Keith Donnell asked on November 10, 2015 00:07

Hi there.

We have a fully custom product page which allows multiple quantities of variants to be added to the cart in a single page. Everything is wired up, however we have a custom field (a value that will be different each time they add to cart). When we call ShoppingCart.SetShoppingCartItem(cartItemParams), the system will perform an update on the line item matching the sku, even though our custom field is different:

var cartItemParams = new ShoppingCartItemParameters();
cartItemParams.Quantity = qty;
cartItemParams.SKUID = id;
cartItemParams.CustomParameters.Add("CustomFieldName", custom); // <--- this value is different than the value for this custom column in the existing cart line item.

We want a NEW cart item record created in this scenario - how can we accomplish this?

Correct Answer

Keith Donnell answered on November 11, 2015 18:42

We figured out if you do not use the cart.SetShoppingCartItem() method and instead manually call ShoppingCartInfoProvider.SetShoppingCartItemInfo(item) and then provider.AddShoppingCartItem(cart, item), this accomplishes what we need.

0 votesVote for this answer Unmark Correct answer

Recent Answers


Tim Cromwell answered on June 21, 2016 02:57

Hi @keith-donnel / anyone. I'm trying to achieve this as well (Kentico 8.2) but am not getting very far as there doesn't seem to be a "ShoppingCartInfoProvider.SetShoppingCartItemInfo" method?

I've dug through the API docs and can't seem to find any other way to get from a ShoppingCartItemParameters object to a ShoppingCartItemInfo object other than by using "SetShoppingCartItem", which updates existing records in the cart (which I don't want).

Any help would be greatly appreciated.

0 votesVote for this answer Mark as a Correct answer

Atri Dwivedi answered on May 23, 2017 17:19

Hi,

I am stuck on same issue. I am trying add a new cart item all time. But SetShoppingCartItem always update CartItemUnits instead of adding a new cart item if SKUId is same. How we can accomplish it.

Please help.

0 votesVote for this answer Mark as a Correct answer

   Please, sign in to be able to submit a new answer.