mzmt Class Reference

Inherits InterfaceModule, and InterfaceAcaShipping.

List of all members.

Public Member Functions

Public Attributes

Private Member Functions


Detailed Description

Definition at line 11 of file mzmt.php.


Constructor & Destructor Documentation

mzmt::__construct (  ) 

block suite si BO

Definition at line 15 of file mzmt.php.

00015                          {
00016 
00017 
00018     $this->code = __CLASS__;
00019     $this->title = __('module shipping mzmt text title');
00020     $this->description = __('module shipping mzmt text description');
00021     $this->sort_order = (defined('MODULE_SHIPPING_MZMT_SORT_ORDER') ? MODULE_SHIPPING_MZMT_SORT_ORDER : 0);
00022     $this->tax_class = (defined('MODULE_SHIPPING_MZMT_TAX_CLASS') ? MODULE_SHIPPING_MZMT_TAX_CLASS : '');
00023     $this->icon = '';
00024     $this->enabled = true;
00025 
00026     $this->num_geozones = (defined('MODULE_SHIPPING_MZMT_NUMBER_GEOZONES') ? MODULE_SHIPPING_MZMT_NUMBER_GEOZONES : 3 );
00027     $this->num_tables = (defined('MODULE_SHIPPING_MZMT_NUMBER_TABLES') ? MODULE_SHIPPING_MZMT_NUMBER_TABLES : 3 );
00028 
00029     global $order;
00031     if(!is_object($order)) return false;
00032     else $this->update_status($order);
00033 
00034   }


Member Function Documentation

mzmt::check (  ) 

Interface InterfaceModule.

Definition at line 107 of file mzmt.php.

00107                           {
00108     if (!isset($this->_check)) {
00109       $check_query = tep_db_query("select configuration_value from " . TABLE_CONFIGURATION . " where configuration_key LIKE 'MODULE_SHIPPING_MZMT_%' ");
00110         if( tep_db_num_rows($check_query) ==  (4+ ($this->num_geozones* 4)+(+$this->num_tables *$this->num_geozones) ) ) $this->_check=true;
00111         else {
00112         $this->remove();
00113         $this->_check=false;
00114       }
00115     }
00116     return $this->_check;
00117   }

mzmt::determineShipping ( table_cost  )  [private]

Calcul shipping.

calcul pour table de prix en %

majoration tare emballage

Definition at line 190 of file mzmt.php.

Referenced by quote().

00190                                                   {
00191     $shipping_factor=0;
00192     for ($i=0, $n=sizeof($table_cost); $i<$n; $i+=2){
00193       if ($this->order_total <= $table_cost[$i] && isset($table_cost[$i+1]) && tep_not_null($table_cost[$i+1]) ){
00194         $shipping_factor = $table_cost[$i+1];
00195         break;
00196       }
00197     }
00198 
00200     if (substr_count($shipping_factor, '%') > 0)
00201       $shipping = ((($this->order_total*10)/10)*((str_replace('%', '', $shipping_factor))/100));
00202     else
00203       $shipping = str_replace('$', '', $shipping_factor);
00204 
00205 
00207     if ($this->geozone_mode == 'weight')
00208       $shipping = $shipping * shipping::$shipping_num_boxes;
00209 
00210     return $shipping;
00211   }

mzmt::determineTableMethod ( geozone_mode  )  [private]

PRIVATE/PUBLIC Specific module.

Mode base calcul

Definition at line 171 of file mzmt.php.

Referenced by quote().

00171                                                        {
00172     global $total_count, $shipping_weight;
00173 
00174     $this->geozone_mode = $geozone_mode;
00175 
00176     if ($this->geozone_mode == 'price') {
00177       $this->order_total = $_SESSION['cart']->show_total();
00178     } elseif ($this->geozone_mode == 'count') {
00179       $this->order_total = $total_count;
00180     } else {
00181       $this->order_total = $shipping_weight;
00182     }
00183 
00184     return null;
00185   }

mzmt::install (  ) 

Definition at line 119 of file mzmt.php.

00119                             {
00120     $DB=Database::getInstance();
00121 
00122     $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_MZMT_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())");
00123     $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_MZMT_SORT_ORDER', '0', 'sort order of display.', '6', '0', now())");
00124     $DB->query("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order,  date_added) values ('number geozones', 'MODULE_SHIPPING_MZMT_NUMBER_GEOZONES', '".(defined('MODULE_SHIPPING_MZMT_NUMBER_GEOZONES')? MODULE_SHIPPING_MZMT_NUMBER_GEOZONES : '3')."', 'use the following tax class on the shipping fee.', '6', '0', now())");
00125     $DB->query("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, date_added) values ('number tables', 'MODULE_SHIPPING_MZMT_NUMBER_TABLES', '".(defined('MODULE_SHIPPING_MZMT_NUMBER_TABLES')? MODULE_SHIPPING_MZMT_NUMBER_TABLES : '3')."', 'Sort order of display.', '6', '0', now())");
00126 
00127     for ($n=1; $n<=$this->num_geozones; $n++) {
00128       $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 ('<hr />Geo Zone $n', 'MODULE_SHIPPING_MZMT_GEOZONE_".$n."_ID', '', 'Enable this for the following geo zone.', '6', '0', 'tep_get_zone_class_title', 'tep_cfg_pull_down_zone_shipping(', now())");
00129       $DB->query("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, set_function, date_added) values ('Geo Zone $n Table Method', 'MODULE_SHIPPING_MZMT_GEOZONE_".$n."_MODE', 'weight', 'The shipping cost is based on the total weight, total price, or total count of the items ordered.', '6', '0', 'tep_cfg_select_option(array(\'weight\', \'price\', \'count\'), ', now())");
00130       $DB->query("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, date_added) values ('Geo Zone $n Handling Fee', 'MODULE_SHIPPING_MZMT_GEOZONE_".$n."_HANDLING', '0', 'Handling Fee for this shipping geo zone', '6', '0', now())");
00131       $DB->query("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, date_added,set_function) values ('choose icon', 'MODULE_SHIPPING_MZMT_GEOZONE_".$n."_ICON', '', 'choose icon transporteur', '6', '0', now(),'tep_cfg_choose_img(')");
00132 
00133 
00134       for ($j=1; $j<=$this->num_tables; $j++) {
00135         $DB->query("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, date_added) values ('Geo Zone $n Shipping Table $j', 'MODULE_SHIPPING_MZMT_GEOZONE_".$n."_TABLE_".$j."', '', 'Shipping table $j for this geo zone', '6', '0', now())");
00136       }
00137 
00138 
00139     }
00140   }

mzmt::keys (  ) 

Definition at line 146 of file mzmt.php.

00146                          {
00147     $keys = array( 'MODULE_SHIPPING_MZMT_TAX_CLASS', 'MODULE_SHIPPING_MZMT_SORT_ORDER','MODULE_SHIPPING_MZMT_NUMBER_GEOZONES','MODULE_SHIPPING_MZMT_NUMBER_TABLES');
00148 
00149     for ($n=1; $n<=$this->num_geozones; $n++) {
00150       $keys[] = 'MODULE_SHIPPING_MZMT_GEOZONE_' . $n . '_ID';
00151       $keys[] = 'MODULE_SHIPPING_MZMT_GEOZONE_' . $n . '_MODE';
00152       $keys[] = 'MODULE_SHIPPING_MZMT_GEOZONE_' . $n . '_HANDLING';
00153       $keys[] = 'MODULE_SHIPPING_MZMT_GEOZONE_' . $n . '_ICON';
00154 
00155       for ($j=1; $j<=$this->num_tables; $j++) {
00156         $keys[] = 'MODULE_SHIPPING_MZMT_GEOZONE_' . $n . '_TABLE_' . $j;
00157       }
00158     }
00159 
00160     return $keys;
00161   }

mzmt::quote ( method = ''  ) 

Interface InterfaceAcaShipping.

Definition at line 38 of file mzmt.php.

00038                                       {
00039     global $order, $shipping_weight;
00040 
00041     $combined_quote_weight = (shipping::$shipping_num_boxes * $shipping_weight);
00042     $this->quotes = array('id' => $this->code,
00043                         'module' => __('module shipping mzmt geozone ' . $this->delivery_geozone . ' text title') . ' (' . $combined_quote_weight . ' '.UNIT_WEIGHT_NAME.')',
00044                         'methods' => array());
00045 
00046     $this->determineTableMethod(constant('MODULE_SHIPPING_MZMT_GEOZONE_' . $this->delivery_geozone . '_MODE'));
00047 
00048 
00049     if ($method) {
00050       $j = substr($method, 5);
00051 
00052       $shipping = $this->determineShipping(preg_split("/[:,]/" , constant('MODULE_SHIPPING_MZMT_GEOZONE_' . $this->delivery_geozone . '_TABLE_' . $j)));
00053 
00054       $this->quotes['methods'][] = array('id' => 'table' . $j,
00055                                           'title' => __('module shipping mzmt geozone ' . $this->delivery_geozone . ' table ' . $j . ' text way'),
00056                                           'cost_ht' => $shipping + constant('MODULE_SHIPPING_MZMT_GEOZONE_' . $this->delivery_geozone . '_HANDLING'),
00057                                           'cost' => $shipping + constant('MODULE_SHIPPING_MZMT_GEOZONE_' . $this->delivery_geozone . '_HANDLING')
00058                                         );
00059     }
00060     else {
00061       for ($j=1; $j<=$this->num_tables; $j++) {
00062         if (!tep_not_null(constant('MODULE_SHIPPING_MZMT_GEOZONE_' . $this->delivery_geozone . '_TABLE_' . $j))) continue;
00063 
00064         $shipping = $this->determineShipping(preg_split("/[:,]/" , constant('MODULE_SHIPPING_MZMT_GEOZONE_' . $this->delivery_geozone . '_TABLE_' . $j)));
00065 
00066         $this->quotes['methods'][] = array('id' => 'table' . $j,
00067                                             'title' => __('module shipping mzmt geozone ' . $this->delivery_geozone . ' table ' . $j . ' text way'),
00068                                             'cost_ht' => $shipping + constant('MODULE_SHIPPING_MZMT_GEOZONE_' . $this->delivery_geozone . '_HANDLING'),
00069                                             'cost' => $shipping + constant('MODULE_SHIPPING_MZMT_GEOZONE_' . $this->delivery_geozone . '_HANDLING')
00070                                           );
00071       }
00072     }
00073 
00074     if ($this->tax_class > 0) {
00075       $this->quotes['tax'] = tep_get_tax_rate($this->tax_class, $order->delivery['country']['id'], $order->delivery['zone_id']);
00076       $this->quotes['methods'][0]['cost'] = tep_add_tax(((MODULE_SHIPPING_ITEM_COST * $total_count) + MODULE_SHIPPING_ITEM_HANDLING), $this->quotes['tax']);
00077       $this->quotes['methods'][0]['cost_ht'] = ((MODULE_SHIPPING_ITEM_COST * $total_count) + MODULE_SHIPPING_ITEM_HANDLING);
00078     }
00079 
00080     if (defined('MODULE_SHIPPING_MZMT_GEOZONE_' . $this->delivery_geozone . '_ICON')) {
00081       if ( tep_not_null(constant('MODULE_SHIPPING_MZMT_GEOZONE_' . $this->delivery_geozone . '_ICON')) )
00082         $this->quotes['icon'] = shipping::get_icon(constant('MODULE_SHIPPING_MZMT_GEOZONE_' . $this->delivery_geozone . '_ICON'), $this->title);
00083     }
00084 
00085     return $this->quotes;
00086   }

mzmt::remove (  ) 

Definition at line 142 of file mzmt.php.

00142                            {
00143     tep_db_query("delete from " . TABLE_CONFIGURATION . " where configuration_key  LIKE  'MODULE_SHIPPING_MZMT_%' ");
00144   }

mzmt::update_status ( order  ) 

Definition at line 88 of file mzmt.php.

Referenced by __construct().

00088                                         {
00089     if ($this->enabled == true ) {
00090       $this->enabled = false;
00091       for ($n=1; $n<=$this->num_geozones; $n++) {
00092         if ( ((int)constant('MODULE_SHIPPING_MZMT_GEOZONE_' . $n . '_ID') > 0) && ((int)constant('MODULE_SHIPPING_MZMT_GEOZONE_' . $n . '_ID') == shipping::getGeoZoneID($order->delivery['country']['id'], $order->delivery['zone_id'])) ) {
00093           $this->enabled = true;
00094           $this->delivery_geozone = $n;
00095           break;
00096         } elseif ( ((int)constant('MODULE_SHIPPING_MZMT_GEOZONE_' . $n . '_ID') == 0) && ($n == (int)$this->num_geozones) ) {
00097           $this->enabled = true;
00098           $this->delivery_geozone = $n;
00099           break;
00100         }
00101       }
00102     }
00103   }


Member Data Documentation

mzmt::$code

Definition at line 13 of file mzmt.php.

mzmt::$delivery_geozone

Definition at line 13 of file mzmt.php.

mzmt::$description

Definition at line 13 of file mzmt.php.

mzmt::$enabled

Definition at line 13 of file mzmt.php.

mzmt::$geozone_mode

Definition at line 13 of file mzmt.php.

Referenced by determineTableMethod().

mzmt::$icon

Definition at line 13 of file mzmt.php.

mzmt::$num_tables

Definition at line 13 of file mzmt.php.

mzmt::$num_zones

Definition at line 13 of file mzmt.php.

mzmt::$order_total

Definition at line 13 of file mzmt.php.

mzmt::$title

Definition at line 13 of file mzmt.php.


The documentation for this class was generated from the following file: