Jump to content
Sign in to follow this  
ELIOT

AJAX Shopping Cart

Recommended Posts

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?

 

Hey Baronnn!

 

Check out the first page of this topic, someone already posted a solution for your problem

Share this post


Link to post
Share on other sites

Is this contribution supposed update the shopping cart box without a refresh or just the shopping cart page? Because I can only get ajax to work on the shopping card page.

Share this post


Link to post
Share on other sites

same here i only want to use it for the box? can some please tell us how... i went to one of the stores in this thread and they had it working. im going to start tinkering and will let everyone know

Share this post


Link to post
Share on other sites
make test in cart - load amount - this not loading the attributes

 

 

Hi Osgregs

 

Attributes are not supported in this version. When i get a minute i will be adding support

 

regards

 

Eliot

Share this post


Link to post
Share on other sites
Hi Osgregs

 

Attributes are not supported in this version. When i get a minute i will be adding support

 

regards

 

Eliot

Ok Thanks.

Share this post


Link to post
Share on other sites

Is there a way that this could be used to modify the price as well?

 

I'm thinking sort of like an administration order entry style thing, where you can create the order easily from the customer's account and enter the customer's price right from the order screen???

Share this post


Link to post
Share on other sites

I recently installed the version of AJAX shopping cart with the attributes support and came across many of the problems reported by others. Since I spent more time trying to fix them than I wanted, I will post my solutions in hopes that it will save others time. (I've tested this on IE7 and Firefox 2.) As a final note, I'm pretty sure that these changes will work for all, but my oscommerce site has so many mods they may not... You can check out the shopping cart at my site to see the result at http://www.chemicalevolution.com

 

1. Updates to quantities box and delete checkbox not updating properly in IE7

 

In GetCart.php replace this:

       $info_box_contents[$cur_row][] = array('align' => 'center',
                                            'params' => 'class="productListing-data" valign="top"',
                                            'text' => 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'].'"'));

 

With this:

      $info_box_contents[$cur_row][] = array('align' => 'center',
                                            'params' => 'class="productListing-data" valign="top"',
                                            'text' => 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_sc.gif alt=loading> Please wait...\', \'rem_' . $products[$i]['id'] . '\', \'' . $products[$i]['id'] . '\');"onclick="this.blur();" id="rem_'.$products[$i]['id'].'"'));

 

and replace this:

      $info_box_contents[$cur_row][] = array('align' => 'center',
                                            'params' => 'class="productListing-data" valign="top"',
                                            'text' => '<a href="java script:sendCartChangeQty(\'' . $products[$i]['id'] . '\', \'getCart.php\',\'' . tep_session_name() . '=' . tep_session_id() . '\',\'span_cart\', \' <img src=images/loading_sc.gif alt=loading> Please wait...<br/>\', \'qty_' . $products[$i]['id'] . '\', \'' . $products[$i]['id'] . '\', -1)">'.tep_image(DIR_WS_IMAGES .'minusBtn.gif').'</a>'.tep_draw_input_field('cart_quantity[]', $products[$i]['quantity'], 'size="4" onChange="sendCartChangeQty(\'' . $products[$i]['id'] . '\', \'getCart.php\',\'' . tep_session_name() . '=' . tep_session_id() . '\',\'span_cart\', \' <img src=images/loading_sc.gif alt=loading> Please wait...<br/>\', \'qty_' . $products[$i]['id'] . '\', \'' . $products[$i]['id'] . '\', 0);" id="qty_'.$products[$i]['id'].'"').'<a href="java script:sendCartChangeQty(\'' . $products[$i]['id'] . '\', \'getCart.php\',\'' . tep_session_name() . '=' . tep_session_id() . '\',\'span_cart\', \' <img src=images/loading_sc.gif alt=loading> Please wait...<br/>\', \'qty_' . $products[$i]['id'] . '\', \'' . $products[$i]['id'] . '\', 1)">'.tep_image(DIR_WS_IMAGES .'plusBtn.gif').'</a>'. tep_draw_hidden_field('products_id[]', $products[$i]['id']));

 

with this:

      $info_box_contents[$cur_row][] = array('align' => 'center',
                                            'params' => 'class="productListing-data" valign="top"',
                                            'text' => '<a href="java script:sendCartChangeQty(\'' . $products[$i]['id'] . '\', \'getCart.php\',\'' . tep_session_name() . '=' . tep_session_id() . '\',\'span_cart\', \' <img src=images/loading_sc.gif alt=loading> Please wait...<br/>\', \'qty_' . $products[$i]['id'] . '\', \'' . $products[$i]['id'] . '\', 1)">'.tep_image(DIR_WS_IMAGES .'plusBtn.gif').'</a>'.tep_draw_input_field('cart_quantity[]', $products[$i]['quantity'], 'size="4" onKeyPress="if((event.keyCode==10)||(event.keyCode==13)) this.blur();" onChange="sendCartChangeQty(\'' . $products[$i]['id'] . '\', \'getCart.php\',\'' . tep_session_name() . '=' . tep_session_id() . '\',\'span_cart\', \' <img src=images/loading_sc.gif alt=loading> Please wait...<br/>\', \'qty_' . $products[$i]['id'] . '\', \'' . $products[$i]['id'] . '\', 0);" id="qty_'.$products[$i]['id'].'"').'<a href="java script:sendCartChangeQty(\'' . $products[$i]['id'] . '\', \'getCart.php\',\'' . tep_session_name() . '=' . tep_session_id() . '\',\'span_cart\', \' <img src=images/loading_sc.gif alt=loading> Please wait...<br/>\', \'qty_' . $products[$i]['id'] . '\', \'' . $products[$i]['id'] . '\', -1)">'.tep_image(DIR_WS_IMAGES .'minusBtn.gif').'</a>'. tep_draw_hidden_field('products_id[]', $products[$i]['id']));

 

2. Shopping cart flashes when quantities being updated caused by extra GET requests.

 

In catalog/shopping_cart.php replace this:

 

			//When our stock change has been sent, update our page.
		function handleSendCart() {
			getCartText('','getCart.php','<?php echo tep_session_name().'='.tep_session_id(); ?>','span_cart',tmp);
			getCartInfoBoxText('','getCartBox.php','<?php echo tep_session_name().'='.tep_session_id(); ?>','span_cart_box',tmp);
		}

 

with this:

 

//When our stock change has been sent, update our page.
function handleSendCart() {
if (sendReq.readyState == 4 && sendReq.status == 200){
 getCartText('','getCart.php','<?php echo tep_session_name().'='.tep_session_id(); ?>','span_cart',tmp);
 getCartInfoBoxText('','getCartBox.php','<?php echo tep_session_name().'='.tep_session_id(); ?>','span_cart_box',tmp);
 }
}

 

and this:

			//When our stock change has been sent, update our page.
		function handleSendCartRemoveItem() {
			getCartText('','getCart.php','<?php echo tep_session_name().'='.tep_session_id(); ?>',loc,tmp);
			getCartInfoBoxText('','getCartBox.php','<?php echo tep_session_name().'='.tep_session_id(); ?>','span_cart_box',tmp);
		}	

 

with this:

 

//When our stock change has been sent, update our page.
function handleSendCartRemoveItem() {
if (sendReq.readyState == 4 && sendReq.status == 200){
 getCartText('','getCart.php','<?php echo tep_session_name().'='.tep_session_id(); ?>',loc,tmp);
 getCartInfoBoxText('','getCartBox.php','<?php echo tep_session_name().'='.tep_session_id(); ?>','span_cart_box',tmp);
 }
}

 

3. Code to verify text entered in quantity box is a number doesn't work:

 

In catalog/shopping_cart.php replace this:

  				if (qty.length > 0) {
			    qty_float = parseFloat(qty);
			    if (isNaN(qty_float)) {
					document.getElementById('p_status').innerHTML = 'Status: You must enter a number for Quantity.';
					return;						
   				}
			} else {
			    qty_float = 1;
 				}

 

with this:

//Verify entered quantity is number
if (isNaN(element.value)) {
 document.getElementById('p_status').innerHTML = 'You must enter a number for Quantity.';
 getCartText(key,file,sid,loc,tmp);
 return;
}
else {
 document.getElementById('p_status').innerHTML = '';
}

 

4. Problems when setting quantity to 0 and prompted to deleted item.

 

In catalog\shopping_cart.php replace this

				// check if Quantity drops below 0
			if  (Number(element.value) + Number(qty) <= 0) {
				// Are you sure you want to remove this item
				var fRet;
				fRet = confirm('Are you sure you want to remove this item from your shopping cart?');
				if (fRet == false) { return; } 
			}

 

with this:

// check if Quantity drops below 0
if (Number(element.value) + Number(qty) <= 0) {
 //Call function to delete item
 sendCartRemoveItem(key,file,sid,loc,tmp,iElementId,product_id);
 return;
}

 

and this:

				// check user wants to remove item
			if  (element.value != '') {
				// Are you sure you want to remove this item
				var fRet;
				fRet = confirm('Are you sure you want to remove this item from your shopping cart?');
				//alert(fRet);
				if (fRet == false) { return; } 
			}

 

with this:

// check user wants to remove item
//if (element.value != '') {
// Are you sure you want to remove this item
var fRet;
fRet = confirm('Are you sure you want to remove this item from your shopping cart?');
//alert(fRet);
if (fRet == false) {
 getCartText(key,file,sid,loc,tmp);
 return;
 }

 

Hope this is useful.

Share this post


Link to post
Share on other sites

Hi,

 

Great contribution, but I've run into a very strange problem with it ...

 

I've got three sites that are identical in every way apart from the product range and graphics:

 

http://www.spaces-collections.com/contemporary/

http://www.spaces-collections.com/fusion/

http://www.spaces-collections.com/rustic/

 

All three sites use the same shopping_cart, getCart files .... they were literally copied from one site to another.

 

The shopping cart works absolutely perfectly in the fusion and rustic sites, but on the contemporary no number appears in the quantity box (on shopping_cart.php). Quantities are still updated correctly (the order value increases for example) but the quantity doesn't show the way it does on the other two sites.

 

Anyone got any ideas, as it's got me stumped?

 

Thanks,

Ali.

Share this post


Link to post
Share on other sites

Hello,

 

this contribution seems great. But is there a possibility to use it with Simple Template System?

I'm only getting a shopping cart page with two buttons, but no cart at all.

Anyone got any ideas?

 

Thanks defiance

Share this post


Link to post
Share on other sites

Hello,

 

it was my fault...its to early in the morning. I have an Ticker script in my Template. So this results in two BODY ONLOAD commands. I changed the init function to

function init() 
{  	
newsticker();
if(typeof startCart == 'function') {
startCart('','getCart.php','<?php echo tep_session_name().'='.tep_session_id(); ?>');}	 
} 

and store it in the sts_template.html. Now it's functional.

 

regards

 

defiance

Share this post


Link to post
Share on other sites

I can't get this to work...

 

I'm using STS, I don't have any other functions going, I've tried to put the onload in my sts_template.htm body tag, but nothing...

 

All I get is a blank cart with the title and the checkout button (http://www.thewardrum.com) It seems to know that items are in the cart but just won't show them.

 

Any ideas anyone?

Share this post


Link to post
Share on other sites

I am testing this contribution on a new section I will open soon, but it does not display the Euro symbol correctly. I have updated to the most recent version tonight and still no change. By the way, this is in IE7. It shows fine in Firefox You can see it at http://www.thefonedoc.com/shop2

 

Just add something to cart and then once you are on the shopping_cart.php page the Euro symbol disappears?

 

Any ideas anybody?

Edited by fonedoc

Share this post


Link to post
Share on other sites

Hey boss this is what happened when I applied everything:

 

Notice: main(): Unable to find the wrapper "file" - did you forget to enable it when you configured PHP? in C:\Inetpub\wwwroot\erbanfootwear.com\getCart.php on line 14

 

Warning: main(file:///E|/Program Files/xampp/htdocs/catalog/includes/application_top.php): failed to open stream: No such file or directory in C:\Inetpub\wwwroot\erbanfootwear.com\getCart.php on line 14

 

Warning: main(): Failed opening 'file:///E|/Program Files/xampp/htdocs/catalog/includes/application_top.php' for inclusion (include_path='.;c:\php4\pear') in C:\Inetpub\wwwroot\erbanfootwear.com\getCart.php on line 14

 

Notice: Use of undefined constant CHARSET - assumed 'CHARSET' in C:\Inetpub\wwwroot\erbanfootwear.com\getCart.php on line 16

 

Warning: Cannot modify header information - headers already sent by (output started at C:\Inetpub\wwwroot\erbanfootwear.com\getCart.php:14) in C:\Inetpub\wwwroot\erbanfootwear.com\getCart.php on line 16

 

Notice: Use of undefined constant DIR_WS_LANGUAGES - assumed 'DIR_WS_LANGUAGES' in C:\Inetpub\wwwroot\erbanfootwear.com\getCart.php on line 18

 

Notice: Undefined variable: language in C:\Inetpub\wwwroot\erbanfootwear.com\getCart.php on line 18

 

Notice: Use of undefined constant FILENAME_SHOPPING_CART - assumed 'FILENAME_SHOPPING_CART' in C:\Inetpub\wwwroot\erbanfootwear.com\getCart.php on line 18

 

Warning: main(DIR_WS_LANGUAGES/FILENAME_SHOPPING_CART): failed to open stream: No such file or directory in C:\Inetpub\wwwroot\erbanfootwear.com\getCart.php on line 18

 

Fatal error: main(): Failed opening required 'DIR_WS_LANGUAGES/FILENAME_SHOPPING_CART' (include_path='.;c:\php4\pear') in C:\Inetpub\wwwroot\erbanfootwear.com\getCart.php on line 18

 

 

Any help please? would be greatly appreciated as always :D

Share this post


Link to post
Share on other sites

Does this contribution allow the customer to change the option of an attribute in the cart? For example, they ordered the wrong size of an item - can they change the size when viewing the cart?

Share this post


Link to post
Share on other sites

I've started testing this contribution on my test-system, but I get no items in the shopping_cart.php view, and the update button is removed. The info_box shows the correct items.

Them items dissappeared when I apllied the lines from line no. 294 in shopping_cart.php.

The following code is replaced by the code in the installation.html . Can anyone see any obvious reasons why this will not work?

 

Regards

AEM

 

<?php
 if ($cart->count_contents() > 0) {
?>
     <tr>
       <td>
<?php
   $info_box_contents = array();
   $info_box_contents[0][] = array('align' => 'center',
                                   'params' => 'class="productListing-heading"',
                                   'text' => TABLE_HEADING_REMOVE);

   $info_box_contents[0][] = array('params' => 'class="productListing-heading"',
                                   'text' => TABLE_HEADING_PRODUCTS);

   $info_box_contents[0][] = array('align' => 'center',
                                   'params' => 'class="productListing-heading"',
                                   'text' => TABLE_HEADING_QUANTITY);

   $info_box_contents[0][] = array('align' => 'right',
                                   'params' => 'class="productListing-heading"',
                                   'text' => TABLE_HEADING_TOTAL);

   $any_out_of_stock = 0;
   $products = $cart->get_products();
   for ($i=0, $n=sizeof($products); $i<$n; $i++) {
// Push all attributes information in an array
     if (isset($products[$i]['attributes']) && is_array($products[$i]['attributes'])) {
       while (list($option, $value) = each($products[$i]['attributes'])) {
         echo tep_draw_hidden_field('id[' . $products[$i]['id'] . '][' . $option . ']', $value);
         $attributes = tep_db_query("select popt.products_options_name, poval.products_options_values_name, pa.options_values_price, pa.price_prefix
                                     from " . TABLE_PRODUCTS_OPTIONS . " popt, " . TABLE_PRODUCTS_OPTIONS_VALUES . " poval, " . TABLE_PRODUCTS_ATTRIBUTES . " pa
                                     where pa.products_id = '" . $products[$i]['id'] . "'
                                      and pa.options_id = '" . $option . "'
                                      and pa.options_id = popt.products_options_id
                                      and pa.options_values_id = '" . $value . "'
                                      and pa.options_values_id = poval.products_options_values_id
                                      and popt.language_id = '" . $languages_id . "'
                                      and poval.language_id = '" . $languages_id . "'");
         $attributes_values = tep_db_fetch_array($attributes);

         $products[$i][$option]['products_options_name'] = $attributes_values['products_options_name'];
         $products[$i][$option]['options_values_id'] = $value;
         $products[$i][$option]['products_options_values_name'] = $attributes_values['products_options_values_name'];
         $products[$i][$option]['options_values_price'] = $attributes_values['options_values_price'];
         $products[$i][$option]['price_prefix'] = $attributes_values['price_prefix'];
       }
     }
   }

   for ($i=0, $n=sizeof($products); $i<$n; $i++) {
     if (($i/2) == floor($i/2)) {
       $info_box_contents[] = array('params' => 'class="productListing-even"');
     } else {
       $info_box_contents[] = array('params' => 'class="productListing-odd"');
     }

     $cur_row = sizeof($info_box_contents) - 1;

     $info_box_contents[$cur_row][] = array('align' => 'center',
                                            'params' => 'class="productListing-data" valign="top"',
                                            'text' => tep_draw_checkbox_field('cart_delete[]', $products[$i]['id']));

     $products_name = '<table border="0" cellspacing="2" cellpadding="2">' .
                      '  <tr>' .
                      '    <td class="productListing-data" align="center"><a href="' . tep_href_link(FILENAME_PRODUCT_INFO, 'products_id=' . $products[$i]['id']) . '">' . tep_image(DIR_WS_IMAGES . $products[$i]['image'], $products[$i]['name'], SMALL_IMAGE_WIDTH, SMALL_IMAGE_HEIGHT) . '</a></td>' .
                      '    <td class="productListing-data" valign="top"><a href="' . tep_href_link(FILENAME_PRODUCT_INFO, 'products_id=' . $products[$i]['id']) . '"><b>' . $products[$i]['name'] . '</b></a>';

     if (STOCK_CHECK == 'true') {
       $stock_check = tep_check_stock($products[$i]['id'], $products[$i]['quantity']);
       if (tep_not_null($stock_check)) {
         $any_out_of_stock = 1;

         $products_name .= $stock_check;
       }
     }

     if (isset($products[$i]['attributes']) && is_array($products[$i]['attributes'])) {
       reset($products[$i]['attributes']);
       while (list($option, $value) = each($products[$i]['attributes'])) {
         $products_name .= '<br><small><i> - ' . $products[$i][$option]['products_options_name'] . ' ' . $products[$i][$option]['products_options_values_name'] . '</i></small>';
       }
     }

     $products_name .= '    </td>' .
                       '  </tr>' .
                       '</table>';

     $info_box_contents[$cur_row][] = array('params' => 'class="productListing-data"',
                                            'text' => $products_name);

     $info_box_contents[$cur_row][] = array('align' => 'center',
                                            'params' => 'class="productListing-data" valign="top"',
                                            'text' => tep_draw_input_field('cart_quantity[]', $products[$i]['quantity'], 'size="4"') . tep_draw_hidden_field('products_id[]', $products[$i]['id']));

     $info_box_contents[$cur_row][] = array('align' => 'right',
                                            'params' => 'class="productListing-data" valign="top"',
                                            'text' => '<b>' . $currencies->display_price($products[$i]['final_price'], tep_get_tax_rate($products[$i]['tax_class_id']), $products[$i]['quantity']) . '</b>');
   }

   new productListingBox($info_box_contents);
?>
       </td>
     </tr>
     <tr>
       <td><?php echo tep_draw_separator('pixel_trans.gif', '100%', '10'); ?></td>
     </tr>
     <tr>
       <td align="right" class="main"><b><?php echo SUB_TITLE_SUB_TOTAL; ?> <?php echo $currencies->format($cart->show_total()); ?></b></td>
     </tr>
<?php
   if ($any_out_of_stock == 1) {
     if (STOCK_ALLOW_CHECKOUT == 'true') {
?>
     <tr>
       <td class="stockWarning" align="center"><br><?php echo OUT_OF_STOCK_CAN_CHECKOUT; ?></td>
     </tr>
<?php
     } else {
?>
     <tr>
       <td class="stockWarning" align="center"><br><?php echo OUT_OF_STOCK_CANT_CHECKOUT; ?></td>
     </tr>
<?php
     }
   }
?>

Share this post


Link to post
Share on other sites
I can't get this to work...

 

I'm using STS, I don't have any other functions going, I've tried to put the onload in my sts_template.htm body tag, but nothing...

 

All I get is a blank cart with the title and the checkout button (http://www.thewardrum.com) It seems to know that items are in the cart but just won't show them.

 

Any ideas anyone?

 

I have the same problem :( Seems to be a conflict with STS.

Any ideas to correct the error would be great!

 

Greetings,

Dreyer

Share this post


Link to post
Share on other sites

Hello, I ask for your help! I have installed Ajax Shopping Cart and everything worked perfectly if Javascript is enabled, but does not work if Javascript is disabled, how can I do?

Thanks to all

Link is Here!

Antonello

LavoriamoPerVoi - PayPTR

Share this post


Link to post
Share on other sites

Hi,

is there an easy way to eliminate completely the "loading please wait" and image when changing somthing? so that it just does nothing until refreshes...

thanks

Share this post


Link to post
Share on other sites

Hi Everyone

 

Not sure if anyone else is having this problem or realised this problem but i am having a very peculiar problem.

 

When you put a tick on the remove box and then untick the tick in the remove box and click anywhere on screen you still get the message asking if you want to remove the item from the cart. Don't think that is right!!!

 

Also the question asking to press ok for remove item should come as soon as you click on remove box rather having to click somewhere on screen. This confuses customer into thinking what to do now after ticking remove.

 

A solution to this would be much appreciated.

Share this post


Link to post
Share on other sites
I recently installed the version of AJAX shopping cart with the attributes support and came across many of the problems reported by others. Since I spent more time trying to fix them than I wanted, I will post my solutions in hopes that it will save others time. (I've tested this on IE7 and Firefox 2.) As a final note, I'm pretty sure that these changes will work for all, but my oscommerce site has so many mods they may not... You can check out the shopping cart at my site to see the result at http://www.chemicalevolution.com

 

1. Updates to quantities box and delete checkbox not updating properly in IE7

 

In GetCart.php replace this:

       $info_box_contents[$cur_row][] = array('align' => 'center',
                                            'params' => 'class="productListing-data" valign="top"',
                                            'text' => 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'].'"'));

 

With this:

      $info_box_contents[$cur_row][] = array('align' => 'center',
                                            'params' => 'class="productListing-data" valign="top"',
                                            'text' => 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_sc.gif alt=loading> Please wait...\', \'rem_' . $products[$i]['id'] . '\', \'' . $products[$i]['id'] . '\');"onclick="this.blur();" id="rem_'.$products[$i]['id'].'"'));

 

and replace this:

      $info_box_contents[$cur_row][] = array('align' => 'center',
                                            'params' => 'class="productListing-data" valign="top"',
                                            'text' => '<a href="java script:sendCartChangeQty(\'' . $products[$i]['id'] . '\', \'getCart.php\',\'' . tep_session_name() . '=' . tep_session_id() . '\',\'span_cart\', \' <img src=images/loading_sc.gif alt=loading> Please wait...<br/>\', \'qty_' . $products[$i]['id'] . '\', \'' . $products[$i]['id'] . '\', -1)">'.tep_image(DIR_WS_IMAGES .'minusBtn.gif').'</a>'.tep_draw_input_field('cart_quantity[]', $products[$i]['quantity'], 'size="4" onChange="sendCartChangeQty(\'' . $products[$i]['id'] . '\', \'getCart.php\',\'' . tep_session_name() . '=' . tep_session_id() . '\',\'span_cart\', \' <img src=images/loading_sc.gif alt=loading> Please wait...<br/>\', \'qty_' . $products[$i]['id'] . '\', \'' . $products[$i]['id'] . '\', 0);" id="qty_'.$products[$i]['id'].'"').'<a href="java script:sendCartChangeQty(\'' . $products[$i]['id'] . '\', \'getCart.php\',\'' . tep_session_name() . '=' . tep_session_id() . '\',\'span_cart\', \' <img src=images/loading_sc.gif alt=loading> Please wait...<br/>\', \'qty_' . $products[$i]['id'] . '\', \'' . $products[$i]['id'] . '\', 1)">'.tep_image(DIR_WS_IMAGES .'plusBtn.gif').'</a>'. tep_draw_hidden_field('products_id[]', $products[$i]['id']));

 

with this:

      $info_box_contents[$cur_row][] = array('align' => 'center',
                                            'params' => 'class="productListing-data" valign="top"',
                                            'text' => '<a href="java script:sendCartChangeQty(\'' . $products[$i]['id'] . '\', \'getCart.php\',\'' . tep_session_name() . '=' . tep_session_id() . '\',\'span_cart\', \' <img src=images/loading_sc.gif alt=loading> Please wait...<br/>\', \'qty_' . $products[$i]['id'] . '\', \'' . $products[$i]['id'] . '\', 1)">'.tep_image(DIR_WS_IMAGES .'plusBtn.gif').'</a>'.tep_draw_input_field('cart_quantity[]', $products[$i]['quantity'], 'size="4" onKeyPress="if((event.keyCode==10)||(event.keyCode==13)) this.blur();" onChange="sendCartChangeQty(\'' . $products[$i]['id'] . '\', \'getCart.php\',\'' . tep_session_name() . '=' . tep_session_id() . '\',\'span_cart\', \' <img src=images/loading_sc.gif alt=loading> Please wait...<br/>\', \'qty_' . $products[$i]['id'] . '\', \'' . $products[$i]['id'] . '\', 0);" id="qty_'.$products[$i]['id'].'"').'<a href="java script:sendCartChangeQty(\'' . $products[$i]['id'] . '\', \'getCart.php\',\'' . tep_session_name() . '=' . tep_session_id() . '\',\'span_cart\', \' <img src=images/loading_sc.gif alt=loading> Please wait...<br/>\', \'qty_' . $products[$i]['id'] . '\', \'' . $products[$i]['id'] . '\', -1)">'.tep_image(DIR_WS_IMAGES .'minusBtn.gif').'</a>'. tep_draw_hidden_field('products_id[]', $products[$i]['id']));

 

2. Shopping cart flashes when quantities being updated caused by extra GET requests.

 

In catalog/shopping_cart.php replace this:

 

			//When our stock change has been sent, update our page.
		function handleSendCart() {
			getCartText('','getCart.php','<?php echo tep_session_name().'='.tep_session_id(); ?>','span_cart',tmp);
			getCartInfoBoxText('','getCartBox.php','<?php echo tep_session_name().'='.tep_session_id(); ?>','span_cart_box',tmp);
		}

 

with this:

 

//When our stock change has been sent, update our page.
function handleSendCart() {
if (sendReq.readyState == 4 && sendReq.status == 200){
 getCartText('','getCart.php','<?php echo tep_session_name().'='.tep_session_id(); ?>','span_cart',tmp);
 getCartInfoBoxText('','getCartBox.php','<?php echo tep_session_name().'='.tep_session_id(); ?>','span_cart_box',tmp);
 }
}

 

and this:

			//When our stock change has been sent, update our page.
		function handleSendCartRemoveItem() {
			getCartText('','getCart.php','<?php echo tep_session_name().'='.tep_session_id(); ?>',loc,tmp);
			getCartInfoBoxText('','getCartBox.php','<?php echo tep_session_name().'='.tep_session_id(); ?>','span_cart_box',tmp);
		}	

 

with this:

 

//When our stock change has been sent, update our page.
function handleSendCartRemoveItem() {
if (sendReq.readyState == 4 && sendReq.status == 200){
 getCartText('','getCart.php','<?php echo tep_session_name().'='.tep_session_id(); ?>',loc,tmp);
 getCartInfoBoxText('','getCartBox.php','<?php echo tep_session_name().'='.tep_session_id(); ?>','span_cart_box',tmp);
 }
}

 

3. Code to verify text entered in quantity box is a number doesn't work:

 

In catalog/shopping_cart.php replace this:

  				if (qty.length > 0) {
			    qty_float = parseFloat(qty);
			    if (isNaN(qty_float)) {
					document.getElementById('p_status').innerHTML = 'Status: You must enter a number for Quantity.';
					return;						
   				}
			} else {
			    qty_float = 1;
 				}

 

with this:

//Verify entered quantity is number
if (isNaN(element.value)) {
 document.getElementById('p_status').innerHTML = 'You must enter a number for Quantity.';
 getCartText(key,file,sid,loc,tmp);
 return;
}
else {
 document.getElementById('p_status').innerHTML = '';
}

 

4. Problems when setting quantity to 0 and prompted to deleted item.

 

In catalog\shopping_cart.php replace this

				// check if Quantity drops below 0
			if  (Number(element.value) + Number(qty) <= 0) {
				// Are you sure you want to remove this item
				var fRet;
				fRet = confirm('Are you sure you want to remove this item from your shopping cart?');
				if (fRet == false) { return; } 
			}

 

with this:

// check if Quantity drops below 0
if (Number(element.value) + Number(qty) <= 0) {
 //Call function to delete item
 sendCartRemoveItem(key,file,sid,loc,tmp,iElementId,product_id);
 return;
}

 

and this:

				// check user wants to remove item
			if  (element.value != '') {
				// Are you sure you want to remove this item
				var fRet;
				fRet = confirm('Are you sure you want to remove this item from your shopping cart?');
				//alert(fRet);
				if (fRet == false) { return; } 
			}

 

with this:

// check user wants to remove item
//if (element.value != '') {
// Are you sure you want to remove this item
var fRet;
fRet = confirm('Are you sure you want to remove this item from your shopping cart?');
//alert(fRet);
if (fRet == false) {
 getCartText(key,file,sid,loc,tmp);
 return;
 }

 

Hope this is useful.

 

 

1st of all thank you a lot ChemEvo, this contrib was useless of course without the ability to remove products, it works like a charm now, however there are 2 typos in the above codes at 2 points you have writter javascript as java script which of course breaked the cart... so I fixed it in my copy think I should update the original doc and post a revision?

Share this post


Link to post
Share on other sites

Hi Everybody:

 

I had the contribution working on Mozilla 2.0. Everything was right but today I upgraded to Mozilla 3.0 and I didn't work, so I have found the ChemEvo code changes, I put them on my shop and everything goes right now...

 

I have updated the contribution with all fixes and code changes included...

 

I have included products weight on shopping cart. It's useful to customers to see the shipping cost if that cost is weight based.

 

Thank you very much ChemEvo and of course... ELIOT, contributor creator. Thanks a lot both...

 

Ana

 

Buenas...

 

Tenía esta impresionante contribución funcionando en Mozilla 2.0 pero al subir a Mozilla 3.0 no funcionaba correctamente. He visto las modificaciones propuestas por ChemEvo y he probado a ver que tal y es estupendo porque vuelve a funcionar todo...

 

He actualizado la contribución con sus cambios y he incluido el peso en el carrito porque esto facilita a los usuarios conocer los gastos de envío.

 

Muchísimas gracias a ChemEvo y por supuesto a ELIOT el creador de la contribución. Gracias a los dos.

 

Saludos!!!

 

Ana

Share this post


Link to post
Share on other sites

Hi,

 

thanks for this very useful contribute.

 

I tried the last version out with IE6, IE7, FF2 and Opera:

After +/- or change the quantity it reloads - display - reloads - display.

The quantity is ever after the second display correct.

 

But I've some trouble with Firefox 3 (this depends on +/- and input):

Case 1:

It reloads and displays only once, the quantity is not changed.

Case 2 and 3:

It reloads and displays tow times like the other browsers, in most cases the quantity is changed than - but less time also not.

 

Is it normal that the reload goes twice?

Has somebody an idea why FF sometimes does not add/sub or change the value?

 

Thanks,

 

Andre

Edited by andre1972

Share this post


Link to post
Share on other sites

Hi to all

 

I install the AJAX shopping Cart 1.3 but i have a problem. When i buy some products and goto the shopping cart, nothing dislpayed here, the shopping cart is empty.

But in shopping cart infobox i see my products.

 

The installation was maked in not fresh install like installation instructions.

 

Can anyone help me?

 

With best regards

Christos Ioannou

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  

×