TalkPHP
 
 
Account Login
Latest Articles
» The basic usage of PHPTAL, a XML/XHTML template library for PHP
» Vulnerable methods and the areas they are commonly trusted in.
» Simple way to protect a form from bot
» The Basics On: How Session Stealing Works
» How to keep your forms from double posting data
IRC Channel
IRC Speech Bubble Join the friendly bunch on IRC...
(#TalkPHP on Freenode)

...Also available via a web interface.

See this thread for information on the TalkPHP Free Hugs Initiative™. Subject to availability.
Associates
Associates
CSS Tutorials
Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old 03-03-2008, 11:34 AM   #1 (permalink)
The Wanderer
 
bullit's Avatar
 
Join Date: Jan 2008
Location: Leeds, West Yorkshire
Posts: 9
Thanks: 6
bullit is on a distinguished road
Default shipping matrix issue

does anyone here have any experience of using Oscommerce?
osCommerce, Open Source Online Shop E-Commerce Solutions
basically I've used an addon for a client which calculates the shipping charges based on th total cost and weight of the items in the basket when you get to the checkout screen, the costs and weights are specified in the admin section
this is basically how the shipping matrix is laid out:
0-2kg 2-10kg 10-17kg
0-£40 £2.50 £20.00 £30.00
£40+ £4.75 £20.00 £30.00

for some reason not matter what the total cost in the basket is, it is only picking up a price from the first line in the matrix

Heres the code:

Code:
<?php
/*
  $Id: table.php,v 1.27 2003/02/05 22:41:52 hpdl Exp $

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

  Copyright (c) 2003 osCommerce

  Released under the GNU General Public License
*/

  class pwtable {
    var $code, $title, $description, $icon, $enabled;

// class constructor
    function pwtable() {
      global $order;

      $this->code = 'pwtable';
      $this->title = MODULE_SHIPPING_PWTABLE_TEXT_TITLE;
      $this->description = MODULE_SHIPPING_PWTABLE_TEXT_DESCRIPTION;
      $this->sort_order = MODULE_SHIPPING_PWTABLE_SORT_ORDER;
      $this->icon = '';
      $this->tax_class = MODULE_SHIPPING_PWTABLE_TAX_CLASS;
      $this->enabled = ((MODULE_SHIPPING_PWTABLE_STATUS == 'True') ? true : false);

      if ( ($this->enabled == true) && ((int)MODULE_SHIPPING_PWTABLE_ZONE > 0) ) {
        $check_flag = false;
        $check_query = tep_db_query("select zone_id from " . TABLE_ZONES_TO_GEO_ZONES . " where geo_zone_id = '" . MODULE_SHIPPING_PWTABLE_ZONE . "' and zone_country_id = '" . $order->delivery['country']['id'] . "' order by zone_id");
        while ($check = tep_db_fetch_array($check_query)) {
          if ($check['zone_id'] < 1) {
            $check_flag = true;
            break;
          } elseif ($check['zone_id'] == $order->delivery['zone_id']) {
            $check_flag = true;
            break;
          }
        }

        if ($check_flag == false) {
          $this->enabled = false;
        }
      }
    }

// class methods
    function quote($method = '') {
      global $order, $cart, $total_weight, $currencies, $currency, $currency_symbol, $table_costtable,$table_pointer,$weight_pointer,$weight_matrix;

      $dest_country = $order->delivery['country']['iso_code_2'];
      $currency_symbol = $currencies->currencies[$currency]['symbol_left'];
      $order_total = $cart->show_total();
      $table_pointer = 0;
      $weight_pointer = 0;
      $weight_matrix =     array( 
                                  (split("[:,]" , MODULE_SHIPPING_PWTABLE_WEIGHTTABLE_0)),
                                  (split("[:,]" , MODULE_SHIPPING_PWTABLE_WEIGHTTABLE_1)),
                                (split("[:,]" , MODULE_SHIPPING_PWTABLE_WEIGHTTABLE_2)),
                                (split("[:,]" , MODULE_SHIPPING_PWTABLE_WEIGHTTABLE_3)),
                                (split("[:,]" , MODULE_SHIPPING_PWTABLE_WEIGHTTABLE_4)),
                                (split("[:,]" , MODULE_SHIPPING_PWTABLE_WEIGHTTABLE_5)), 
                        );


      $table_costtable = split("[,]" , MODULE_SHIPPING_PWTABLE_COSTTABLE);
      $size = sizeof($table_costtable);
      for ($i=0; $i<$size; $i++) {
          if ($order_total <= $table_costtable[$i]) {
                $table_pointer = $i;
                break;
          }
      }

    
      $table_costweight = $weight_matrix[$i];
      $size = sizeof($table_costweight);
      for ($i=0; $i<$size; $i+=2) {
        if ($total_weight <= $table_costweight[$i]) {
          $shipping = $table_costweight[$i+1];
          $weight_pointer = $i;
          break;
        }
      }



require(DIR_WS_FUNCTIONS . 'cost_weight_table.php');
$display_table = display_table();

          $shipping_method = MODULE_SHIPPING_PWTABLE_TEXT_WAY . ' ' . '<br>' . MODULE_SHIPPING_PWTABLE_TEXT_AMOUNT . ':' . $currency_symbol . $order_total . ',   ' . MODULE_SHIPPING_PWTABLE_TEXT_WEIGHT . ':' . $total_weight . ' ' . MODULE_SHIPPING_PWTABLE_TEXT_UNITS;
          



      $this->quotes = array('id' => $this->code,
                            'module' => MODULE_SHIPPING_PWTABLE_TEXT_TITLE,
                            'methods' => array(array('id' => $this->code,
                                                    'title' => $shipping_method,
                                                    'table' => $display_table,
                                                     'cost' => $shipping + MODULE_SHIPPING_PWTABLE_HANDLING)));

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

      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_PWTABLE_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, set_function, date_added) VALUES ('Enable Table Method', 'MODULE_SHIPPING_PWTABLE_STATUS', 'True', 'Do you want to offer table rate shipping?', '6', '0', 'tep_cfg_select_option(array(\'True\', \'False\'), ', now())");

      tep_db_query("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, date_added) values ('Cost Bands', 'MODULE_SHIPPING_PWTABLE_COSTTABLE', '30.00,125.00,350.00,750.00,1500.00,3000.00', 'These are the six cost bands. For each of these bands, there are six weight:shipping-charge rates (See below). Shipping charge is therefore based on price/weight of the cart.', '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 ('Weight/Shipping Band 0', 'MODULE_SHIPPING_PWTABLE_WEIGHTTABLE_0', '0.5:1.99,5.0:5.49,10.0:5.99,20.0:6.49,50.0:7.49,100.0:8.49', 'Rates for cost band 0. The shipping charge is based on the cost band(£30.00 in this case) + the six cart weights. Eg. 0.5:1.99 means for cart amount less than £30.00 and cart weight less than 0.5 kg, the shipping charge would be £1.99 etc.', '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 ('Weight/Shipping Band 1', 'MODULE_SHIPPING_PWTABLE_WEIGHTTABLE_1', '0.5:3.29,5.0:4.49,10.0:5.59,20.0:5.79,50.0:5.99,100.0:6.99', 'Rates for cost band 1. The shipping charge is based on the cost band(£125.00 in this case) + the six cart weights. Eg. 5.0:4.49 means for cart amount less than £125.00 and cart weight less than 5.0 kg, the shipping charge would be £4.49 etc.', '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 ('Weight/Shipping Band 2', 'MODULE_SHIPPING_PWTABLE_WEIGHTTABLE_2', '0.5:4.99,5.0:4.99,10.0:4.99,20.0:4.99,50.0:5.99,100.0:6.99', 'Rates for cost band 2. The shipping charge is based on the cost band(£350.00 in this case) + the six cart weights. Eg. 10.0:4.99 means for cart amount less than £350.00 and cart weight less than 10.0 kg, the shipping charge would be £4.99 etc.', '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 ('Weight/Shipping Band 3', 'MODULE_SHIPPING_PWTABLE_WEIGHTTABLE_3', '0.5:4.99,5.0:4.99,10.0:4.99,20.0:4.99,50.0:5.99,100.0:6.99', 'Rates for cost band 3. The shipping charge is based on the cost band(£750.00 in this case) + the six cart weights. Eg. 20.0:4.99 means for cart amount less than £750.00 and cart weight less than 20.0 kg, the shipping charge would be £4.99 etc.', '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 ('Weight/Shipping Band 4', 'MODULE_SHIPPING_PWTABLE_WEIGHTTABLE_4', '0.5:3.99,5.0:3.99,10.0:4.49,20.0:4.99,50.0:4.99,100.0:5.99', 'Rates for cost band 4. The shipping charge is based on the cost band(£1500.00 in this case) + the six cart weights. Eg. 50.0:4.99 means for cart amount less than £1500.00 and cart weight less than 50.0 kg, the shipping charge would be £4.99 etc.', '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 ('Weight/Shipping Band 5', 'MODULE_SHIPPING_PWTABLE_WEIGHTTABLE_5', '0.5:3.99,5.0:3.99,10.0:4.49,20.0:4.99,50.0:4.99,100.0:5.99', 'Rates for cost band 5. The shipping charge is based on the cost band(£3000.00 in this case) + the six cart weights. Eg. 100.0:5.99 means for cart amount less than £3000.00 and cart weight less than 100.0 kg, the shipping charge would be £5.99 etc.', '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_PWTABLE_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, use_function, set_function, date_added) values ('Shipping Zone', 'MODULE_SHIPPING_PWTABLE_ZONE', '0', 'If a zone is selected, only enable this shipping method for that zone.', '6', '0', 'tep_get_zone_class_title', 'tep_cfg_pull_down_zone_classes(', now())");
      tep_db_query("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, date_added) values ('Sort Order', 'MODULE_SHIPPING_PWTABLE_SORT_ORDER', '0', 'Sort order of display.', '6', '0', now())");
    }

    function remove() {
      tep_db_query("delete from " . TABLE_CONFIGURATION . " where configuration_key in ('" . implode("', '", $this->keys()) . "')");
    }

    function keys() {
      return array('MODULE_SHIPPING_PWTABLE_STATUS','MODULE_SHIPPING_PWTABLE_COSTTABLE','MODULE_SHIPPING_PWTABLE_WEIGHTTABLE_0','MODULE_SHIPPING_PWTABLE_WEIGHTTABLE_1','MODULE_SHIPPING_PWTABLE_WEIGHTTABLE_2','MODULE_SHIPPING_PWTABLE_WEIGHTTABLE_3','MODULE_SHIPPING_PWTABLE_WEIGHTTABLE_4','MODULE_SHIPPING_PWTABLE_WEIGHTTABLE_5','MODULE_SHIPPING_PWTABLE_SORT_ORDER', 'MODULE_SHIPPING_PWTABLE_ZONE','MODULE_SHIPPING_PWTABLE_HANDLING', 'MODULE_SHIPPING_PWTABLE_TAX_CLASS');
    }
  }
?>
could someone please tell me whats going wrong :s
__________________
who is general failure? and why is he reading my hard drive?
Send a message via MSN to bullit
bullit is offline  
Reply With Quote
Reply



Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


All times are GMT. The time now is 12:35 AM.

 
     

Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.1.0
Inactive Reminders By Icora Web Design