Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

ChemEvo

Archived
  • Posts

    1
  • Joined

  • Last visited

Profile Information

  • Real Name
    Zach Wagner

ChemEvo's Achievements

  1. 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.
×
×
  • Create New...