Portal Engine Questions on portal engine and web parts.
Version 5.x > Portal Engine > Unable to delete/empty shopping cart outside of shopping cart control View modes: 
User avatar
Member
Member
henry - 2/10/2010 4:31:40 PM
   
Unable to delete/empty shopping cart outside of shopping cart control
Hi guys, we're currently building a ecommerce solution that uses an external hosted provider, so our ecommerce workflow goes something like this:

add items to shopping cart --> enter details/delivery --redirected to external (like paypal) payment provider --> postback to site and update order status.

The problem we are having is with clearing the shopping cart after coming back to the site from the payment provider. First we get the shopping cart from the order info:

ShoppingCartInfoProvider.GetShoppingCartInfoFromOrder(orderID)

But we can't seem to remove/delete the shoppingcartinfo object at this stage anymore. Have tried ShoppingCartInfoProvider.DeleteShoppingCartItems(), ShoppingCartInfoProvider.EmptyShoppingCart(), ShoppingCartInfoProvider.DeleteShoppingCartInfo() and while debugging sometimes the items clear but the changes don't persist and the next time go to the shopping basket page your old items are there again.

Does anyone know why this is not working/how to do this properly? At the moment we are using a workaround where we're clearing the shopping cart from within the shoppingcart control using ShoppingCartControl.CleanUpShoppingCart(); but this means that if the user goes back after being redirected to the payment provider but before completing their payment, their shopping cart has already been cleared.

Thanks in advance!

-Henry

User avatar
Member
Member
kentico_pavelk - 2/15/2010 7:10:33 AM
   
RE:Unable to delete/empty shopping cart outside of shopping cart control
Hello,

You can proceed like this:
In your custom payment gateway in ProcessPayment method, you can clean the shopping cart using CleanUpShoppingCart (the shoppingcart object is available in that method). The problem with customer's returning back without completing the payment can be solved if you fill the CurrentShoppingCart object with the order from the database. When the customer is coming back to your site, you know the Order Id which you should use to get the data.


Best regards,
Pavel Knotek

User avatar
Certified Developer 8
Certified Developer 8
richard - 5/27/2010 2:02:48 AM
   
RE:Unable to delete/empty shopping cart outside of shopping cart control
Hi Pavel

I have the exactly the same problem tried what you suggest but the CleanUpShoppingCart method does not seem to work. I get a Object not set to an instance... etc.

I am calling this.ShoppingCartControl.CleanUpShoppingCart(); in the ProcessPayment() method. But I think because I am using a stand alone page - ie not in a shopping cart step then I can't use this.

The issue is that I can update the orderid to completed and paid ecertera but when they go back and try to add anything to their cart I get this exception:

Message: [DataConnection.ExecuteQuery]: Query: INSERT INTO COM_ShoppingCartSKU ([ShoppingCartID], [SKUID], [SKUUnits], [CartItemCustomData], [CartItemGuid], [CartItemParentGuid] ) VALUES ( @ShoppingCartID, @SKUID, @SKUUnits, @CartItemCustomData, @CartItemGuid, @CartItemParentGuid); SELECT SCOPE_IDENTITY() AS [CartItemID] : caused exception: The INSERT statement conflicted with the FOREIGN KEY constraint "FK_COM_ShoppingCartSKU_COM_ShoppingCart". The conflict occurred in database "brick_bay", table "brick_bay_user.COM_ShoppingCart", column 'ShoppingCartID'.


User avatar
Member
Member
kentico_pavelk - 6/1/2010 6:18:19 AM
   
RE:Unable to delete/empty shopping cart outside of shopping cart control
Hello Richard,

Could you please describe your shopping process structure? You mentioned that you try to clean up the shopping cart on some stand alone page which is confusing for me.


Best regards,
Pavel Knotek