Jump to content
Sign in to follow this  
ELIOT

AJAX Shopping Cart

Recommended Posts

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

 

 

I am also suffering from the same problem as outlined above - can anyone kindly assist with this problem?

Share this post


Link to post
Share on other sites
I am also suffering from the same problem as outlined above - can anyone kindly assist with this problem?

 

Hey, Having the same issues, running Mac OS with FireFox 3 and Safari, but the basket never shows up. Did you find an answear?

 

Thanks


Thanking God for a beautiful day??

Share this post


Link to post
Share on other sites

I've installed this contribution about 2 weeks ago. It ran fine after I installed it. Today after spending 2 weeks installing other contributions the cart no longer displays anything. I have not modified shopping_cart.php nor any other files associated with this contribution.

 

Any idea where I can start trying to solve this problem?

 

The shopping cart does not display anything at all with or without java enabled.

 

The original shopping_cart.php works fine.

 

Any help at all will be appreciated. Thanks!

Share this post


Link to post
Share on other sites

Useful contribution but I have found two problems.

When user change qty. of products and next click "checkout" sometimes qty. is changed and sometimes not. I think script should wait and proceed to checkout only when qty is updated.

Second one is similar. When customer change qty of one product and quickly change qty of second product, second change isn't saved. Change of qty of second product should be blocked until first change is saved.

Share this post


Link to post
Share on other sites

1054 - Unknown column 'popt.products_options_track_stock' in 'field list'

 

guys i get this error when i follow the steps...

 

please help.

Share this post


Link to post
Share on other sites

There is a bug in this contribution.

 

If you switch the manufactures in this page, the cart will get empty!!

 

in a fresh install of osc + this contribution. Click on DVD movies => Comedy, then switch the manufactures in:

 

Let's See What We Have Here Show: ALL Manufactures

FOX

Warners

 

 

I hope you will fix this bug guys.

Share this post


Link to post
Share on other sites

Hi i followed the steps one by one at last i got this error on the shopping_cart.php

 

 

Parse error: syntax error, unexpected '<' in W:\www\catalog\includes\boxes\shopping_cart.php on line 82

 

I think it is because of the last step, there must be an error in the install instructions.

 

4) Open catalog/includes/boxes/shopping_cart.php (all that i'm doing here is putting a span tag around the shopping cart info box <span id="span_cart_box">)

Find (now around line 13 on a fresh ms2)

 

<!-- shopping_cart //-->

<tr>

<td>

 

Replace With

 

<!-- shopping_cart //-->

<tr>

<td>

 

<!-- BOE: ERSD.net AJAX Shopping Cart -->

<span id="span_cart_box">

<!-- EOE: ERSD.net AJAX Shopping Cart -->

 

Find (now around line 65 on a fresh ms2)

 

?>

</td>

</tr>

<!-- shopping_cart_eof //-->

 

Replace With

 

<!-- BOE: ERSD.net AJAX Shopping Cart --> this is line 82

 

</span>

<!-- EOE: ERSD.net AJAX Shopping Cart -->

</td>

</tr>

<!-- shopping_cart_eof //-->

 

 

anyone know how to fix this please?

Edited by celina2007

Share this post


Link to post
Share on other sites
Hi i followed the steps one by one at last i got this error on the shopping_cart.php

 

 

CODE

Parse error: syntax error, unexpected '<' in W:\www\catalog\includes\boxes\shopping_cart.php on line 82

 

 

well i figured out the parse error

 

 

but still this contribution doesn't work with STS. it shows an empty shopping cart page with only CHECKOUT button; i will inform BILL KULLEM about it.

Share this post


Link to post
Share on other sites

Where can i find the needed info to make this cart support attributes ?

 

Best Regards

Kasper Hvid Voldstedlund

www.plejeprodukter.dk

Share this post


Link to post
Share on other sites

mmm not sure if to add this or not

Edited by steve_s

Share this post


Link to post
Share on other sites

Great Contribution works perfectly on my Site.

 

But since I installed Dynamenu the /catalog/shopping_cart.php doesn't show my cart, ie. it only displays "What's In My Cart?" with the continue shopping & checkout buttons.

 

 

 

Any1 know how to fix this?

 

Dynamenu only alters Header with:

include(DIR_WS_BOXES . 'dm_categories.php');

 

and only the Footer with:

echo $GLOBALS['dmfooter'];

 

It worked 100% before dynamenu and when I change the HEader edit to "<?php //include(DIR_WS_BOXES . 'dm_categories.php'); ?>" it works perfectly.

Edited by Stephan (VS)

"I have no special talent. I am only passionately curious"

- Albert Einstein

Share this post


Link to post
Share on other sites

STS + Ajax Cart solution:

 

The problem is than onload function is not present on STS generated HTML. The solution is to add the onload with javascript :

 

Open shopping_cart.php

 

Change

 

<body onLoad="java script:startCart('','getCart.php','<?php echo tep_session_name().'='.tep_session_id(); ?>');" marginwidth="0" marginheight="0" topmargin="0" bottommargin="0" leftmargin="0" rightmargin="0">

 

with

 

<body marginwidth="0" marginheight="0" topmargin="0" bottommargin="0" leftmargin="0" rightmargin="0">

<script type="text/javascript">

var backupOnload = window.onload; // Let's save the existing assignment, if any

window.onload = function () {

startCart('','getCart.php','<?php echo tep_session_name().'='.tep_session_id();?>');

if(backupOnload != null && typeof(backupOnload) == 'function') {

backupOnload();

}

};

</script>

 

And, this is all. Should I add this to module page?

 

Ciao,

Jordi Berges

Share this post


Link to post
Share on other sites
Parse error: syntax error, unexpected '{' in ***catalog/shopping_cart.php on line 275

using OSc ra2a.

try the manual install in install.html file

Share this post


Link to post
Share on other sites

I am trying to use the shipping Estimator and move into the ajax side of the shipping page. I am having a little difficulty on the changes for the shipping price on the different options. The code I have is

<?php
/*
This is the PHP backend file for the AJAX Driven shopping cart.

You may use this code in your own projects as long as this copyright is left
in place.  All code is provided AS-IS.
This code is distributed in the hope that it will be useful,
	but WITHOUT ANY WARRANTY; without even the implied warranty of
	MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

Copyright 2005 Eliot Rayner / ersd.net.
*/

require("includes/application_top.php");
// make sure we set the right character set
header('Content-type: text/html; charset='.CHARSET);

require(DIR_WS_LANGUAGES . $language . '/' . FILENAME_SHOPPING_CART);

//Check to ensure the user is in the Shoping Cart.
if(!isset($_GET['Cart'])) {
echo "<b>Not in Cart session !! </b></br>";
} else {

// Check to see if item should be removed
if(isset($_POST['cart_delete']) && $_POST['cart_delete'] != '' && isset($_POST['products_id']) && $_POST['products_id'] != '') {
// customer wants to remove the product from their shopping cart
$cart->remove($_POST['products_id']);
}

//Check to see if a ChangeQty was sent.
if(isset($_POST['quantity']) && $_POST['quantity'] != '' && isset($_POST['products_id']) && $_POST['products_id'] != '') {
// customer wants to update the product quantity in their shopping cart

// customer wants to update the product quantity in their shopping cart
 // attributes are working now - update by Kavita Aggarwal
         $prid = $_POST['products_id'];
      $attributes = explode('{', substr($prid, strpos($prid, '{')+1));

         for ($i=0, $n=sizeof($attributes); $i<$n; $i++) {
           $pair = explode('}', $attributes[$i]);

           if (is_numeric($pair[0]) && is_numeric($pair[1])) {
             $HTTP_POST_VARS['id'][$pair[0]] .= $pair[1];
           } 
         }

$cart->add_cart($_POST['products_id'], $_POST['quantity'], $HTTP_POST_VARS['id'], false);
// attributes are working now - update by Kavita Aggarwal
}

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

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

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

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

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

   $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, popt.products_options_track_stock, 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 = '" . (int)$products[$i]['id'] . "'
                                      and pa.options_id = '" . (int)$option . "'
                                      and pa.options_id = popt.products_options_id
                                      and pa.options_values_id = '" . (int)$value . "'
                                      and pa.options_values_id = poval.products_options_values_id
                                      and popt.language_id = '" . (int)$languages_id . "'
                                      and poval.language_id = '" . (int)$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'];
	  $products[$i][$option]['track_stock'] = $attributes_values['products_options_track_stock'];
       }
     }
   }

   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'], '','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'].'"'));


     $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') {
       if (isset($products[$i]['attributes']) && is_array($products[$i]['attributes'])) {
         $stock_check = tep_check_stock($products[$i]['id'], $products[$i]['quantity'], $products[$i]['attributes']); 
       }else{
	$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('align' => 'center',
                                        	'params' => 'class="productListing-data" valign="top"',
										 'text' => '<a href="javascript: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="javascript: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']));

     $info_box_contents[$cur_row][] = array('align' => 'left',
                                            'params' => 'class="productListing-data" valign="top"',
                                            'text' => '<a href="' . tep_href_link(FILENAME_PRODUCT_INFO, 'products_id=' . $products[$i]['id']) . '">' . $products[$i]['model'] . '</a>');

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

     $peso_total = $products[$i]['quantity'] * $products[$i]['weight'];
     /*$info_box_contents[$cur_row][] = array('align' => 'center',
                                            'params' => 'class="productListing-data" valign="top"',
                                            'text' => '<b>' .  $peso_total . TEXT_PRODUCT_WEIGTH . ' </b>');*/

     $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>');
}
if (CARTSHIP_ONOFF == 'Disabled') {
$info_box_contents[] = array('align' => 'right',
							 'params' => 'colspan="5" class="main"',
							 'text' => '<br/><b>' . SUB_TITLE_SUB_TOTAL . $currencies->format($cart->show_total()) . '</b>');}

   if ($any_out_of_stock == 1) {
  if (STOCK_ALLOW_CHECKOUT == 'true') {
	  $info_box_contents[] = array('align' => 'center',
								 'params' => 'colspan="5" class="stockWarning"',
								 'text' => '<br/><b>' . OUT_OF_STOCK_CAN_CHECKOUT . '</b>');
     } else {
	  $info_box_contents[] = array('align' => 'center',
								 'params' => 'colspan="5" class="stockWarning"',
								 'text' => '<br/><b>' . OUT_OF_STOCK_CANT_CHECKOUT . '</b>');
     }
   }

   new productListingBox($info_box_contents);
}

if (CARTSHIP_ONOFF == 'Enabled') {
 require(DIR_WS_LANGUAGES . $language . '/modules/' . FILENAME_SHIPPING_ESTIMATOR);

if (($cart->count_contents() > 0)) {

 // shipping cost
 require('includes/classes/http_client.php'); // shipping in basket

 //if($cart->get_content_type() !== 'virtual') {
   if (tep_session_is_registered('customer_id')) {
     // user is logged in
     if (isset($HTTP_POST_VARS['address_id'])){
       // user changed address
       $sendto = $HTTP_POST_VARS['address_id'];
     }elseif (tep_session_is_registered('cart_address_id')){
       // user once changed address
       $sendto = $HTTP_POST_VARS['cart_address_id'];
     }else{
       // first timer
       $sendto = $HTTP_POST_VARS['customer_default_address_id'];
     }
     // set session now
     $cart_address_id = $sendto;
     tep_session_register('cart_address_id');
     // set shipping to null ! multipickup changes address to store address...
     $shipping='';
     // include the order class (uses the sendto !)
     require(DIR_WS_CLASSES . 'order.php');
     $order = new order;
   }else{
// user not logged in !
     if (isset($HTTP_POST_VARS['country_id'])){
       // country is selected
       $country_info = tep_get_countries($HTTP_POST_VARS['country_id'],true);
       $cache_state_prov_values = tep_db_fetch_array(tep_db_query("select zone_code from " . TABLE_ZONES . " where zone_country_id = '" . $HTTP_POST_VARS['country_id'] . "' and zone_id = '" . $HTTP_POST_VARS['state'] . "'"));
       $cache_state_prov_code = $cache_state_prov_values['zone_code'];
       $order->delivery = array('postcode' => $HTTP_POST_VARS['zip_code'],
                                'state' => $cache_state_prov_code,
                                'country' => array('id' => $HTTP_POST_VARS['country_id'], 'title' => $country_info['countries_name'], 'iso_code_2' => $country_info['countries_iso_code_2'], 'iso_code_3' =>  $country_info['countries_iso_code_3']),
                                'country_id' => $HTTP_POST_VARS['country_id'],
//add state zone_id
                                'zone_id' => $HTTP_POST_VARS['state'],
                                'format_id' => tep_get_address_format_id($HTTP_POST_VARS['country_id']));
       $cart_country_id = $HTTP_POST_VARS['country_id'];
       tep_session_register('cart_country_id');
//add state zone_id
       $cart_zone = $HTTP_POST_VARS['zone_id'];
       tep_session_register('cart_zone');
       $cart_zip_code = $HTTP_POST_VARS['zip_code'];
       tep_session_register('cart_zip_code');
     }elseif (tep_session_is_registered('cart_country_id')){
       // session is available
       $country_info = tep_get_countries($cart_country_id,true);
       $order->delivery = array('postcode' => $cart_zip_code,
                                'country' => array('id' => $cart_country_id, 'title' => $country_info['countries_name'], 'iso_code_2' => $country_info['countries_iso_code_2'], 'iso_code_3' =>  $country_info['countries_iso_code_3']),
                                'country_id' => $cart_country_id,
                                'format_id' => tep_get_address_format_id($cart_country_id));
     } else {
       // first timer
       $cart_country_id = STORE_COUNTRY;
       tep_session_register('cart_country_id');
       $country_info = tep_get_countries(STORE_COUNTRY,true);
       tep_session_register('cart_zip_code');
       $order->delivery = array(//'postcode' => '',
                                'country' => array('id' => STORE_COUNTRY, 'title' => $country_info['countries_name'], 'iso_code_2' => $country_info['countries_iso_code_2'], 'iso_code_3' =>  $country_info['countries_iso_code_3']),
                                'country_id' => STORE_COUNTRY,
                                'format_id' => tep_get_address_format_id($HTTP_POST_VARS['country_id']));
     }
     // set the cost to be able to calculate free shipping
     $order->info = array('total' => $cart->show_total(), // TAX ????
                          'currency' => $currency,
                          'currency_value'=> $currencies->currencies[$currency]['value']);
   }
// weight and count needed for shipping
   $total_weight = $cart->show_weight();
   $total_count = $cart->count_contents();
   require(DIR_WS_CLASSES . 'shipping.php');
   $shipping_modules = new shipping;
   $quotes = $shipping_modules->quote();
   $order->info['subtotal'] = $cart->total;

// set selections for displaying
   $selected_country = $order->delivery['country']['id'];
   $selected_address = $sendto;
 //}
// eo shipping cost

 // check free shipping based on order total
 if ( defined('MODULE_ORDER_TOTAL_SHIPPING_FREE_SHIPPING') && (MODULE_ORDER_TOTAL_SHIPPING_FREE_SHIPPING == 'true')) {
   switch (MODULE_ORDER_TOTAL_SHIPPING_DESTINATION) {
     case 'national':
       if ($order->delivery['country_id'] == STORE_COUNTRY) $pass = true; break;
     case 'international':
       if ($order->delivery['country_id'] != STORE_COUNTRY) $pass = true; break;
     case 'both':
       $pass = true; break;
     default:
       $pass = false; break;
   }
   $free_shipping = false;
   if ( ($pass == true) && ($order->info['total'] >= MODULE_ORDER_TOTAL_SHIPPING_FREE_SHIPPING_OVER)) {
     $free_shipping = true;
     include(DIR_WS_LANGUAGES . $language . '/modules/order_total/ot_shipping.php');
   }
 } else {
   $free_shipping = false;
 }
 // begin shipping cost
 if(!$free_shipping && $cart->get_content_type() !== 'virtual'){
   if (tep_not_null($HTTP_POST_VARS['sid'])){
     list($module, $method) = explode('_', $HTTP_POST_VARS['sid']);
     $cart_sid = $HTTP_POST_VARS['sid'];
     tep_session_register('cart_sid');
   }elseif (tep_session_is_registered('cart_sid')){
     list($module, $method) = explode('_', $cart_sid);
   }else{
     $module="";
     $method="";
   }
   if (tep_not_null($module)){
     $selected_quote = $shipping_modules->quote($method, $module);
     if($selected_quote[0]['error'] || !tep_not_null($selected_quote[0]['methods'][0]['cost'])){
       $selected_shipping = $shipping_modules->cheapest();
       $order->info['shipping_method'] = $selected_shipping['title'];
       $order->info['shipping_cost'] = $selected_shipping['cost'];
       $order->info['total']+= $selected_shipping['cost'];
     }else{
       $order->info['shipping_method'] = $selected_quote[0]['module'].' ('.$selected_quote[0]['methods'][0]['title'].')';
       $order->info['shipping_cost'] = $selected_quote[0]['methods'][0]['cost'];
       $order->info['total']+= $selected_quote[0]['methods'][0]['cost'];
       $selected_shipping['title'] = $order->info['shipping_method'];
       $selected_shipping['cost'] = $order->info['shipping_cost'];
       $selected_shipping['id'] = $selected_quote[0]['id'].'_'.$selected_quote[0]['methods'][0]['id'];
     }
   }else{
     $selected_shipping = $shipping_modules->cheapest();
     $order->info['shipping_method'] = $selected_shipping['title'];
     $order->info['shipping_cost'] = $selected_shipping['cost'];
     $order->info['total']+= $selected_shipping['cost'];
   }
 }
// virtual products use free shipping
 if($cart->get_content_type() == 'virtual') {
   $order->info['shipping_method'] = CART_SHIPPING_METHOD_FREE_TEXT . ' ' . CART_SHIPPING_METHOD_ALL_DOWNLOADS;
   $order->info['shipping_cost'] = 0;
 }
 if($free_shipping) {
   $order->info['shipping_method'] = MODULE_ORDER_TOTAL_SHIPPING_TITLE;
   $order->info['shipping_cost'] = 0;
 }
 $shipping=$selected_shipping;
// end of shipping cost
// end free shipping based on order total

 $info_box_contents = array();
 $info_box_contents[] = array('text' => '<b>' . CART_SHIPPING_OPTIONS . '</b>'); // azer for 2.20 cosmetic change
 new infoBoxHeading($info_box_contents, false, false);

 $ShipTxt= tep_draw_form('estimator', tep_href_link(FILENAME_SHOPPING_CART, '', 'NONSSL'), 'post'); //'onSubmit="return check_form();"'
 $ShipTxt.=tep_draw_hidden_field('sid', $selected_shipping['id']);
 $ShipTxt.='<table>';
 if(sizeof($quotes)) {
   if (tep_session_is_registered('customer_id')) {
     // logged in

 if (CARTSHIP_SHOWWT == 'true') {
   $showweight = ' (' . $total_weight . ' ' . CARTSHIP_WTUNIT . ')';
 } else {
   $showweight = '';
 }

       if(CARTSHIP_SHOWIC == 'true'){
     //ishazer remover hard code for version 2.20 : $ShipTxt.='<tr><td class="main">' . ($total_count == 1 ? ' <b>Item:</b></td><td colspan="2" class="main">' : ' <b>' . CART_ITEM . '</b></td><td colspan="2" class="main">') . $total_count . $showweight . '</td></tr>';
     $ShipTxt.='<tr><td class="main">' . ($total_count == 1 ? ' <b>' . CART_ITEM . '</b></td><td colspan="2" class="main">' : ' <b>' . CART_ITEM . '</b></td><td colspan="2" class="main">') . $total_count . $showweight . '</td></tr>';

      }
     $addresses_query = tep_db_query("select address_book_id, entry_city as city, entry_postcode as postcode, entry_state as state, entry_zone_id as zone_id, entry_country_id as country_id from " . TABLE_ADDRESS_BOOK . " where customers_id = '" . $customer_id . "'");
     // only display addresses if more than 1
     if (tep_db_num_rows($addresses_query) > 1){
       while ($addresses = tep_db_fetch_array($addresses_query)) {
         $addresses_array[] = array('id' => $addresses['address_book_id'], 'text' => tep_address_format(tep_get_address_format_id($addresses['country_id']), $addresses, 0, ' ', ' '));
       }
       $ShipTxt.='<tr><td colspan="3" class="main" nowrap>' .
                 CART_SHIPPING_METHOD_ADDRESS .' '. tep_draw_pull_down_menu('address_id', $addresses_array, $selected_address, 'onchange="return shipincart_submit(\'\');"').'</td></tr>';
     }
     $ShipTxt.='<tr valign="top"><td class="main"><b>' . CART_SHIPPING_METHOD_TO .'</b> </td><td colspan="2" class="main">'. tep_address_format($order->delivery['format_id'], $order->delivery, 1, ' ', '<br>') . '</td></tr>';

   } else {
// not logged in
     $ShipTxt.=CART_SHIPPING_OPTIONS_LOGIN;

       if(CARTSHIP_SHOWIC == 'true'){
//azer for 2.20:      $ShipTxt.='<tr><td class="main">' . ($total_count == 1 ? ' <b>Item:</b></td><td colspan="2" class="main">' : ' <b>Items:</b></td><td colspan="2" class="main">') . $total_count . $showweight . '</td></tr>';
             $ShipTxt.='<tr><td class="main" nowrap>' . ($total_count == 1 ? ' <b>' . CART_ITEM . '</b></td><td colspan="2" class="main" nowrap>' : ' <b>' . CART_ITEM . '</b></td><td colspan="2" class="main">') . $total_count . $showweight . '</td></tr>';

      }

     if($cart->get_content_type() != 'virtual'){

       if(CARTSHIP_SHOWCDD == 'true'){
       $ShipTxt.='<tr><td colspan="3" class="main" nowrap>' .
                 ENTRY_COUNTRY .' '. tep_get_country_list('country_id', $selected_country,'style="width=200"').'<br />';
       }

//add state zone_id
       $state_array[] = array('id' => '', 'text' => 'Please Select');
       $state_query = tep_db_query("select zone_name, zone_id from " . TABLE_ZONES . " where zone_country_id = '$selected_country' order by zone_country_id DESC, zone_name");
       while ($state_values = tep_db_fetch_array($state_query)) {
         $state_array[] = array('id' => $state_values['zone_id'],
                                'text' => $state_values['zone_name']);
       }

       if(CARTSHIP_SHOWSDD == 'true'){
        $ShipTxt.=ENTRY_STATE .' '. tep_draw_pull_down_menu('state',$state_array).'<br />';
       }

       if(CARTSHIP_SHOWZDD == 'true'){
         $ShipTxt.=ENTRY_POST_CODE .' '. tep_draw_input_field('zip_code', $selected_zip, 'size="5"');
       }
//        $ShipTxt.=' <a href="_" onclick="return shipincart_submit(\'\');">'.CART_SHIPPING_METHOD_RECALCULATE.'</a></td></tr>';

       if(CARTSHIP_SHOWUB == 'true'){
$ShipTxt.=' <td><a href="_" onclick="return shipincart_submit(\'\');">'. tep_image_button('button_update_cart.gif', IMAGE_BUTTON_UPDATE_CART) . ' </a></td></td></tr>';
       }
       }
   }
   if($cart->get_content_type() == 'virtual'){
     // virtual product-download
     //$ShipTxt.='<tr><td colspan="3" class="main">'.tep_draw_separator().'</td></tr>';
     $ShipTxt.='<tr><td class="main" colspan="3"> </td></tr><tr><td class="main" colspan="3"><i>' . CART_SHIPPING_METHOD_FREE_TEXT . ' ' . CART_SHIPPING_METHOD_ALL_DOWNLOADS . '</i></td></tr>';
   }elseif ($free_shipping==1) {
     // order $total is free
     //$ShipTxt.='<tr><td colspan="3" class="main">'.tep_draw_separator().'</td></tr>';
     $ShipTxt.='<tr><td class="main" colspan="3"> </td></tr><tr><td class="main" colspan="3"><i>' . sprintf(FREE_SHIPPING_DESCRIPTION, $currencies->format(MODULE_ORDER_TOTAL_SHIPPING_FREE_SHIPPING_OVER)) . '</i></td><td> </td></tr>';
   }else{
     // shipping display
  if ( empty($quotes[0]['error']) || (!empty($quotes[1])&∅($quotes[1]['error'])) ) {
       $ShipTxt.='<tr><td colspan="3" class="main"> </td></tr><tr><td class="main"><b>' . CART_SHIPPING_CARRIER_TEXT . '</b></td><td class="main" align="left"><b>' . CART_SHIPPING_METHOD_TEXT . '</b></td><td class="main" align="right"><b>' . CART_SHIPPING_METHOD_RATES . '</b></td></tr>';
       $ShipTxt.='<tr><td colspan="3" class="main">'.tep_draw_separator().'</td></tr>';
  } else {
    $ShipTxt.='<tr><td colspan="3" class="main"> </td></tr>';
  }
     for ($i=0, $n=sizeof($quotes); $i<$n; $i++) {
       if(sizeof($quotes[$i]['methods'])==1){
         // simple shipping method
         $thisquoteid = $quotes[$i]['id'].'_'.$quotes[$i]['methods'][0]['id'];
         $ShipTxt.= '<tr class="'.$extra.'">';
         $ShipTxt.='<td class="main">'.$quotes[$i]['icon'].'   </td>';
         if($quotes[$i]['error']){
           $ShipTxt.='<td colspan="2" class="main">'.$quotes[$i]['module'].' ';
           $ShipTxt.= '('.$quotes[$i]['error'].')</td></tr>';
         }else{
           if($selected_shipping['id'] == $thisquoteid){
            // commented for v2.10 : $ShipTxt.='<td class="main"><a title="Select this method" href="_"  onclick="return shipincart_submit(\''.$thisquoteid.'\');"><b>'.$quotes[$i]['module'].' ';
$ShipTxt.='<td class="main"><a title="' . CART_SELECT_THIS_METHOD .'" href="shopping_cart.php"  onclick="return shipincart_submit(\''.$thisquoteid.'\');"><b>'.$quotes[$i]['module'].' ';

             $ShipTxt.= '('.$quotes[$i]['methods'][0]['title'].')</b></a>   </td><td align="right" class="main"><b>'.$currencies->format(tep_add_tax($quotes[$i]['methods'][0]['cost'], $quotes[$i]['tax'])).'</b></td></tr>';
           }else{
            // commented for v2.10 : $ShipTxt.='<td class="main"><a title="Select this method" href="_" onclick="return shipincart_submit(\''.$thisquoteid.'\');">'.$quotes[$i]['module'].' ';
$ShipTxt.='<td class="main"><a title="' . CART_SELECT_THIS_METHOD .'" href="shopping_cart.php" onclick="return shipincart_submit(\''.$thisquoteid.'\');">'.$quotes[$i]['module'].' ';

             $ShipTxt.= '('.$quotes[$i]['methods'][0]['title'].')</a>   </td><td align="right" class="main">'.$currencies->format(tep_add_tax($quotes[$i]['methods'][0]['cost'], $quotes[$i]['tax'])).'</td></tr>';
           }
         }
       } else {
         // shipping method with sub methods (multipickup)
         for ($j=0, $n2=sizeof($quotes[$i]['methods']); $j<$n2; $j++) {
           $thisquoteid = $quotes[$i]['id'].'_'.$quotes[$i]['methods'][$j]['id'];
           $ShipTxt.= '<tr class="'.$extra.'">';
           $ShipTxt.='<td class="main">'.$quotes[$i]['icon'].'   </td>';
           if($quotes[$i]['error']){
             $ShipTxt.='<td colspan="2" class="main">'.$quotes[$i]['module'].' ';
             $ShipTxt.= '('.$quotes[$i]['error'].')</td></tr>';
           }else{
             if($selected_shipping['id'] == $thisquoteid){
              // commented for v2.10 :  $ShipTxt.='<td class="main"><a title="Select this method" href="_" onclick="return shipincart_submit(\''.$thisquoteid.'\');"><b>'.$quotes[$i]['module'].' ';
$ShipTxt.='<td class="main"><a title="' . CART_SELECT_THIS_METHOD .'" href="shopping_cart.php" onclick="return shipincart_submit(\''.$thisquoteid.'\');"><b>'.$quotes[$i]['module'].' ';

               $ShipTxt.= '('.$quotes[$i]['methods'][$j]['title'].')</b></a>   </td><td align="right" class="main"><b>'.$currencies->format(tep_add_tax($quotes[$i]['methods'][$j]['cost'], $quotes[$i]['tax'])).'</b></td><td class="main">'.tep_image(DIR_WS_ICONS . 'selected.gif', 'Selected').'</td></tr>';
             }else{
             // commented for v2.10 :   $ShipTxt.='<td class="main"><a title="Select this method" href="_" onclick="return shipincart_submit(\''.$thisquoteid.'\');">'.$quotes[$i]['module'].' ';
$ShipTxt.='<td class="main"><a title="' . CART_SELECT_THIS_METHOD .'" href="shopping_cart.php" onclick="return shipincart_submit(\''.$thisquoteid.'\');">'.$quotes[$i]['module'].' ';

               $ShipTxt.= '('.$quotes[$i]['methods'][$j]['title'].')</a>   </td><td align="right" class="main">'.$currencies->format(tep_add_tax($quotes[$i]['methods'][$j]['cost'], $quotes[$i]['tax'])).'</td><td class="main"> </td></tr>';
             }
           }
         }
       }
     }
   }
 }
 $ShipTxt.= '</table></form>';

 $info_box_contents = array();
 $info_box_contents[] = array('text' => $ShipTxt);
 new infoBox($info_box_contents);

 if (CARTSHIP_SHOWOT == 'true'){
   // BOF get taxes if not logged in
   if (!tep_session_is_registered('customer_id')){
     $products = $cart->get_products();
     for ($i=0, $n=sizeof($products); $i<$n; $i++) {
       $products_tax = tep_get_tax_rate($products[$i]['tax_class_id'], $order->delivery['country_id'],$order->delivery['zone_id']);
       $products_tax_description = tep_get_tax_description($products[$i]['tax_class_id'], $order->delivery['country_id'], $order->delivery['zone_id']);
       if (DISPLAY_PRICE_WITH_TAX == 'true') {
        //Modified by Strider 42 to correct the tax calculation when a customer is not logged in
        // $tax_val = ($products[$i]['final_price']-(($products[$i]['final_price']*100)/(100+$products_tax)))*$products[$i]['quantity'];
         $tax_val = (($products[$i]['final_price']/100)*$products_tax)*$products[$i]['quantity'];
       } else {
         $tax_val = (($products[$i]['final_price']*$products_tax)/100)*$products[$i]['quantity'];
       }
       $order->info['tax'] += $tax_val;
       $order->info['tax_groups']["$products_tax_description"] += $tax_val;
       // Modified by Strider 42 to correct the order total figure when shop displays prices with tax
       if (DISPLAY_PRICE_WITH_TAX == 'true') {
          $order->info['total'];
       } else {
       $order->info['total']+=$tax_val;
              }
     }
   }
   // EOF get taxes if not logged in (seems like less code than in order class)
if (CARTSHIP_ORTOTAL == 'true') {
   require(DIR_WS_CLASSES . 'order_total.php');
   $order_total_modules = new order_total;
   echo '<table align="right"><td align="right">';
   // order total code
   $order_total_modules->process();

   $info_box_contents = array();
 $info_box_contents[] = array('text' => '<b>' . CART_OT . '</b>'); //azer version 2.20

   new infoBoxHeading($info_box_contents, false, false);
   $otTxt='<table align="right">';
   $otTxt.=$order_total_modules->output().'</table>';

   $info_box_contents = array();
   $info_box_contents[] = array('text' => $otTxt);

   new infoBox($info_box_contents);
 }
 }
} // Use only when cart_contents > 0
}
?>

There was some Java code but not sure were to put it.

 

<!-- shipping_estimator //-->
<script language="JavaScript">
 function shipincart_submit(sid){
   if(sid){
     document.estimator.sid.value=sid;
   }
   document.estimator.submit();
   return false;
 }
</script>

Share this post


Link to post
Share on other sites

Hi

 

Thanks for this contribution I hoping to get it working for me.

I am using Merchant v2.2 RC2a. with no extra additions to this file shopping_cart.php

When I try to add a product to the shopping cart that has options I get this error message.

 

1054 - Unknown column 'popt.products_options_track_stock' in 'field list'

 

select popt.products_options_name, popt.products_options_track_stock, poval.products_options_values_name, pa.options_values_price, pa.price_prefix from products_options popt, products_options_values poval, products_attributes pa where pa.products_id = '1' and pa.options_id = '4' and pa.options_id = popt.products_options_id and pa.options_values_id = '1' and pa.options_values_id = poval.products_options_values_id and popt.language_id = '1' and poval.language_id = '1'

 

[TEP STOP]

 

any ideas? I'd love to get this working.

 

Cheers Chad

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  

×