Jump to content
delete13

jQuery/Ajax Shopping Cart

Recommended Posts

j'ai quitte Marseille il y'a plus que trente ans

 

Currently, i don't stay in Marseille but in Bangkok, another amazing place !

 

I'm sure you know my friend Michel,

one of the last best fisherman in Marseille !

 

Yes it's possible but need a custom developpment

Edited by delete13

Share this post


Link to post
Share on other sites

Hi great contrib :thumbsup:

 

i dont get the total sum to update (correct it self)when customer deletes a product from eg index site. ( i do get the question popup if i want to update the shopping cart).

 

When shopping cart is empty the price is still there until the customer goes to shopping_cart.php

 

Any solution? :)

Share this post


Link to post
Share on other sites

i installed the latest contribution and checked my boxes/shopping_cart.php for the fix earlier in this thread but still the sum doesnt update as it should.

Share this post


Link to post
Share on other sites

I have applied the AJAX/jQuery contribution #7477 (http://addons.oscommerce.com/info/7477)

to a stock oscommerce 2.2rc2a over 4 times now and keep getting a big issue:

 

Everything works but instead of the total price being updated in the shopping-cart-box, a whole new oscommerce window opens INSIDE the shopping cart box. In opera the whole thing just hangs or crashes. Ive tried on seveal PCs, but same issue.

 

http://chaosoutfitters.com/ << try it and see!

 

I have re-installed oscommerce and this add-on over 4 times in past 2 days trying to get it to work...

 

When i remove <span id=boxcart-total> from line ~72 of /boxes/shopping_cart.php

the issue dissapears but of course total will not get updated.

 

in oscart.js this is the line thats not getting the right DATA passed

 

--------------------------------------------

// Updating infobox content

 

$.ajax({

type: 'POST',

url: encodeURI($('form[name=cart_quantity]').attr('action')) + '&show_total=1&ajax=1',

data: $('form[name=cart_quantity]').serialize(),

success: function(data) {

$('#boxcart-total').html(data);

//Hide_Load();

}

});

--------------------------------------------

I can post my php files but like I said they are out of the box with ONLY this add-on.

 

Thanks in advance

 

-Duane

Edited by Worst_Username_Ever

Share this post


Link to post
Share on other sites

Everything works but instead of the total price being updated in the shopping-cart-box, a whole new oscommerce window opens INSIDE the shopping cart box. In opera the whole thing just hangs or crashes. Ive tried on seveal PCs, but same issue.

 

Dear Sir,

 

Sure ! You're right.

 

There is a mistake in jquery-oscart.js line 120 and i never had feedback about this problem :

 

Look for '?action=show_total&ajax=1' change to '?show_total&ajax=1'

 

If you could update the package that will be great for other people too.

 

Thx in advance.

Olivier

Share this post


Link to post
Share on other sites

salut Olivier,

 

I am still not able to make this addon work. I have made the changes you mention to line 120 but I dont think it affects the total price.

 

Is it possible that line 77 or 78 is the culprit?

 

Let me know if you are having the same error...

 

Thanks!

 

D

Share this post


Link to post
Share on other sites

Is it possible that line 77 or 78 is the culprit?

Yes i think the URL is not perfectly encoded :

 

change this :

url: encodeURI($('form[name=cart_quantity]').attr('action')) + '&show_total=1&ajax=1',

 

by this :

url: encodeURI($('form[name=cart_quantity]').attr('action')) + '?show_total=1&ajax=1',

 

the best way is to encode the URL like this but i don't test it :

url: encodeURI($('form[name=cart_quantity]').attr('action') + '?show_total=1&ajax=1'),

 

I hope that will work for you !

Share this post


Link to post
Share on other sites

I have tried for hours now every combination of what you suggested. It is still not working :(

 

If you are unable to test it, I can grant you full access to my site with a clean install of 2.2rc2 so you can try it.

 

Also, on line 77 and 78, you are using 'form[name=cart_quantity]'

Should it be 'form[name=boxcart_quantity]' ?

 

Thanks

D

Share this post


Link to post
Share on other sites

Congratulations for this nice contribution,

 

when i run KissErrorHandler for debugging, i get the following error in shopping cart, in the 2 places of code where this line appears:

 

Here is the report and line following

 

Error: Undefined index: ajax
File: shopping_cart.php
Line: 34
Error: Undefined index: HTTP_X_REQUESTED_WITH
File: shopping_cart.php
Line: 34

Error: Undefined index: ajax
File: shopping_cart.php
Line: 340
Error: Undefined index: HTTP_X_REQUESTED_WITH
File: shopping_cart.php
Line: 340

 

	if ( (int)$_GET['ajax'] != 1 && $_SERVER['HTTP_X_REQUESTED_WITH'] != 'XMLHttpRequest' )

 

I'm sure this must be super easy to sort out but still :)

Share this post


Link to post
Share on other sites

Also, on line 77 and 78, you are using 'form[name=cart_quantity]'

Should it be 'form[name=boxcart_quantity]' ?

No don't look for bugs that doesn't exists lol

 

there is cart_quantity to uptdate shopping_cart page and boxcart_quantity to update shopping cart infoboxe !

Share this post


Link to post
Share on other sites

	if ( (int)$_GET['ajax'] != 1 && $_SERVER['HTTP_X_REQUESTED_WITH'] != 'XMLHttpRequest' )

 

You could change it by this one :

	if ( isset($_GET['ajax']) && (int)$_GET['ajax'] != 1 )

 

I tried before HTTP_X_REQUESTED_WITH, i like this method but seems to be uncompatible with some server and particulary with MSIE (...)

 

To avoid page directly page call with ajax parameter (from a non ajax requester) i also modified tep_href_link in html_output.php but it is not needed in this contribution, but i still post the code :

html_output.php / tep_href_link

	// Prevent non ajax loading / OLIVIER
//
$parameters = str_replace('&ajax=1', '', $parameters) ; 
$parameters = str_replace('?ajax=1', '?', $parameters) ; 

Share this post


Link to post
Share on other sites

there is cart_quantity to uptdate shopping_cart page and boxcart_quantity to update shopping cart infoboxe !

 

so why would cart_quantity update the cart INFOBOX?

 

i am sorry for being so instrusive, just very desperate to get this working...

 

thanks

Share this post


Link to post
Share on other sites

Hello,

First of all thanks for really great contribution;)

 

Some problems reported:

1. special polish characters are not displayed properly in Firefox (IE works fine). i did changes like in #3, but still with no luck. the problem exists only after shopping_cart or shopping_cart_box are reloaded without reloading the whole page.

2. when on shopping_cart page i want to change quantity or remove product from cart funcion is called twice(IE and Firefox). Firefox only for the first time (i have 1 cd in my cart, i click on "plus" button, quantity change to 3, the if i press "plus" again it will change quantity to 4).

3. I also have a problem with whole page in plase of total value in shopping cart box. temporary i removed total value line from box.

 

I will be appreciate for help.

Share this post


Link to post
Share on other sites

Problem is with this:

 

from line: 282

    $.ajax({
       type: 'POST',
       url: encodeURI($('form[name=cart_quantity]').attr('action')) + '&show_total=1&ajax=1',
       data: $('form').serialize(),
       success: function(data) {
           $('#boxcart-total').html(data);
           //Hide_Load();
           }
       });

 

when you click + or - in shopping cart then i have in my Apache logs:

 

 

"POST /shopping_cart.php?action=update_product&ajax=1 HTTP/1.1" 302 27
"GET /shopping_cart.php?ajax=1 HTTP/1.1" 200 2061
"GET /js/jquery-oscart.js HTTP/1.1" 200 2409
"POST /shopping_cart.php?action=update_product&show_total=1?ajax=1 HTTP/1.1" 302 27
"GET /shopping_cart.php?show_total=1&ajax=1 HTTP/1.1" 200 13814

 

problem is with last line - look ad this show_total=1&ajax=1 - some funcion changed & to $amp;

after this - when you load shopping_cart with this wrong parameter - it puts whole site into field #boxcart-total. And then we have none - in firefox - or whole site in cart box - in IE

 

When you will comment out

 

//            $('#boxcart-total').html(data);

 

then boxcart-total is not changing, but changing products quantity by buttons + / - is working.

 

 

I don't know what is changing & to &

do anyone have any idea ?

 

 

The same problem is when you removing product by small remove item in cartbox.

 

 

Any idea ?

 

i have already corrected line 120, but it changes nothing.

I have lot's of other mods in shop, but i think it's not only my problem :-(

Edited by krecik

Share this post


Link to post
Share on other sites

after I have changed:

 

url: encodeURI($('form[name=cart_quantity]').attr('action')) + '&show_total=1&ajax=1',

 

into

 

        url:  encodeURI($(location).attr('href')) + '?show_total=1&ajax=1',

 

it start working , and updating correctly when i'm using + / -

 

but there is still problem with small remove icon in cartbox -

Share this post


Link to post
Share on other sites

Problem is with function redirect in includes/functions/general.php

 

It's because:

 

when we hit + or - then javascript send ajax POST to address:

 

shopping_cart.php?action=update&show_total=1&ajax=1

 

first is application_top with action=update starting

 

and there is function that redirects us to:

shopping_cart.php?show_total=1&ajax=1

 

this is good, but

 

i don't know why - when - in general.php in function tep_redirect we have original:

 

    header('Location: ' . $url);

 

we get:

 

http://blablabla.com?param1=x&param2=y

 

after i changed to:

 

    header('Location: ' . htmlspecialchars_decode($url));

 

i got correct:

 

http://blablabla.com?param1=x&param2=y

 

after adding htmlspecialchars_decode it stopped to changing & into &

 

 

delete13 can you check your settings in this place ?

 

 

 

now it is working ;-)

in a half ;-) but rest i will try to fix tomorrow.

Edited by krecik

Share this post


Link to post
Share on other sites

someone knows how to make this contribution friendly with STS ??

when I click "add cart" it still reload the page"

 

thanks for you help

Share this post


Link to post
Share on other sites

Hi Delete,

 

Would it be possible for you to upload your RC2a catalog/product_info.php, & catalog/shopping_cart.php files with the contribution's modifications?

 

I simply cannot get this to work with a clean install of osc RC2a. It would be way much appreciated as I have been messing with this for hours and hours, and have had no success. The only part that I can get to work for me is the delete product function of the catalog/includes/boxes/shopping_cart.php file.

 

Thanks for your time.

 

TR

Share this post


Link to post
Share on other sites

Hi Again Delete,

 

Never mind my previous request.

 

My problem was that I was copying the modifications from the" jquery shopping cart - en.pdf" file, which copied them broken up into several lines that I then had to straighten out, which I obviously didn't do well with as I could not get it to work.

 

Anyhow, I ended up downloading Open Office so I could use the "jquery shopping cart - en.odt" file, which allowed me to copy the modifications formatted correctly.

 

Now it works properly. It's a wonderful contribution. Thank you for it. I am going to upload the RC2a catalog/product_info.php, & catalog/shopping_cart.php files with the contribution's modifications myself, for anyone who doesn't have Open Office. I will include the "js/jquery-oscart.js" line 120 update.

 

TR

Share this post


Link to post
Share on other sites

Hi Again Delete/Oliver,

 

Wondering if you might have time to see what can be done about the following:

 

When a product has attributes, adding more than one quantity does not update the quantities in the shopping cart info box the way it does when a product has no attributes. It will after the page has been refreshed.

 

Was also wondering (of a similar vein) if you could point me in the right direction towards how to make an added catalog/product_info.php quantity field, refresh the quantity correctly (so when a user adds more than one of a product through the added quantity field it will display correctly in the shopping cart info box without having to refresh the page)

 

Thanks in advance for your time.

 

TR

Share this post


Link to post
Share on other sites

Hi, i was trying to setup this plugin again and i noticed few things:

 

1. this plugin only works on "product_info" page if there is a image of the product

2. this plugin is not working on "product_list" (for example, if i choose one category on the left menu),

but i dont know if isnt working because REALLY isnt working or if is some "issue" like #1

 

any ideas?

Share this post


Link to post
Share on other sites

Hello Olivier,

 

T'as un parigot qui s'arrache les cheveux depuis 2 jours sur ta contrib :-)

 

Please upload the files included in your contribution (the ones running on your demo site) to allow us make a diff with plain vanilla osc files.

I noticed some differences between the php files and the joined instructions files (both en & fr).

 

That's very very frustrating to be so closed to get it running ... you're driving us nuts man !

 

TIA

Alain

Edited by groumph

Share this post


Link to post
Share on other sites

I was wondering if the current package is compatible with the new Version 2.3.1? I've tried looking for the lines to find and replace however I can't seem to locate them. It's probably that I'm just too new at this as well.

Share this post


Link to post
Share on other sites
I was wondering if the current package is compatible with the new Version 2.3.1? I've tried looking for the lines to find and replace however I can't seem to locate them. It's probably that I'm just too new at this as well.

 

Anyone can help???

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

×