public function tablerate_row_tier($row = 0, $tier = 0, array $attrs = array(), array $setting = array()) { $markup = parent::tablerate_row_tier(0, array(), array()); $this->widget('tablerate-row-tier', $markup); }
public function prepare_items() { $active = (array) shopp_setting('active_shipping'); $Shopp = Shopp::object(); $Shipping = $Shopp->Shipping; $Shipping->settings(); // Load all installed shipping modules for settings UIs $Shipping->ui(); // Setup setting UIs $settings = array(); // Registry of loaded settings for table-based shipping rates for JS $this->items = array(); // Registry for activated shipping rate modules $this->installed = array(); // Registry of available shipping modules installed foreach ($Shipping->active as $name => $Module) { if (version_compare($Shipping->modules[$name]->since, '1.2') == -1) { continue; } // Skip 1.1 modules, they are incompatible $default_name = strtolower($name); $fullname = $Module->methods(); $this->installed[$name] = $fullname; if ($Module->ui->tables) { $defaults[$default_name] = $Module->ui->settings(); $defaults[$default_name]['name'] = $fullname; $defaults[$default_name]['label'] = Shopp::__('Shipping Method'); } if (array_key_exists($name, $active)) { $ModuleSetting = $active[$name]; } else { continue; } // Not an activated shipping module, go to the next one $Entry = new StdClass(); $Entry->id = sanitize_title_with_dashes($name); $Entry->label = $Shipping->modules[$name]->name; $Entry->type = $Shipping->modules[$name]->name; $Entry->setting = $name; if ($this->request('id') == $Entry->setting) { $Entry->editor = $Module->ui(); } // Setup shipping service shipping rate entries and settings if (!is_array($ModuleSetting)) { $Entry->destinations = array($Shipping->active[$name]->destinations); $this->items[$name] = $Entry; continue; } // Setup shipping calcualtor shipping rate entries and settings foreach ($ModuleSetting as $id => $m) { $Entry->setting = "{$name}-{$id}"; $Entry->settings = shopp_setting($Entry->setting); if ($this->request('id') == $Entry->setting) { $Entry->editor = $Module->ui(); } if (isset($Entry->settings['label'])) { $Entry->label = $Entry->settings['label']; } $Entry->destinations = array(); $min = $max = false; if (isset($Entry->settings['table']) && is_array($Entry->settings['table'])) { foreach ($Entry->settings['table'] as $tablerate) { $destination = false; $d = ShippingSettingsUI::parse_location($tablerate['destination']); if (!empty($d['zone'])) { $Entry->destinations[] = $d['zone'] . ' (' . $d['countrycode'] . ')'; } elseif (!empty($d['area'])) { $Entry->destinations[] = $d['area']; } elseif (!empty($d['country'])) { $Entry->destinations[] = $d['country']; } elseif (!empty($d['region'])) { $Entry->destinations[] = $d['region']; } } if (!empty($Entry->destinations)) { $Entry->destinations = array_keys(array_flip($Entry->destinations)); } // Combine duplicate destinations } $this->items[$Entry->setting] = $Entry; $settings[$Entry->setting] = shopp_setting($Entry->setting); $settings[$Entry->setting]['id'] = $Entry->setting; $settings[$Entry->setting] = array_merge($defaults[$default_name], $settings[$Entry->setting]); if (isset($settings[$Entry->setting]['table'])) { usort($settings[$Entry->setting]['table'], array('ShippingFramework', '_sorttier')); foreach ($settings[$Entry->setting]['table'] as &$r) { if (isset($r['tiers'])) { usort($r['tiers'], array('ShippingFramework', '_sorttier')); } } } } // end foreach ( $ModuleSetting ) } // end foreach ( $Shipping->active ) $this->set_pagination_args(array('total_items' => count($this->items), 'total_pages' => 1)); $postcodes = ShoppLookup::postcodes(); foreach ($postcodes as &$postcode) { $postcode = !empty($postcode); } $lookup = array('regions' => array_merge(array('*' => Shopp::__('Anywhere')), ShoppLookup::regions()), 'regionmap' => ShoppLookup::regions('id'), 'countries' => ShoppLookup::countries(), 'areas' => ShoppLookup::country_areas(), 'zones' => ShoppLookup::country_zones(), 'postcodes' => $postcodesscre); shopp_custom_script('shiprates', ' var shipping = ' . json_encode(array_map('sanitize_title_with_dashes', array_keys($this->installed))) . ', defaults = ' . json_encode($defaults) . ', settings = ' . json_encode($settings) . ', lookup = ' . json_encode($lookup) . ';'); }
<?php } $hidden = get_hidden_columns('shopp_page_shopp-settings-shiprates'); $even = false; foreach ($shiprates as $setting => $module) { $shipping = shopp_setting($setting); $service = $Shipping->modules[$module]->name; if (isset($shipping['fallback']) && Shopp::str_true($shipping['fallback'])) { $service = '<big title="' . __('Fallback shipping real-time rate lookup failures', 'Shopp') . '">⎌</big> ' . $service; } $destinations = array(); $min = $max = false; if (isset($shipping['table']) && is_array($shipping['table'])) { foreach ($shipping['table'] as $tablerate) { $destination = false; $d = ShippingSettingsUI::parse_location($tablerate['destination']); if (!empty($d['zone'])) { $destinations[] = $d['zone'] . ' (' . $d['countrycode'] . ')'; } elseif (!empty($d['area'])) { $destinations[] = $d['area']; } elseif (!empty($d['country'])) { $destinations[] = $d['country']; } elseif (!empty($d['region'])) { $destinations[] = $d['region']; } } } if (!empty($destinations)) { $destinations = array_keys(array_flip($destinations)); } // Combine duplicate destinations