Jump to content
Sign in to follow this  
ELIOT

AJAX Shopping Cart

Recommended Posts

AJAX Shopping Cart beta v1.0

 

This contribution allows customers to change product quantities and remove products without having to click the update button. Only the Shopping Cart area of the screen and the shopping cart infobox are refreshed.

 

Instead of the normal 'You should update your browser' message if using a non-XMLHTTP Compliant Browser (e.g. IE, Mozilla) the normal shopping cart will show instead.

 

Contribution: AJAX Shopping Cart

 

Beta 1.0 does not include support for attributes that's coming soon.

 

Installation should take about 5 mins.

 

Any comments welcomed. Enjoy

 

Eliot

Edited by ELIOT

Share this post


Link to post
Share on other sites
Sounds great! any idea if it will work alongside Easy Discount?

 

Thanks

David

 

Hi David

 

After taking a brief look at Easy Discount i should think it would. It will need some adjusting to fit it in like moving the Easy Discount code into getCart.php as well and adding it to the infobox using getCartBox.php

 

Eliot

Share this post


Link to post
Share on other sites
Hi David

 

After taking a brief look at Easy Discount i should think it would. It will need some adjusting to fit it in like moving the Easy Discount code into getCart.php as well and adding it to the infobox using getCartBox.php

 

Eliot

I've just installed it by transferring the files directly accross and nothing appears on the shopping_cart page. I get an HTML error.

 

http://dev.classicsoundandvision.com/shopping_cart.php

 

Any reason why?

 

Thanks

David

Edited by xdam

Share this post


Link to post
Share on other sites
I've just installed it by transferring the files directly accross and nothing appears on the shopping_cart page. I get an HTML error.

 

http://dev.classicsoundandvision.com/shopping_cart.php

 

Any reason why?

 

Thanks

David

 

I just tried it with Firefox and it works, i'll look into the IE error, but it'll be tomorrow now

 

cheers

 

Eliot

Share this post


Link to post
Share on other sites

AJAX Shopping Cart beta v1.1 released

 

v1.1 beta

--- General Bug fix release ---

* Empty cart Javascript errors fixed - included <span_cart> even if cart empty

* Cancelled <body onLoad=> if shopping cart empty

* Fixed bug with charset in GetCart.php and GetCartBox.php (thanks to Vlad Savitsky)

* Added support for Contrib Installer contrib

(http://www.oscommerce.com/community/contributions,3286) (thanks to Vlad Savitsky)

* install documentation updated inluding instructions for if you already have <BODY onLoad attribute

 

Contribution: AJAX Shopping Cart

 

Beta 1.1 still does not include support for attributes that's coming soon.

 

Installation should take about 5 mins.

 

Enjoy

 

Eliot

Share this post


Link to post
Share on other sites
I've just installed it by transferring the files directly accross and nothing appears on the shopping_cart page. I get an HTML error.

 

http://dev.classicsoundandvision.com/shopping_cart.php

 

Any reason why?

 

Thanks

David

 

Hi David

 

I tested out the contrib with two <body onload> attributes (like your code has) and the shopping cart will not work.

 

I've just uploaded beta v1.1 which explains what you'd need to do if you already have a body onload attribute (at the bottom of install.html)

 

regards

 

Eliot

Share this post


Link to post
Share on other sites

Hi!

Here is an error in install.html:

 

Find (now around line 65 on a fresh ms2)

?>

</td>

</tr>

<!-- shopping_cart_eof //-->

Should be (no "?>"):

Find (now around line 65 on a fresh ms2)

</td>

</tr>

<!-- shopping_cart_eof //-->


===============================

Never give up! Never give up! Never give up!

Share this post


Link to post
Share on other sites

Hi

 

This is great contrib! Eliot you are cool programmer!

 

I have replaced this js-code:

//fRet = confirm('Are you sure you want to remove this item from your shopping cart?');

with:

fRet = confirm('<?php echo TABLE_HEADING_REMOVE;?>?');

And now I have a multilanguage alert message: "Remove?"

 

I also change a design of remove checkbox:

 

tep_draw_checkbox_field('cart_delete[]', $products[$i]['id'], '','onChange="sendCartRemoveItem(\'' . $products[$i]['id'] . '\', \'getCart.php\',\'' . tep_session_name() . '=' . tep_session_id() . '\',\'span_cart\', \' <img src=images/loading.gif alt=loading> Please wait...\', \'rem_' . $products[$i]['id'] . '\', \'' . $products[$i]['id'] . '\');" id="rem_'.$products[$i]['id'].'"')

 

replaced with:

<a href=""

onClick="sendCartRemoveItem(\'' . $products[$i]['id'] . '\', \'getCart.php\',\'' . tep_session_name() . '=' . tep_session_id() . '\',\'span_cart\', \' <img src=images/loading.gif alt=loading> Please wait...\', \'rem_' . $products[$i]['id'] . '\', \'' . $products[$i]['id'] . '\');" id="rem_'.$products[$i]['id'].'"

>'.TABLE_HEADING_REMOVE.'</a>

 

 

and bug reportl:

1. When items count became 1 and I press "-" he ask me to remove but not remove item.

2. When I have 1 item in cart and use remove checkbox (or link) he ask me and I answer "No" he

cleans all from cart and load index.php (main page).

3. When I have some items in cart and press "Remove" checkbox he ask me but not remove.

 

Why?


===============================

Never give up! Never give up! Never give up!

Share this post


Link to post
Share on other sites

Installes this on my test shop then removed it.

Is it suppose to flicker so much and refresh such big area every time ?

Share this post


Link to post
Share on other sites
Installes this on my test shop then removed it.

Is it suppose to flicker so much and refresh such big area every time ?

Yes, you are right!

Can be refreshed only changed data?

 

I want also ask:

How I can do auto request to server after 1 sec after user stops type quantity?

Vlad


===============================

Never give up! Never give up! Never give up!

Share this post


Link to post
Share on other sites

Hi Vlad

 

I will be changing the code to only update the changed items as i would prefer not to update the larger shopping cart area, only the item that changes within the cart / infobox.

 

Eliot

 

Yes, you are right!

Can be refreshed only changed data?

 

I want also ask:

How I can do auto request to server after 1 sec after user stops type quantity?

Vlad

Share this post


Link to post
Share on other sites

I have created a nice little cross-browser ajax enabled shopping cart. You can see it in action at <a href="http://judson.biz/shopping_cart.php">Judson.biz</a>... This works with attributes, and allows removal, and updating of quantities. I removed the "update cart" button, but since this is unobtrusive javascript, if I were to add back the update cart button, the shopping cart would work as usual. Feel free to check out the code.

 

-Jud

Edited by Jud

Share this post


Link to post
Share on other sites
I have created a nice little cross-browser ajax enabled shopping cart. You can see it in action at <a href="http://judson.biz/shopping_cart.php">Judson.biz</a>... This works with attributes, and allows removal, and updating of quantities. I removed the "update cart" button, but since this is unobtrusive javascript, if I were to add back the update cart button, the shopping cart would work as usual. Feel free to check out the code.

 

-Jud

 

I have even (!) registered at your site...

But I couldn't add nothing to cart in Opera.

Splash scrfeen "Product Added!" is showing all time...

So I can't add and can't see how it works.

Edited by Vlad Savitsky

===============================

Never give up! Never give up! Never give up!

Share this post


Link to post
Share on other sites

Hi, ELIOT!

 

I have resolved all my problems.

On clear osc all works fine so bugs that I posted was my own bugs. Sorry.

 

Can you also do just one refreshment.

When I inc or dec qty in cart cart content refreshes twice...

Why?

 

There is ajax cart at my site:

http://www.smirna.org/shopping_cart.php

Edited by Vlad Savitsky

===============================

Never give up! Never give up! Never give up!

Share this post


Link to post
Share on other sites
I have created a nice little cross-browser ajax enabled shopping cart. You can see it in action at <a href="http://judson.biz/shopping_cart.php">Judson.biz</a>... This works with attributes, and allows removal, and updating of quantities. I removed the "update cart" button, but since this is unobtrusive javascript, if I were to add back the update cart button, the shopping cart would work as usual. Feel free to check out the code.

 

-Jud

 

Thats a really cool shopping cart you have there. Any plans to release some of the functions you have done?

 

Nice work,

Fredrik

Share this post


Link to post
Share on other sites
Hi, ELIOT!

 

I have resolved all my problems.

On clear osc all works fine so bugs that I posted was my own bugs. Sorry.

 

Can you also do just one refreshment.

When I inc or dec qty in cart cart content refreshes twice...

Why?

 

There is ajax cart at my site:

http://www.smirna.org/shopping_cart.php

 

well, in FF it shows after some delay and then flickers twice and in IE7 nothing ever shows at all as it produces a runtime error, the same applies to the shopping cart box by the way.


Treasurer MFC

Share this post


Link to post
Share on other sites
I have even (!) registered at your site...

But I couldn't add nothing to cart in Opera.

Splash scrfeen "Product Added!" is showing all time...

So I can't add and can't see how it works.

 

When I said cross-browser, I should have said "cross-browser that I care about" ;-) ... as it is, less than 1 percent of my customers use opera, in fact, it is only 12 per year. The big two (or 3 depending on how u look at it) are IE 6 and 7, and then the 12% share held by firefox, which all show no problems with using the ajax features on Judson.biz

Edited by Jud

Share this post


Link to post
Share on other sites

Jud, can u tell me wt contribution(s) u used for all ur ajax functions?? the product images .. the shopping card? they are nice

Share this post


Link to post
Share on other sites

I didn't use a contribution, All of it is custom for my store. Its really not that hard though, you may want to look at the mootools javascript library, which is the library I used.

Share this post


Link to post
Share on other sites

Hi,

 

Can anyone point me in the right direction here.

 

When I use the +- quantity buttons, it adds a second shopping cart on the left.

 

error.jpg

 

I use the column controller contrib also if that help?

Also when the qty =1 and i minus it it asks me if i want to remove it from cart, i say ok, but it stays..

 

Any ideas?

Share this post


Link to post
Share on other sites

Hey there!

 

First thanks for this cool contribution!

 

Question: When removing an item with tick the remove box, the item will not be removed until clicking additional once at some empty space on the space...

 

so is it possible to enable that the "remove" question will come directly after ticking the remove box....??

 

Thank you!

Andreas

Share this post


Link to post
Share on other sites

There is an additional bug here:

 

When setting the quantity to 0 it asks "are you sure you want to remove the item" but after clicking OK the item will not be removed!

Share this post


Link to post
Share on other sites
There is an additional bug here:

 

When setting the quantity to 0 it asks "are you sure you want to remove the item" but after clicking OK the item will not be removed!

I have the same one. Next to that I have one more question. I am quite new to OsCommerce and PHP, but when checking for contributions, I felt like this to be a 'must have'. It gives a very professional image to the webshop.

 

My question is: I am having three languages in my shop. How can I adjust the "Are you sure you want to remove this item from your shopping cart?" to show for the language that has been selected instead of the plain English one?

 

Thanks!

Share this post


Link to post
Share on other sites
I have the same one. Next to that I have one more question. I am quite new to OsCommerce and PHP, but when checking for contributions, I felt like this to be a 'must have'. It gives a very professional image to the webshop.

 

My question is: I am having three languages in my shop. How can I adjust the "Are you sure you want to remove this item from your shopping cart?" to show for the language that has been selected instead of the plain English one?

 

Thanks!

I have one more problem. When I add a product to the cart and when I click on "continue shopping" or just go to a product group, my shopping carts empties again. Which part of the code should I have a look at for this to solve?

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×