Jump to content
ednique

[Contribution] Ship In Cart

Recommended Posts

Yea Devon, I am having the same problems and have not had time to really work it out yet. I will post any progress I make as soon as I do make some. Apparently, we are a bit alone in having problems with this mod, I seems to wrk great for everyone else. LOL!!!

 

Craig :)


Happy Coding!

Craig Garrison Sr

Anything worth having, is worth working for.

Multi Vendor Shipping V1.1 Demo Catalog

3 Vendors, each category, "buy" a product from each category to see how MVS works during checkout.

Multi Vendor Shipping V1.1 Demo Admin

login: webmaster@blucollarsales.com

pass: mvs_demo

MVS Thread:

Multi-Vendor Shipping

My contribs:

Download Multi Vendor Shipping V1.1

Vendor Email

Vendor Info in easypopulate

EZ Price Updater

And more to come!

Share this post


Link to post
Share on other sites

Hello!

 

First, I would like also to thank all involved with this not just wonderful, but in my mind, necessary - contribution.

 

Second, I have read through this entire posting, and still have a bit of a problem with one small area, having to do with another contribution & SIC.

 

I have installed Didier Debbaut's v1.9 on MS2 2.2. I also have PWA as well as many other great contributions, and too I have changed the Zip/Post code position to come after State in (catalog/create_account.php, catalog/includes/modules/address_book_details.php, catalog/includes/modules/checkout_new_address.php - catalog/admin/customers.php).

 

I am using IE 6.0.

 

My difficulty:

 

When using any of the standard shipping modules, all works as it should - when signed in, or not signed in.

When using another wonderful shipping contribution, (regions3.0 - http://www.oscommerce.com/community/contri...Shipping+Module - http://forums.oscommerce.com/viewtopic.php?t=29585) Ship In Cart works as it should when signed in, BUT will not work when NOT signed in. When NOT signed in Ship In Cart will pick up both the (Free shipping over a certain amount) setting, and the tax zone setting, BUT - NOT the shipping settings of the (regions3.0) contribution, which it DOES pick up when signed in.

 

I am thinking that there is something, which all of the standard osCommerce shipping modules have in them that is different from many of the shipping contributions I have tried, as all of the several different shipping module contributions I have tried produce the same result as does regions.php.

 

I was wondering if anyone might know of why? I know very little about all this. And, though I am not a novice to HTML, I only know enough to be dangerous to myself when it comes to php & programming.

 

If anyone has the time to take a look, any thoughts/input would be much appreciated.

 

Here is the regions.php shipping module file involved:

 

<?php

/*

$Id: regions.php, v 1.0 2002/12/15 14:29:56 Jorge Exp $

Based upon zones.php by wilt, written for:

osCommerce, Open Source E-Commerce Solutions
http://www.oscommerce.com
Copyright (c) 2002 osCommerce
Released under the GNU General Public License

-----------------------------------------------------------------------------
REGIONS -  Rates Based on State or Regions (group of States) module for osC 2.2-CVS (new checkout)
 
This module allows you create shipping regions by dividing states of the USA (or other country) in different groups. Each group will then have it's own shipping price which you can based on price or weight. 

This module is perfect when for those of you need to charge different when shipping to different parts of the country.

Features
1..Regions can be composed of US States or of any other country
2..Order weight or price can be used to calculate shipping price.
3..Any number of regions
4..Handling fee can be added.

Jorge

Set the number of regions you need with
$this->regions = xx;  

Please note that any country / state that is not in one of the groups
will not be able to checkout if this the only shipping you provide.
However it will display a nice message saying so.



Written by Jorge (billythekid_2000@hotmail.com)

*/

class regions {
  var $code, $title, $description, $enabled, $regions;

// class constructor
  function regions() {
    $this->code = 'regions';
    $this->title = MODULE_SHIPPING_REGIONS_TEXT_TITLE;
    $this->description = MODULE_SHIPPING_REGIONS_TEXT_DESCRIPTION;
    $this->icon = DIR_WS_ICONS . 'shipping_amtrak.gif';
    $this->tax_class = MODULE_SHIPPING_REGIONS_TAX_CLASS;
    $this->enabled = MODULE_SHIPPING_REGIONS_STATUS;
    // CUSTOMIZE THIS SETTING FOR THE NUMBER OF States NEEDED
    $this->regions = 5;
  }

// class methods
  function quote($method = '') {
    global $order, $shipping_weight, $cart, $total_count;
    
    if (MODULE_SHIPPING_REGIONS_MODE == 'price') {
      $order_total_price = $cart->show_total();
    } 
    if (MODULE_SHIPPING_REGIONS_MODE == 'weight') {
      $order_total_price = $shipping_weight;
    }
    if (MODULE_SHIPPING_REGIONS_MODE == 'per_item') {
      $order_total_price = $total_count;
    }      

    $dest_state = $order->delivery['state'];
    $dest_country = $order->delivery['country']['title'];
    
    $dest_region = 0;
    $error = false;

    for ($i=1; $i<=$this->regions; $i++) {
      $regions_table = constant('MODULE_SHIPPING_REGIONS' . $i);
      $country_states_or_countries = split("[,]", $regions_table);
      if (in_array($dest_state, $country_states_or_countries)) {
        $dest_region = $i;
        break;
      }
    }
    if ($dest_region == 0) {
     for ($i=1; $i<=$this->regions; $i++) {
       $regions_table = constant('MODULE_SHIPPING_REGIONS' . $i);
       $country_states_or_countries = split("[,]", $regions_table);
       if (in_array($dest_country, $country_states_or_countries)) {
         $dest_region = $i;
         break;
       }
     }
    }

    if ($dest_region == 0) {
      $error = true;
    } else {
      $shipping = -1;
      $region_cost = constant('MODULE_SHIPPING_REGIONS_COST' . $i);

      $regions_table = split("[:,]" , $region_cost);

      if ((MODULE_SHIPPING_REGIONS_MODE == 'price') || (MODULE_SHIPPING_REGIONS_MODE == 'weight')) {
       for ($i=0; $i<sizeof($regions_table); $i+=2) {
         if ($order_total_price <= $regions_table[$i]) {
           $shipping = $regions_table[$i+1];
//Modified line below to show shipping weight at checkout
           $shipping_method = MODULE_SHIPPING_REGIONS_TEXT_WAY . ' ' . "$dest_state, $dest_country: $shipping_weight" . ' ' . MODULE_SHIPPING_REGIONS_TEXT_UNITS;
                            
           break;
         }
       }
      }
      if (MODULE_SHIPPING_REGIONS_MODE == 'per_item') {
  $shipping = $regions_table[1] * $order_total_price;
            $shipping_method = MODULE_SHIPPING_REGIONS_ITEM . ' ' . $total_count . ' ' . MODULE_SHIPPING_REGIONS_ITEMS . ' ' . "$dest_state, $dest_country" . ' ' . MODULE_SHIPPING_REGIONS_TEXT_UNITS;
  }        
      
      
      if ($shipping == -1) {
        $shipping_cost = 0;
        $shipping_method = MODULE_SHIPPING_REGIONS_UNDEFINED_RATE;
      } else {
        $shipping_cost = ($shipping + MODULE_SHIPPING_REGIONS_HANDLING + SHIPPING_HANDLING);
      }
    }

//Modification for maximum weight      
    
    $order_total = $shipping_weight;
//change the number 40 to whatever maximum weight limit you want
if ($order_total >= 100) {
$error = 'over';
    } else {

$this->quotes = array('id' => $this->code,
              //change the module name below to reflect the shipping module
                          'module' => MODULE_SHIPPING_REGIONS_TITLE,
                          'methods' => array(array('id' => $this->code,
                                                  'title' => $shipping_method,
                                                  'cost'=> $shipping_cost)));
}

//end of maximum weight


    $this->quotes = array('id' => $this->code,
                          'module' => MODULE_SHIPPING_REGIONS_TEXT_TITLE,
                          'methods' => array(array('id' => $this->code,
                                                   'title' => $shipping_method,
                                                   'cost' => $shipping_cost)));

    if ($this->tax_class > 0) {
      $this->quotes['tax'] = tep_get_tax_rate($this->tax_class, $order->delivery['country']['id'], $order->delivery['zone_id']);
    }


    if (tep_not_null($this->icon)) $this->quotes['icon'] = tep_image($this->icon, $this->title);

    if ($error == true) $this->quotes['error'] = MODULE_SHIPPING_REGIONS_INVALID_ZONE;

   if ($error =='over') $this->quotes['error'] = 'Service Unavailable At This Weight';

    return $this->quotes;
  }

  function check() {
    if (!isset($this->_check)) {
      $check_query = tep_db_query("select configuration_value from " . TABLE_CONFIGURATION . " where configuration_key = 'MODULE_SHIPPING_REGIONS_STATUS'");
      $this->_check = tep_db_num_rows($check_query);
    }
    return $this->_check;
  }

  function install() {
    tep_db_query("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, date_added) VALUES ('Enable US Regions Method', 'MODULE_SHIPPING_REGIONS_STATUS', '1', 'Do you want to offer Regions rate shipping?', '6', '0', now())");
    tep_db_query("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, date_added) values ('Handling Fee', 'MODULE_SHIPPING_REGIONS_HANDLING', '0', 'Handling Fee for this shipping method', '6', '0', now())");
     tep_db_query("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, use_function, set_function, date_added) values ('Tax Class', 'MODULE_SHIPPING_REGIONS_TAX_CLASS', '0', 'Use the following tax class on the shipping fee.', '6', '0', 'tep_get_tax_class_title', 'tep_cfg_pull_down_tax_classes(', now())");
    tep_db_query("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, set_function, date_added) values ('Mode', 'MODULE_SHIPPING_REGIONS_MODE', 'weight', 'Is the shipping table based on total Weight or Total amount of order.', '6', '0', 'tep_cfg_select_option(array(\'weight\', \'price\', \'per_item\'), ', now())");
    for ($i = 1; $i <= $this->regions; $i++) {
      $default_countries = '';
      if ($i == 1) {
        $default_states_or_countries = 'California';
        $default_prices = '30:8.95,75:10.95,150:16.95,400:21.95,10000:25.95';
      }
      if ($i == 2) {
        $default_states_or_countries = 'Alabama,Arizona,Arkansas,California,Colorado,Connecticut,Delaware,District of Columbia,Florida,Georgia,Idaho,Illinois,Indiana,Iowa,Kansas,Kentucky,Louisiana,M
aine,Maryland,Massachusetts,Michigan,Minnesota,Mississippi,Missouri,Montana';
        $default_prices = '30:10.95,75:12.95,150:18.95,400:23.95,10000:27.95';
      }
      if ($i == 3) {
        $default_states_or_countries = 'Nebraska,Nevada,New Hampshire,New Jersey,New Mexico,New York,North Carolina,North Dakota,Ohio,Oklahoma,Oregon,Pennsylvania,Rhode Island,South Carolina,South Dakota,Texas,Utah,Vermont,Virginia,Washington,West Virginia,Wisconsin,Wyoming';
        $default_prices = '30:10.95,75:12.95,150:18.95,400:23.95,10000:27.95';
      }
      tep_db_query("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, date_added) values ('Region " . $i ." States/Countries', 'MODULE_SHIPPING_REGIONS" . $i ."', '" . $default_states_or_countries . "', 'Comma separated list of States and/or Countries', '6', '0', now())");
      tep_db_query("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, date_added) values ('Region " . $i ." Shipping Table', 'MODULE_SHIPPING_REGIONS_COST" . $i ."', '" . $default_prices . "' , 'Example: 3:8.50,7:10.50.....(weight/price)<b>:</b>(shipping cost)', '6', '0', now())");
    }
  }

  function remove() {
    $keys = '';
    $keys_array = $this->keys();
    for ($i=0; $i<sizeof($keys_array); $i++) {
      $keys .= "'" . $keys_array[$i] . "',";
    }
    $keys = substr($keys, 0, -1);

    tep_db_query("delete from " . TABLE_CONFIGURATION . " where configuration_key in (" . $keys . ")");
  }

  function keys() {
    $keys = array('MODULE_SHIPPING_REGIONS_STATUS', 'MODULE_SHIPPING_REGIONS_HANDLING', 'MODULE_SHIPPING_REGIONS_TAX_CLASS', 'MODULE_SHIPPING_REGIONS_MODE');

    for ($i=1; $i<=$this->regions; $i++) {
      $keys[] = 'MODULE_SHIPPING_REGIONS' . $i;
      $keys[] = 'MODULE_SHIPPING_REGIONS_COST' . $i;
    }

    return $keys;
  }
}
?>

 

And here is an exact copy (I have made some small cosmetic changes - nothing that should have anything to do with this though) of the shipping_estimator.php file I am using:

 

<?php
/*
 $Id: ship in cart,v 1.90 2004/07/02 

 1.90 by DDB
 -----------
- all text labels can be localized and can be found in their own language file
- wrong place of "ship to address" in case of free shipping

 ***This version (V1.83) customised by JonoB
 ***V1.83 is the same as V1.82, and also includes:
 - Ability to switch certain parts on or off via the defines section of shipping_estimator.php
 - Fixed some small spelling mistakes

 osCommerce, Open Source E-Commerce Solutions
 http://www.oscommerce.com

 Copyright (c) 2003 Edwin Bekaert (edwin@ednique.com)
 
 Customized by: Linda McGrath osCommerce@WebMakers.com
 * This now handles Free Shipping for orders over $total as defined in the Admin
 * This now shows Free Shipping on Virtual products
 * Everything is contained in an infobox for easier placement.
 
 Released under the GNU General Public License

 http://forums.oscommerce.com/viewtopic.php?t=38411

 http://www.oscommerce.com/community/contributions,1094
*/
?>
<!-- shipping_estimator //-->
<script language="JavaScript">
 function shipincart_submit(sid){
   if(sid){
     document.estimator.sid.value=sid;
   }
   document.estimator.submit();
   return false;
 }
</script>
             <table align="center"><tr valign="top"><td> 

<?php

// Defines
 define('CART_SHIPPING_METHOD_ITEMCOUNT_REQUIRED','true'); // set to false if you don't want the item count and weight shown 
 define('CART_SHIPPING_METHOD_COUNTRY_REQUIRED','true'); // set to false if you don't want the country drop down
 define('CART_SHIPPING_METHOD_STATE_REQUIRED','true'); // set to false if you don't want the state drop down
 define('CART_SHIPPING_METHOD_ZIP_REQUIRED','false');  // set to false if you don't want the zip code drop down
 define('CART_SHIPPING_METHOD_BUTTON_REQUIRED','true'); // set to false if you don't want the update button
 define('CART_OT_SHOW','true'); // set to false if you don't want order totals

// Only do when something is in the cart
if ($cart->count_contents() > 0) {
 // shipping cost
 require('includes/classes/http_client.php'); // shipping in basket
 require(DIR_WS_LANGUAGES . $language . '/' . FILENAME_SHIPPING_ESTIMATOR);

 //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 = $cart_address_id;
     }else{
       // first timer
       $sendto = $customer_default_address_id;
     }
     // set session now
     $cart_address_id = $sendto;
     tep_session_register('cart_address_id');
     // set shipping to null ! multipickjup 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);
       $order->delivery = array('postcode' => $HTTP_POST_VARS['zip_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 need a 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' => CART_SHIPPING_OPTIONS);
 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(CART_SHIPPING_METHOD_ITEMCOUNT_REQUIRED == "true"){
     $ShipTxt.='<tr><td colspan="3" class="main">' . ($total_count == 1 ? ' Item: ' : ' Items: ') . $total_count . '</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">' . CART_SHIPPING_METHOD_TO .'</td><td colspan="2" class="main">'. tep_address_format($order->delivery['format_id'], $order->delivery, 1, ' ', '<br>') . '</td></tr>';
   } else {

// not logged in
//      $ShipTxt.=tep_output_warning(CART_SHIPPING_OPTIONS_LOGIN);
     
       if(CART_SHIPPING_METHOD_ITEMCOUNT_REQUIRED == "true"){
     $ShipTxt.='<tr><td colspan="3" class="main">' . ($total_count == 1 ? ' Item: ' : ' Items: ') . $total_count . '</td></tr>';
      }

     if($cart->get_content_type() != 'virtual'){
       
       if(CART_SHIPPING_METHOD_COUNTRY_REQUIRED == "true"){
       $ShipTxt.='<tr><td colspan="3" class="main" nowrap>' . 
                 ENTRY_COUNTRY .' '. tep_get_country_list('country_id', $selected_country, 'onchange="return shipincart_submit(\'\');"');
       }

//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(CART_SHIPPING_METHOD_STATE_REQUIRED == "true"){
        $ShipTxt.='<tr><td colspan="3" class="main" nowrap>' .ENTRY_STATE .' '. tep_draw_pull_down_menu('state',$state_array);
       }

       if(CART_SHIPPING_METHOD_ZIP_REQUIRED == "true"){
         $ShipTxt.=' '.ENTRY_POST_CODE .' '. tep_draw_input_field('zip_code', $selected_zip, 'size="5"');
       }
       
       if(CART_SHIPPING_METHOD_BUTTON_REQUIRED == "true"){
$ShipTxt.='<tr><td colspan="3" class="main" nowrap><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">' . CART_SHIPPING_METHOD_FREE_TEXT . ' ' . CART_SHIPPING_METHOD_ALL_DOWNLOADS . '</td></tr>';
   }elseif ($free_shipping==1) {
     // order $total is free
     $ShipTxt.='<table><tr><td colspan="3" class="main">'.tep_draw_separator('pixel_trans.gif', '10', '1').'</td></tr>';
     $ShipTxt.='<tr><td class="main" align="left"><b>' . sprintf(FREE_SHIPPING_DESCRIPTION, $currencies->format(MODULE_ORDER_TOTAL_SHIPPING_FREE_SHIPPING_OVER)) . '</b></td></tr>';
   } else {
     // shipping display
     $ShipTxt.='<tr><td></td><td class="main" align="left"><b>' . CART_SHIPPING_METHOD_TEXT . '</b></td><td class="main" align="left"><b>' . CART_SHIPPING_METHOD_RATES . '</b></td></tr>';
     $ShipTxt.='<tr><td colspan="3" class="main">'.tep_draw_separator().'</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){
             $ShipTxt.='<td class="main"><b>'.$quotes[$i]['module'].' ';
             $ShipTxt.= '('.$quotes[$i]['methods'][0]['title'].')</b></td><td align="right" class="main"><b>'.$currencies->format(tep_add_tax($quotes[$i]['methods'][0]['cost'], $quotes[$i]['tax'])).'<b></td><td class="main">[<a href="_"  onclick="return shipincart_submit(\''.$thisquoteid.'\');">'.CART_SELECT.'</a>]</td></tr>';
           }else{
             $ShipTxt.='<td class="main">'.$quotes[$i]['module'].' ';
             $ShipTxt.= '('.$quotes[$i]['methods'][0]['title'].')</td><td align="right" class="main">'.$currencies->format(tep_add_tax($quotes[$i]['methods'][0]['cost'], $quotes[$i]['tax'])).'</td><td class="main">[<a href="_" onclick="return shipincart_submit(\''.$thisquoteid.'\');">'.CART_SELECT.'</a>]</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){
               $ShipTxt.='<td class="main"><b>'.$quotes[$i]['module'].' ';
               $ShipTxt.= '('.$quotes[$i]['methods'][$j]['title'].')</b></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">[<a href="_" onclick="return shipincart_submit(\''.$thisquoteid.'\');">'.CART_SELECT.'</a>]</td></tr>';
             }else{
               $ShipTxt.='<td class="main">'.$quotes[$i]['module'].' ';
               $ShipTxt.= '('.$quotes[$i]['methods'][$j]['title'].')</td><td align="right" class="main">'.$currencies->format(tep_add_tax($quotes[$i]['methods'][$j]['cost'], $quotes[$i]['tax'])).'</td><td class="main">[<a href="_" onclick="return shipincart_submit(\''.$thisquoteid.'\');">'.CART_SELECT.'</a>]</td></tr>';
             }
           }
         }
       }
     }
   }
 } 
 $ShipTxt.= '</table></form>';

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

 if (CART_OT_SHOW == 'true'){
   // bof damned we need the 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 damned we need the taxes if not logged in (seems like less code than in order class ???)
   require(DIR_WS_CLASSES . 'order_total.php');
   $order_total_modules = new order_total;
   //echo '</td><td align="right">';
   // order total code
   $order_total_modules->process();
   
   $info_box_contents = array();
   $info_box_contents[] = array('text' => CART_OT);
 
   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);
 }
} // Only do when something is in the cart
?>
            </td></tr></table>
<!-- shipping_estimator_eof //-->

 

Thanks in advance.

 

Carlos

Share this post


Link to post
Share on other sites

I don't know if this has been posted before but I wanted to share it just in case. After some recent sporadic problems with Ship in Cart, I began poking around and noticed a few session variables were registered, but never seemed to be unregistered. (correct me if I am wrong)

 

If they are not, then the following should be added to logoff.php:

 

  tep_session_unregister('cart_address_id');
 tep_session_unregister('cart_country_id');
 tep_session_unregister('cart_zone');
 tep_session_unregister('cart_zip_code');
 tep_session_unregister('cart_sid');


There are people who, instead of listening to what is being said to them, are already listening to what they are going to say themselves. - Albert Guinon

Share this post


Link to post
Share on other sites

This contribution works great, thanks for all the hard work.

 

I do have a question though. I ship through FedEx and the rates it's quoting is for home delivery (because company is blank for the FedEx module). Is there a way to add a checkbox where the user can select whether they are a commerical address or residencial address at the same time they enter their country, state, and zipcode? I would need to add the check box and then have it pass the value to the company variable in the FedEx module. Any help would be appriciated.

 

Thanks,

Mark

Share this post


Link to post
Share on other sites

Hi - When I select a shipping method with Ship In Cart, I'm forced to AGAIN select a shipping method in the checkout_shipping page.

 

Is this normal?

 

Is there a way for Ship In Cart to pass this information to checkout_shipping?

 

Thx

Share this post


Link to post
Share on other sites
Hi - When I select a shipping method with Ship In Cart, I'm forced to AGAIN select a shipping method in the checkout_shipping page.

 

Is this normal?

 

Is there a way for Ship In Cart to pass this information to checkout_shipping?

 

Thx

Set the selected method as a session variable. Then in the checkout_shipping page you would need to modify the default selected method.

 

For example ...

 

If the default-selected variable in checkout_shipping was $this, you would add this statement above:

 

if ($_SESSION['sic_method'] != NULL {
 $default_method = $_SESSION['sic_method'];
} else {
 $default method = $this;
}

 

Then you would remove $this from the radio button default and replace it with $default_method.

 

It'll take a little bit of coding knowledge, but it's not difficult.


There are people who, instead of listening to what is being said to them, are already listening to what they are going to say themselves. - Albert Guinon

Share this post


Link to post
Share on other sites

Hi Todd, thanks for your quick reply. And super response !

 

Followup question: Any ideas how to make the shipping methods sortable?

 

For example, I want the shipping prices to all be sorted by price, cheapest to most expensive.

 

As it is, it's by module (fedex, ups), then by price.

Share this post


Link to post
Share on other sites

Many osc users may not be aware that when selecting a shipping quote (logged in or not) from shopping_cart.php (or where ever your shipping_estimator.php is called from) that the rate is not carried over to checkout_shipping.php.

 

Here is the fix for ShipInCart (MS2) assuming your shipping_estimator.php uses the: $cart_sid = $HTTP_POST_VARS['sid']; around line 134

 

In checkout_shipping.php find:

 

} else {

for ($j=0, $n2=sizeof($quotes[$i]['methods']); $j<$n2; $j++) {

// set the radio button to be checked if it is the method chosen

 

Below that add:

 

if ($cart_sid) {

$shipping['id'] = $cart_sid;

}

 

Hope this helps...

Mac

Share this post


Link to post
Share on other sites

Thank you very much for a great contribution. I have it working, only one small problem and that is for some reason the 'selected.gif' is not appearing. I have put it into images/icons/selected.gif and it still does not appear. Dont know why?

Share this post


Link to post
Share on other sites

hello all, blucollarguy or anyone else have any luck with the issue of rates not showing up unless logged in to account yet?

Share this post


Link to post
Share on other sites
Many osc users may not be aware that when selecting a shipping quote (logged in or not) from shopping_cart.php (or where ever your shipping_estimator.php is called from) that the rate is not carried over to checkout_shipping.php.

 

Here is the fix for ShipInCart (MS2) assuming your shipping_estimator.php uses the: $cart_sid = $HTTP_POST_VARS['sid']; around line 134

 

In checkout_shipping.php find:

 

        } else {

          for ($j=0, $n2=sizeof($quotes[$i]['methods']); $j<$n2; $j++) {

// set the radio button to be checked if it is the method chosen

 

Below that add:

 

if ($cart_sid) {

$shipping['id'] = $cart_sid;

}

 

Hope this helps...

Mac

Wahey works like a dream, cheers ;)

Share this post


Link to post
Share on other sites

I need a little help with this contribution. I have tried to scan the entire post but I could not find an answer so i apologize if it has been answered. I have installed this contribution and it works great for a customer who is logged in but I cannot get any shipping options, zip code box or anything to work for a non-registered customer. Here is the link to my test site My Webpage any ideas would be greatly appreciated

Share this post


Link to post
Share on other sites

sorry i see that you can not edit a post but here is a login id and password for my test site so you can see that it works when loged in

login me@aol.com password apple

Share this post


Link to post
Share on other sites

Can anyone please help with some updates for a great and needed contibution?

 

I got the Shipping Estimate contribution to work for users not logged on. :D

 

But :(

 

Now the shipping cost seems to calculate from my zip-code and this is ok I guess if you just want to estimate.

 

When I add the country, zip and update button I can't get it to recalculate. What I do get is:

 

Query was empty - Query was empty

Query was empty

[TEP STOP]

 

If I just add zip-code and update buttom the screen just will refresh on click, but no updated shipping cost.

 

Thanks for any help that you have to offer.

 

Kelly

Share this post


Link to post
Share on other sites
hello all, blucollarguy or anyone else have any luck with the issue of rates not showing up unless logged in to account yet?

Not yet. And as you can see from the many posts recently we are not alone. I have not had time to work on this yet but hope to soon, I will post any solutions I come up with. Craig :)


Happy Coding!

Craig Garrison Sr

Anything worth having, is worth working for.

Multi Vendor Shipping V1.1 Demo Catalog

3 Vendors, each category, "buy" a product from each category to see how MVS works during checkout.

Multi Vendor Shipping V1.1 Demo Admin

login: webmaster@blucollarsales.com

pass: mvs_demo

MVS Thread:

Multi-Vendor Shipping

My contribs:

Download Multi Vendor Shipping V1.1

Vendor Email

Vendor Info in easypopulate

EZ Price Updater

And more to come!

Share this post


Link to post
Share on other sites

Anyone have a solution as to why this doesn't quite work with the upsxml shipping module? When the estimates are first caluculated it works fine. But when you change the shipping to a different listing, the price of shipping and what it reflects on the bottom for the calculations is way off.

 

For example, the shipping cost of 3 day is $14.00. On the bottom where it calculates is like $24.00. Which in turn throws off the order total. It works when its first loaded but when you start changing shipping methods, it gets off.

 

Suggestions?

 

-Dennis

Share this post


Link to post
Share on other sites

Hi. I've been looking for a contributions that lets me type in the zipcode number to get quotes so the user doesnt have to be logged in....

HAS ANYONE GOT THIS TO WORK?

cause im kinda desperate :P

Share this post


Link to post
Share on other sites
From dms1217: hello all, blucollarguy or anyone else have any luck with the issue of rates not showing up unless logged in to account yet? 

 

 

From blucollarguy: Not yet. And as you can see from the many posts recently we are not alone. I have not had time to work on this yet but hope to soon, I will post any solutions I come up with. Craig 

 

From blkg35coupe:

I need a little help with this contribution. I have tried to scan the entire post but I could not find an answer so i apologize if it has been answered. I have installed this contribution and it works great for a customer who is logged in but I cannot get any shipping options, zip code box or anything to work for a non-registered customer. Here is the link to my test site My Webpage any ideas would be greatly appreciated

 

While some of us declared victory and praised the contrib, I fell victim similarly to blucollarguy and blkg35coupe. The shipping estimator doesn't show up for me whether the user is logged in or not. I'm using SICversion 2.0 on MS2<br>

<br>

To debug, I took the "if (CARTSHIP_ONOFF) condition out of shopping_cart.php and require shipping_estimator.php unconditionally. Then, the shipping estimator showed up only for the user who was logged in. I never got to see the country, state, or zip entry fields.<br>

<br>

Please shed your wisdom on us. This is an awesome contrib but it isn't working on my site. <a href:"http://donnam.com">donnam.com</a>.

Share this post


Link to post
Share on other sites

I got my site to work now.

 

Because I suspected that the CARTSHIP_ONOFF was not being read, I went into Admin and disabled "Shipping and Order Total Estimate". Then, I enabled it again.

 

Works great. Great contribution. Many thanks.

 

Tom :D

Share this post


Link to post
Share on other sites

:D Ok all, I finally got a version to work for me. :thumbsup:

 

Here is what I did:

 

Download version 1.83.

Put the "shipping_estimator.php" script in the "modules" dir just like the install says, then add the couple of lines of code to the "catalog/shopping_cart.php" file just like the install says and then in "catalog/includes/boxes/shopping_cart.php" find this bit of code

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

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

    $info_box_contents[] = array('align' => 'right',

                                'text' => $currencies->format($cart->show_total()));

and replace it with this

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

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

    $info_box_contents[] = array('align' => 'right',

                                'text' => $currencies->format($cart->show_total()) . '

                                          <br><a href="' . tep_href_link(FILENAME_SHOPPING_CART, '', 'NONSSL') . '" >Estimate Shipping</b></a>' );

What you will get is a text line that will appear when something has been placed in the cart that says "Estimate Shipping". The link simply goes to the "shopping_cart" file where you installed this version, which is working for me. Hope this helps someone, anyone?

Craig :)

 

BTW: In case anyone can't find the version that I know is working for me, I can send it to you email if you contact me. :thumbsup:


Happy Coding!

Craig Garrison Sr

Anything worth having, is worth working for.

Multi Vendor Shipping V1.1 Demo Catalog

3 Vendors, each category, "buy" a product from each category to see how MVS works during checkout.

Multi Vendor Shipping V1.1 Demo Admin

login: webmaster@blucollarsales.com

pass: mvs_demo

MVS Thread:

Multi-Vendor Shipping

My contribs:

Download Multi Vendor Shipping V1.1

Vendor Email

Vendor Info in easypopulate

EZ Price Updater

And more to come!

Share this post


Link to post
Share on other sites

Howdy all!

 

I have a bit of a question, I just got done reading thru this forum hoping to find the answer to my question, but I haven't so here goes.

 

I just got done installing this AWSOME! contrib and all seems to be working fine (v2.00 Ship In Cart) plus the extra Fix file. I have free shipping over $ amount and this works great too! However I also have some gift certificates that I sell on my shop. I have their weight set at 0, and downloads enabled, but the shipping estimate still comes up for these "virtual" products. Is there some setting I am missing here? How do I get it so that these products don't have shipping on them in the estimate?

 

Thanks to everyone here for making the contrib so usefull and easy to install!

 

RW


A man who works with his hands is a laborer

A man who works with his hands and his brain is a craftsman

But a man who works with his hands and his brain and his heart is an artist. - Charles Dickens

Share this post


Link to post
Share on other sites

hello all

i have just install ship in cart v2.0 , it did not worked. i followed all INSTRUCTIONS as it said in install file. all i got was subtotal at the bottom of the page. but Shipping Estimator had nothing in it. what i am doing wrong.

thanks

pj

Share this post


Link to post
Share on other sites

I have installed the contrib, and it's half working. I only get the quotes if someone is logged in, otherwise nothing shoes up. I'm using version 2, with the fix. I undid the fix and I get the box with $0 shipping quoted, as the fix said I would.

 

I've seen some sites up and running that have a box for the ZIP and country if the user isn't logged in, and that's what I'm trying to achieve. Any help is very appreciated.

 

http://www.bargainbirch.com

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

×