Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

jQuery/Ajax Shopping Cart


delete13

Recommended Posts

Well, I thought seeing as it is a new year, It is time to start learning AJAX/JQuery and one of my clients requirements looked to be satisfied with this contribution.

I have now spent half the day applying the changes, with no luck and the rest of the day rolling back the changes to see if I can find where it is going wrong.

Now I am no Ajax specialist to please excuse my ignorance.

Having rolled everything out, the first thing I did was add the <script type="text/javascript" src="js/jquery-1.4.2.min.js"></script> to the catalog/shopping_cart.php and immediately I received a warning stating that

 

Webpage error details

 

Message: Object doesn't support this property or method

Line: 8

Char: 1

Code: 0

URI: http://www.just-another-thought.info/shop/includes/jquery-oscart.js

 

Please note that I have placed the jquery-oscart.js in the includes directory and not the js directory.

I would imagine that this is a big problem but I am willing to be corrected if this is not the case.

 

Thanks

Link to comment
Share on other sites

  • 1 month later...

Hi,

 

this contri looks very nice.

When testing your demo I found some minor issues:

- start with an empty cart

- go to subcategory (hardware)

- click on 'matrox g400'

- click 'add to cart'

the product flies to the shopping cart (very nice) and the cart changes

next

- in categories click on 'mice'

- new product-page appear with 'buy now' button

- click on 'buy now'

- the product is added to the cart, and the page reload to the shopping cart

next

- do the same as for mice with the 'matrox g400'

- when you click 'buy now' it goes to the product page where you have to select 'add to cart'

 

Besides this minor issue very nice add-on.

 

btw, does it also work with seo as I've tried to install multiple ajax-shopping carts, but they all seem to have problems with seo enabled and/or ultimate seo urls 5 (contri 6768)

 

Keep up the good work.

Link to comment
Share on other sites

  • 3 weeks later...

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.

 

 

Have tried incorporating this mod into OSC 2.3.1, but unable to alter code or understand it to get it added to store.

Link to comment
Share on other sites

  • 2 weeks later...

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?

 

 

I just wondering or point two still not works? The product page works fine. Now I like to have this on the product list. Does anyone got suggestions?

Link to comment
Share on other sites

  • 3 weeks later...

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

 

I got the same problem. When updating the whole page comes into the shoppingcart, also with the shoppingcart box.

Did you already solved the problem?

Link to comment
Share on other sites

Hi eveyone,

 

I tried to install it and I've different problem

1- already report, but i didn find the solution, is th problem of the total price being updated in the shopping-cart-box, a whole new oscommerce window opens INSIDE the shopping cart box. Does anyone have a solution? exept remove ('<span id=boxcart-total>' . $currencies->format($cart->show_total()) . '</span>' );)

 

2- If 1 have a product A with attribute in my basket, and i add a another, the boxe doesnt display 2xA but 1xa, i should change of page to see the good quantity

 

3-On my website I'm already working with Jquery_1.5, but this contribution doesnt work with jquery>=1.5, If i load jquery_1.5, i have a problem on product with attribute, which are added no stop until i'm stay on product_info.

I mean, i'm on product page, i click on "add", the picture go to shopping_cart boxe, but the product aren't add to the boxe. I wait, go to shopping_cart.php, and i see the this product have been added 20-50times?

Does anyone deal with jquery_1.5?

Link to comment
Share on other sites

"GET /shopping_cart.php?ajax=1 HTTP/1.1" 200 2061

 

This is the second line which comes up in firebug when choose + or - quantity. Does anyone know where this as been programmed?

 

The first line POST /~oscommerce/shopping_cart.php?action=update_product&ajax=1 seems to compare with shopping_cart.php arround line 60

 <td width="100%" valign="top"><?php echo tep_draw_form('cart_quantity', tep_href_link(FILENAME_SHOPPING_CART, 'action=update_product')); ?>

 

I like to have this index2.php. But I don't know where to look. I hope somebody can help me with this great contribution.

Link to comment
Share on other sites

Ok. it seems finnaly got shoppingcart box working. The problem I got with the shoppingcart itself is : instead of taken the part

 

 

<div id="content1-body">

...

 

..

</div>

 

it seems that he takes the whole file. Where will this be defined in jquery-oscart? The connection code to the content-body of the shoppingcar.phpt file?

Link to comment
Share on other sites

about my different problem.

 

Finally I redesign the boxe and remove <span id=boxcart-total>'

 

But i still have problem with jquery>1.5

If i load jquery_1.5, i have a problem on product with attribute, which are added no stop until i'm stay on product_info.

I mean, i'm on product page, i click on "add", the picture go to shopping_cart boxe, but the product aren't add to the boxe. I wait, go to shopping_cart.php, and i see the this product have been added 20-50times?

 

Does anyone deal with jquery_1.5?

Link to comment
Share on other sites

about my different problem.

 

Finally I redesign the boxe and remove <span id=boxcart-total>'

 

But i still have problem with jquery>1.5

If i load jquery_1.5, i have a problem on product with attribute, which are added no stop until i'm stay on product_info.

I mean, i'm on product page, i click on "add", the picture go to shopping_cart boxe, but the product aren't add to the boxe. I wait, go to shopping_cart.php, and i see the this product have been added 20-50times?

 

Does anyone deal with jquery_1.5?

 

Delete the second "<script type="text/javascript" src="js/jquery-oscart.js"></script>"

 

in the shopping_cart.php. Maybe the problem solved. I got a similar problem, after delete the rule, problem solved.

Link to comment
Share on other sites

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) ; 

 

You also need to update

<script type="text/javascript" src="js/jquery-1.4.2.min.js"></script>

 

to

<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js" type="text/javascript">
</script>

 

otherwise you get errors

Link to comment
Share on other sites

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) ; 

 

When changing this I got the following error:

 

$(document).ready is not a function =>jquery-oscart.js (line 8)

Link to comment
Share on other sites

In the installation instruction it says,

 

"4) filename : catalog/index.php and other one where placed the shopping cart infobox

 

Just place a call to the jquery API and the javascript contribution include file in the <head> section :

 

<script type="text/javascript" src="js/jquery-1.4.2.min.js"></script>

<script type="text/javascript" src="js/jquery-oscart.js"></script>"

 

What do you mean by that?

Link to comment
Share on other sites

Am I the only one who uses this contribution?

 

I am still busy to get this 100% working. I am getting the following problem

 

I get:

 

"POST /shopping_cart.php?action=update_product&ajax=1 
"GET /shopping_cart.php
"GET /js/jquery-oscart.js 
"POST /shopping_cart.php?action=update_product&show_total=1?ajax=1 
"GET /shopping_cart.php 

 

instead of

 

"POST /shopping_cart.php?action=update_product&ajax=1 
"GET /shopping_cart.php?ajax=1 
"GET /js/jquery-oscart.js 
"POST /shopping_cart.php?action=update_product&show_total=1?ajax=1 
"GET /shopping_cart.php?show_total=1&ajax=1 

 

Where do I have to look to make the right link?

Link to comment
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.

 

 

 

What you can do is change the line is jquery_oscart,js

 

line: ~274

 

$("#content-body").html(data);

 

to

 

$("#content-body").load("shopping_cart.php #content-body > *");

Link to comment
Share on other sites

this contribution works great except for one area. When you are in your shopping cart and you want to update the QTY of each item if you use the plus or minus sign, It updates the prices and the QTYs in the info box and in the shopping cart. The problem is when you click checkout it drops everything to a QTY of 1. the only way the QTY is saving is if you enter a number and then press enter for the page to refresh.

Link to comment
Share on other sites

  • 2 weeks later...

My oscommmerce is not installed in the root of the domain. But in another map.

when I installed this contribution. The programm takes the index.php from the root instead of the map.

 

When I change in the shoppingcart.php the

 

<?php echo tep_draw_form('cart_quantity', tep_href_link(FILENAME_SHOPPING_CART, 'action=update_product')); ?>

 

to

 

<?php echo tep_draw_form('cart_quantity', FILENAME_SHOPPING_CART, 'action=update_product'); ?>

 

I get domain/shopping_cart.php otherwise I get domain/index.php

 

tep_href_link => this should brings you to the right map, but it's not.

 

it seems something in jquery_oscart.js. had to change.

 

the .attr('action') on line 273 gives me the wrong link and of course no action from the shopping_cart.php file (action=update_product)

 

the only action I can see in jquery_oscart.js =

 

on line 216 : action = $(this).attr('class').split(' ').slice(-1) ;

 

I don't know how to read this line. But it seems to bring me back to the root index.php instead of map/index.php

 

hope someone can help me with this.

Link to comment
Share on other sites

when changing the

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

 

To an url link made with shoppingcart, without .attr('action')etc. The POST in firebug goes always to the index.php file instead of the shopping_cart.php file.

 

how come? What code in jquery-oscart.js makes this?

 

Does somebody got a flying image from the listing.php working?

Link to comment
Share on other sites

  • 2 weeks later...

When I click plus or min in the shoppingcart I get in firebug

 

"POST /shopping_cart.php?action=update_product&ajax=1

"GET /shopping_cart.php?ajax=1

"GET /js/jquery-oscart.js

"POST /shopping_cart.php?action=update_product&show_total=1?ajax=1

"GET /shopping_cart.php?show_total=1&ajax=1

 

Where are these GET links from?

"GET /shopping_cart.php?ajax=1

"GET /shopping_cart.php?show_total=1&ajax=1

 

Hope someone knows...

Link to comment
Share on other sites

this contribution works great except for one area. When you are in your shopping cart and you want to update the QTY of each item if you use the plus or minus sign, It updates the prices and the QTYs in the info box and in the shopping cart. The problem is when you click checkout it drops everything to a QTY of 1. the only way the QTY is saving is if you enter a number and then press enter for the page to refresh.

 

Did you change something in your jquery-oscart.js?

 

The best way too discover is to look in firebug what the post and get links are.

 

unfortunately there is almost no response in this forum for such great contribution. I am still busy and solved a lot bugs in my program.

Link to comment
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 -

 

 

I think that's not a solution. check your html_output.php

 

it should be something like this:

 

// Output a form
 function tep_draw_form($name, $action, $method = 'post', $parameters = '', $tokenize = false) {
   global $sessiontoken;

   $form = '<form name="' . tep_output_string($name) . '" action="' . tep_output_string($action) . '" method="' . tep_output_string($method) . '"';

   if (tep_not_null($parameters)) $form .= ' ' . $parameters;

   $form .= '>';

   if ( ($tokenize == true) && isset($sessiontoken) ) {
     $form .= '<input type="hidden" name="formid" value="' . tep_output_string($sessiontoken) . '" />';
   }

   return $form;
 }

 

and if you got something like this:

 

function tep_draw_form($name, $action, $method = 'post', $parameters = '') {
$action = str_replace('&', '&', $action);
$parameters = str_replace('&', '&', $parameters);
   $action_url = preg_replace( '/\.*/?','',$action);  delete . and ? for the right POST connection
   $action_par = preg_replace( '/.*\?/','',$action);

Link to comment
Share on other sites

I think that's not a solution. check your html_output.php

 

it should be something like this:

 

// Output a form
 function tep_draw_form($name, $action, $method = 'post', $parameters = '', $tokenize = false) {
   global $sessiontoken;

   $form = '<form name="' . tep_output_string($name) . '" action="' . tep_output_string($action) . '" method="' . tep_output_string($method) . '"';

   if (tep_not_null($parameters)) $form .= ' ' . $parameters;

   $form .= '>';

   if ( ($tokenize == true) && isset($sessiontoken) ) {
     $form .= '<input type="hidden" name="formid" value="' . tep_output_string($sessiontoken) . '" />';
   }

   return $form;
 }

 

and if you got something like this:

 

function tep_draw_form($name, $action, $method = 'post', $parameters = '') {
$action = str_replace('&', '&', $action);
$parameters = str_replace('&', '&', $parameters);
   $action_url = preg_replace( '/\.*/?','',$action);  delete . and ? for the right POST connection
   $action_par = preg_replace( '/.*\?/','',$action);

 

 

This is what I have. What do I need to change to make it function properly? When I click on the remove or + - quantities it opens a section of my footer which is my hosts SSL Site seal. I have to reload the page to reflect the update which occurs.

 

// Output a form
//+Auto SSL Links

 function tep_draw_form($name, $action, $method = 'post', $parameters = '', $connection = 'NONSSL') {

   //Make secure connection if applicable

   if ($connection == 'SSL' || $action == '') {

     $action = tep_auto_sll_link(tep_output_string($action));

   } else {

     $action = tep_output_string($action);

   }

   $form = '<form name="' . tep_output_string($name) . '" action="' . $action . '" method="' . tep_output_string($method) . '"';

//-Auto SSL Links

   if (tep_not_null($parameters)) $form .= ' ' . $parameters;

   $form .= '>';

   return $form;
 }

Link to comment
Share on other sites

  • 3 weeks later...

This is what I have. What do I need to change to make it function properly? When I click on the remove or + - quantities it opens a section of my footer which is my hosts SSL Site seal. I have to reload the page to reflect the update which occurs.

 

// Output a form
//+Auto SSL Links

 function tep_draw_form($name, $action, $method = 'post', $parameters = '', $connection = 'NONSSL') {

   //Make secure connection if applicable

   if ($connection == 'SSL' || $action == '') {

     $action = tep_auto_sll_link(tep_output_string($action));

   } else {

     $action = tep_output_string($action);

   }

   $form = '<form name="' . tep_output_string($name) . '" action="' . $action . '" method="' . tep_output_string($method) . '"';

//-Auto SSL Links

   if (tep_not_null($parameters)) $form .= ' ' . $parameters;

   $form .= '>';

   return $form;
 }

 

 

change

 

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

 

 

in

 

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

 

maybe it works, for me it does..

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...