I've installed zones on shipping, loaded the countries and shipping table for 6 country zones But when I test it nothing works
The zones are in the data base - enable zones method is set to true the zones do not appear on the zones.php file (is this correct?)
Or have I missed something?
Shipping - Zones
-
Xpajun
- Contributor
- Posts: 187
- Joined: Thu Mar 04, 2021 1:18 pm
- Phoenix Version: v1.0.9.0
- Has thanked: 3 times
- Been thanked: 6 times
Re: Shipping - Zones
In addition:
If I change the name of the file from zones.php to airmail.php and upload to the shipping directories it does not show under Install Modules in Shipping
If I change the name of the file from zones.php to airmail.php and upload to the shipping directories it does not show under Install Modules in Shipping
Current Store is now running 1.0.9.0 - php 8.2.18
Now working on taking a short rest
- php 8.2.18
Now working on taking a short rest
-
Xpajun
- Contributor
- Posts: 187
- Joined: Thu Mar 04, 2021 1:18 pm
- Phoenix Version: v1.0.9.0
- Has thanked: 3 times
- Been thanked: 6 times
Re: Shipping - Zones
Perhaps better if I posted my altered code:
Code: Select all
class zones extends abstract_shipping_module {
const CONFIG_KEY_BASE = 'MODULE_SHIPPING_AIRMAIL_';
// CUSTOMIZE THIS SETTING FOR THE NUMBER OF ZONES NEEDED
const ZONE_COUNT = 6;
protected $destination_zone = false;
public function update_status_by($address) {
if (!$this->enabled || (false !== $this->destination_zone) || !isset($address['country']['iso_code_2'])) {
return;
}
for ($i = 1; $i <= static::ZONE_COUNT; $i++) {
if (in_array($address['country']['iso_code_2'], explode(';', $this->base_constant("COUNTRIES_$i")))) {
$this->destination_zone = $i;
return;
}
}
$this->enabled = false;
}
public function quote($method = '') {
global $order, $shipping_weight, $shipping_num_boxes;
$this->quotes = [
'id' => $this->code,
'module' => MODULE_SHIPPING_AIRMAIL_TEXT_TITLE,
'methods' => [],
];
if (false !== $this->destination_zone) {
$zones_table = preg_split('{[:,]}' , $this->base_constant("COST_{$this->destination_zone}"));
for ($i = 0, $size = count($zones_table); $i < $size; $i += 2) {
if ($shipping_weight <= $zones_table[$i]) {
$this->quotes['methods'][] = [
'id' => $this->code,
'title' => sprintf(MODULE_SHIPPING_AIRMAIL_TEXT_WAY,
$order->delivery['country']['iso_code_2'],
$shipping_weight),
'cost' => ((float)$zones_table[$i+1] * $GLOBALS['shipping_num_boxes'])
+ (float)$this->base_constant("HANDLING_{$this->destination_zone}"),
];
break;
}
}
if (!isset($this->quotes['methods'][0])) {
error_log(sprintf('Weight [%d] larger than maximum in table [%s] for [%s].',
$shipping_weight,
$this->base_constant("COST_$dest_zone"),
$order->delivery['country']['iso_code_2']));
}
}
$this->quote_common();
return $this->quotes;
}
protected function get_parameters() {
$parameters = [
$this->config_key_base . 'STATUS' => [
'title' => 'Enable Zones Method',
'value' => 'True',
'desc' => 'Do you want to offer airmail rate shipping?',
'set_func' => "Config::select_one(['True', 'False'], ",
],
$this->config_key_base . 'TAX_CLASS' => [
'title' => 'Tax Class',
'value' => '0',
'desc' => 'Use the following tax class on the shipping fee.',
'use_func' => 'Tax::get_class_title',
'set_func' => 'Config::select_tax_class(',
],
$this->config_key_base . 'SORT_ORDER' => [
'title' => 'Sort Order',
'value' => '0',
'desc' => 'Sort order of display.',
],
];
for ($i = 1; $i <= static::ZONE_COUNT; $i++) {
$parameters = array_merge($parameters, [
"{$this->config_key_base}COUNTRIES_$i" => [
'title' => "Zone $i Countries",
'value' => (($i == 1) ? 'US;CA' : ''),
'desc' => "Semi-colon separated list of two character ISO country codes that are part of Zone $i.",
],
"{$this->config_key_base}COST_$i" => [
'title' => "Zone $i Shipping Table",
'value' => '3:8.50,7:10.50,99:20.00',
'desc' => <<<"EOT"
Shipping rates to Zone $i destinations based on a group of maximum order weights.
Example: 3:8.50,7:10.50,...
Weights less than or equal to 3 would cost 8.50 for Zone $i destinations.
EOT
],
"{$this->config_key_base}HANDLING_$i" => [
'title' => "Zone $i Handling Fee",
'value' => '0',
'desc' => 'Handling Fee for this shipping zone',
],
]);
}
return $parameters;
}
}
Current Store is now running 1.0.9.0 - php 8.2.18
Now working on taking a short rest
- php 8.2.18
Now working on taking a short rest
-
ecartz
- Core Team
- Posts: 3084
- Joined: Tue Nov 05, 2019 6:02 pm
- Phoenix Version:
- Has thanked: 4 times
- Been thanked: 208 times
Re: Shipping - Zones
Code: Select all
class airmail extends abstract_shipping_module {-
Xpajun
- Contributor
- Posts: 187
- Joined: Thu Mar 04, 2021 1:18 pm
- Phoenix Version: v1.0.9.0
- Has thanked: 3 times
- Been thanked: 6 times
Re: Shipping - Zones
Doh... Thank you Matt - long day yesterdayecartz wrote: ↑Thu Apr 11, 2024 6:56 amOther than that, it looks fine. Note that if you are making a new file, you need a new language file too. The language file constants should be, e.g., MODULE_SHIPPING_AIRMAIL_TEXT_TITLE.Code: Select all
class airmail extends abstract_shipping_module {
Yes I have the language file as well, it is loading now
But is still not loading on checkout
Both the Flat and Table Rates show but not the Zones or my new AirmailXpajun wrote: ↑Wed Apr 10, 2024 4:57 pm I've installed zones on shipping, loaded the countries and shipping table for 6 country zones But when I test it nothing works
The zones are in the data base - enable zones method is set to true the zones do not appear on the zones.php file (is this correct?)
Or have I missed something?
Current Store is now running 1.0.9.0 - php 8.2.18
Now working on taking a short rest
- php 8.2.18
Now working on taking a short rest
-
Xpajun
- Contributor
- Posts: 187
- Joined: Thu Mar 04, 2021 1:18 pm
- Phoenix Version: v1.0.9.0
- Has thanked: 3 times
- Been thanked: 6 times
Re: Shipping - Zones
One day I will learn to read instead of assuming - I was working on the old principal of putting a comma between the country code rather than a semi-colon
Thanks Matt for your help (I will have another query on the shipping files later)
Thanks Matt for your help (I will have another query on the shipping files later)
Current Store is now running 1.0.9.0 - php 8.2.18
Now working on taking a short rest
- php 8.2.18
Now working on taking a short rest
-
14Steve14
- Senior Contributor
- Posts: 923
- Joined: Fri Oct 25, 2019 7:01 pm
- Phoenix Version: v1.0.9.1
- Has thanked: 17 times
- Been thanked: 103 times
-
14Steve14
- Senior Contributor
- Posts: 923
- Joined: Fri Oct 25, 2019 7:01 pm
- Phoenix Version: v1.0.9.1
- Has thanked: 17 times
- Been thanked: 103 times