Portal Engine Questions on portal engine and web parts.
Version 5.x > Portal Engine > Ajax Shopping Cart Update Panels View modes: 
User avatar
Certified Developer 8
Certified Developer 8
richard - 6/20/2010 9:35:29 PM
   
Ajax Shopping Cart Update Panels
Hi there

I am building an ajax shopping cart. Here is what I have built:

I have a mini shopping cart preview webpart that has "ajax" ticked in the properties.
I have ticked "ajax" on the productdatalist web part on the same page.
I have altered the code on the ShoppingCartItemSelector control so it does not redirect the shopping cart.
I have added the code on this page to add the product to the shopping cart via the API.

So the process is that the user clicks the add to cart button, the button changes to "product added" and the mini shopping cart is refreshed.

Now this does partially work:

The add to cart button will only update on the second click but adds the product via API on the first and last...
The ShoppingCart Mini Preview only works if I put a CMSUpdatePanel around the code in the control.

Can anyone caste any light on how to achieve this?

User avatar
Certified Developer 8
Certified Developer 8
richard - 6/20/2010 11:51:28 PM
   
RE:Ajax Shopping Cart Update Panels
I have solved it I think.

I had to disable to ReloadData and InitializeControls functions on the post back, and add to the cart on the postback.

I will make my code available once I am at a bit more advanced stage of the dev as I have seen a few others asking for this.

Cheers

Richard

User avatar
Member
Member
eagleag - 5/5/2011 12:50:22 PM
   
RE:Ajax Shopping Cart Update Panels
wow amazing!!!!
I'd love to see the code

User avatar
Certified Developer 8
Certified Developer 8
richard - 5/5/2011 2:58:21 PM
   
RE:Ajax Shopping Cart Update Panels
Not what I would call amazing, bit of a hack all round really.

Here is the page with the Ajax button on it: http://www.rubyslist.co.nz/Shop.aspx

In retrospect I possibly could have achieved the same thing by just using a client side button and Jquery ajax and hitting a cms page to add the product to the cart.

The hardest thing was getting the value of the quantity dropdown as it is not part of the control that has the button, I had to pass in the clientid of the quantity drop down control to find in the page.

Here is the code, the text file has the transformation:
http://clients.federationmedia.co.nz/RubysShoppingCartItemSelector.zip

Good luck.

Richard