15 Oct 2007, 3:04 AM
New Zenner
- Join Date:
- Aug 2007
- Posts:
- 35
- Plugin Contributions:
- 0
Shipping price based on Company input
I currently have a unique domestic shipping rate mod and would like to combine the if ($order->delivery['company'] != '') like in the FedEx mod to provide a different quote based on the user entering a company name on create account.
I tried a few ways and no avail. Any ideas how I can incorporate this into the current code below. Meaning the rates for residential would be slightly higher. I have been working on this for ages! It seems simple enough but my coding is not the best. Oh and perhaps another user could benefit from this unique code below.
Thank you!
<?php class domestic extends base { var $code, $title, $description, $icon, $enabled; function domestic() { global $order, $db; $this->code = "domestic"; $this->title = MODULE_SHIPPING_DOMESTIC_TEXT_TITLE; $this->description = MODULE_SHIPPING_DOMESTIC_TEXT_DESCRIPTION; $this->sort_order = MODULE_SHIPPING_DOMESTIC_SORT_ORDER; $this->icon = ""; $this->tax_class = MODULE_SHIPPING_DOMESTIC_TAX_CLASS; if (zen_get_shipping_enabled($this->code)) { $this->enabled = ((MODULE_SHIPPING_DOMESTIC_STATUS == 'True') ? true : false); } if ( ($this->enabled == true) && ((int)MODULE_SHIPPING_DOMESTIC_ZONE > 0) ) { $check_flag = false; $check = $db->Execute("select zone_id from " . TABLE_ZONES_TO_GEO_ZONES . " where geo_zone_id = '" . MODULE_SHIPPING_DOMESTIC_ZONE . "' and zone_country_id = '" . $order->delivery['country']['id'] . "' order by zone_id"); while (!$check->EOF) { if ($check->fields['zone_id'] < 1) { $check_flag = true; break; } elseif ($check->fields['zone_id'] == $order->delivery['zone_id']) { $check_flag = true; break; } $check->MoveNext(); } if ($check_flag == false) { $this->enabled = false; } } $this->type = array ( 0 => "DOMESTIC1", 1 => "DOMESTIC2", 2 => "DOMESTIC3", 3 => "DOMESTIC4", 4 => "DOMESTIC5", 5 => "DOMESTIC6", 6 => "DOMESTIC7" ); $this->name = array ( "DOMESTIC1" => "Ground", "DOMESTIC2" => "3 Day", "DOMESTIC3" => "2nd Day Air", "DOMESTIC4" => "Next Day Air PM", "DOMESTIC5" => "Next Day Air AM", "DOMESTIC6" => "Next Day Air (Saturday Delivery)", "DOMESTIC7" => "Priority Mail (USPS)" ); $this->price = array ( "DOMESTIC1" => 10.95, "DOMESTIC2" => 15.95, "DOMESTIC3" => 18.95, "DOMESTIC4" => 24.95, "DOMESTIC5" => 27.95, "DOMESTIC6" => 38.95, "DOMESTIC7" => 16.95 ); } function quote($method = "") { global $order; $this->quotes["id"] = $this->code; $this->quotes["module"] = $this->title; $methods = array(); if ($method == "") { for ($i = 0; $i < count($this->type); $i++) { $methods[] = array ( "id" => $this->type[$i], "title" => $this->name[$this->type[$i]], "cost" => $this->price[$this->type[$i]] ); } } else { $methods[] = array ( "id" => $method, "title" => $this->name[$method], "cost" => $this->price[$method] ); } $this->quotes["methods"] = $methods; if ($this->tax_class > 0) { $this->quotes['tax'] = zen_get_tax_rate($this->tax_class, $order->delivery['country']['id'], $order->delivery['zone_id']); } if (zen_not_null($this->icon)) $this->quotes['icon'] = zen_image($this->icon, $this->title); return $this->quotes; } function check() { global $db; if (!isset($this->_check)) { $check_query = $db->Execute("select configuration_value from " . TABLE_CONFIGURATION . " where configuration_key = 'MODULE_SHIPPING_DOMESTIC_STATUS'"); $this->_check = $check_query->RecordCount(); } return $this->_check; } function install() { global $db; $db->Execute("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, set_function, date_added) values ('Enable Custom UPS Shipping', 'MODULE_SHIPPING_DOMESTIC_STATUS', 'True', 'Do you want to offer Custom UPS shipping?', '6', '0', 'zen_cfg_select_option(array(\'True\', \'False\'), ', now())"); $db->Execute("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_DOMESTIC_TAX_CLASS', '0', 'Use the following tax class on the shipping fee.', '6', '0', 'zen_get_tax_class_title', 'zen_cfg_pull_down_tax_classes(', now())"); $db->Execute("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_DOMESTIC_ZONE', '0', 'If a zone is selected, only enable this shipping method for that zone.', '6', '0', 'zen_get_zone_class_title', 'zen_cfg_pull_down_zone_classes(', now())"); $db->Execute("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, date_added) values ('Sort order of display.', 'MODULE_SHIPPING_DOMESTIC_SORT_ORDER', '0', 'Sort order of display. Lowest is displayed first.', '6', '0', now())"); } function remove() { global $db; $db->Execute("delete from " . TABLE_CONFIGURATION . " where configuration_key like 'MODULE_SHIPPING_DOMESTIC_%' "); } function keys() { return array ( 'MODULE_SHIPPING_DOMESTIC_STATUS', 'MODULE_SHIPPING_DOMESTIC_TAX_CLASS', 'MODULE_SHIPPING_DOMESTIC_ZONE', 'MODULE_SHIPPING_DOMESTIC_SORT_ORDER' ); } } ?>