Skip to content

Commit

Permalink
Version 3.1.0
Browse files Browse the repository at this point in the history
  • Loading branch information
luigifab committed Feb 3, 2023
1 parent 2076b43 commit bbce2bf
Show file tree
Hide file tree
Showing 13 changed files with 2,350 additions and 556 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ To display delivery times, you must edit your template with:

## Copyright and Credits

- Current version: 3.0.0 (02/02/2023)
- Current version: 3.1.0 (03/02/2023)
- Compatibility: OpenMage 19.x / 20.x / 21.x, PHP 7.2 / 7.3 / 7.4 / 8.0 / 8.1 / 8.2
- Client compatibility: Firefox 36+, Chrome 32+, Opera 19+, Edge 16+, Safari 9+
- Translations: English (en), French (fr-FR/fr-CA), German (de), Italian (it), Portuguese (pt-PT/pt-BR), Spanish (es) / Chinese (zh), Czech (cs), Dutch (nl), Greek (el), Hungarian (hu), Japanese (ja), Polish (pl), Romanian (ro), Russian (ru), Slovak (sk), Turkish (tr), Ukrainian (uk)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?php
/**
* Created V/17/07/2020
* Updated J/29/12/2022
* Updated V/03/02/2023
*
* Copyright 2019-2023 | Fabrice Creuzot <fabrice~cellublue~com>
* Copyright 2019-2022 | Jérôme Siau <jerome~cellublue~com>
Expand Down Expand Up @@ -280,22 +280,23 @@ protected function getArrayData(object $rate, int $storeId, string $country, $po
$key = empty($key) ? $code : $code.$key;
$price = $this->getCarrierPrice($rate, $storeId);

$config = @unserialize(Mage::getStoreConfig('shippingmax_times/'.$country.'/config', $storeId), ['allowed_classes' => false]);
return [
'code' => $code,
'name' => ($rate->getData('carrier_title') != $rate->getData('method_title')) ?
$rate->getData('carrier_title').' / '.$rate->getData('method_title') : $rate->getData('carrier_title'),
'country' => $country,
'postcode' => $postcode,
'name1min' => 'groups['.$country.'][fields][cnf1min_'.$key.'][value]',
'name1max' => 'groups['.$country.'][fields][cnf1max_'.$key.'][value]',
'name2min' => 'groups['.$country.'][fields][cnf2min_'.$key.'][value]',
'name2max' => 'groups['.$country.'][fields][cnf2max_'.$key.'][value]',
'name3' => 'groups['.$country.'][fields][cnf3_'.$key.'][value]',
'cnf1min' => Mage::getStoreConfig('shippingmax_times/'.$country.'/cnf1min_'.$key, $storeId),
'cnf1max' => Mage::getStoreConfig('shippingmax_times/'.$country.'/cnf1max_'.$key, $storeId),
'cnf2min' => Mage::getStoreConfig('shippingmax_times/'.$country.'/cnf2min_'.$key, $storeId),
'cnf2max' => Mage::getStoreConfig('shippingmax_times/'.$country.'/cnf2max_'.$key, $storeId),
'cnf3' => Mage::getStoreConfigFlag('shippingmax_times/'.$country.'/cnf3_'.$key, $storeId),
'name1min' => 'groups['.$country.'][fields][config][value][cnf1min_'.$key.']',
'name1max' => 'groups['.$country.'][fields][config][value][cnf1max_'.$key.']',
'name2min' => 'groups['.$country.'][fields][config][value][cnf2min_'.$key.']',
'name2max' => 'groups['.$country.'][fields][config][value][cnf2max_'.$key.']',
'name3' => 'groups['.$country.'][fields][config][value][cnf3_'.$key.']',
'cnf1min' => $config['cnf1min_'.$key] ?? '',
'cnf1max' => $config['cnf1max_'.$key] ?? '',
'cnf2min' => $config['cnf2min_'.$key] ?? '',
'cnf2max' => $config['cnf2max_'.$key] ?? '',
'cnf3' => $config['cnf3_'.$key] ?? '',
'price' => [$price => $price],
];
}
Expand Down
33 changes: 17 additions & 16 deletions src/app/code/community/Kyrena/Shippingmax/Helper/Data.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?php
/**
* Created V/12/04/2019
* Updated S/14/01/2023
* Updated V/03/02/2023
*
* Copyright 2019-2023 | Fabrice Creuzot <fabrice~cellublue~com>
* Copyright 2019-2022 | Jérôme Siau <jerome~cellublue~com>
Expand Down Expand Up @@ -173,6 +173,7 @@ public function getShippingDate(string $code, bool $days = false, $country = nul
$fake = Mage::getModel('customer/address')->setData('country_id', $country)->setData('postcode', $postcode);
$country = Mage::getBlockSingleton('shippingmax/rewrite_renderer')->render($fake, 'country');
$storeId = is_null($storeId) ? Mage::app()->getStore()->getId() : $storeId;
$config = @unserialize(Mage::getStoreConfig('shippingmax_times/'.$country.'/config', $storeId), ['allowed_classes' => false]);

// recherche des délais
// pour shippingmax_chronorelais_cyz_xyz puis pour shippingmax_chronorelais_xyz
Expand All @@ -181,11 +182,11 @@ public function getShippingDate(string $code, bool $days = false, $country = nul
if (empty($postcode)) {
// délai sans postcode
$key = $rateCode;
$cnf1min = (int) Mage::getStoreConfig('shippingmax_times/'.$country.'/cnf1min_'.$key, $storeId);
$cnf1max = (int) Mage::getStoreConfig('shippingmax_times/'.$country.'/cnf1max_'.$key, $storeId);
$cnf2min = (int) Mage::getStoreConfig('shippingmax_times/'.$country.'/cnf2min_'.$key, $storeId);
$cnf2max = (int) Mage::getStoreConfig('shippingmax_times/'.$country.'/cnf2max_'.$key, $storeId);
$cnf3 = Mage::getStoreConfigFlag('shippingmax_times/'.$country.'/cnf3_'.$key, $storeId);
$cnf1min = (int) ($config['cnf1min_'.$key] ?? 0);
$cnf1max = (int) ($config['cnf1max_'.$key] ?? 0);
$cnf2min = (int) ($config['cnf2min_'.$key] ?? 0);
$cnf2max = (int) ($config['cnf2max_'.$key] ?? 0);
$cnf3 = $config['cnf3_'.$key] ?? false;
if (!empty($cnf2min))
break;
}
Expand All @@ -194,22 +195,22 @@ public function getShippingDate(string $code, bool $days = false, $country = nul
while (--$nb >= 2) {
// délai avec postcode
$key = $rateCode.'_'.mb_substr(trim($postcode), 0, $nb);
$cnf1min = (int) Mage::getStoreConfig('shippingmax_times/'.$country.'/cnf1min_'.$key, $storeId);
$cnf1max = (int) Mage::getStoreConfig('shippingmax_times/'.$country.'/cnf1max_'.$key, $storeId);
$cnf2min = (int) Mage::getStoreConfig('shippingmax_times/'.$country.'/cnf2min_'.$key, $storeId);
$cnf2max = (int) Mage::getStoreConfig('shippingmax_times/'.$country.'/cnf2max_'.$key, $storeId);
$cnf3 = Mage::getStoreConfigFlag('shippingmax_times/'.$country.'/cnf3_'.$key, $storeId);
$cnf1min = (int) ($config['cnf1min_'.$key] ?? 0);
$cnf1max = (int) ($config['cnf1max_'.$key] ?? 0);
$cnf2min = (int) ($config['cnf2min_'.$key] ?? 0);
$cnf2max = (int) ($config['cnf2max_'.$key] ?? 0);
$cnf3 = $config['cnf3_'.$key] ?? false;
if (!empty($cnf2min))
break 2;
}
if (empty($cnf2min)) {
// délai sans postcode
$key = $rateCode;
$cnf1min = (int) Mage::getStoreConfig('shippingmax_times/'.$country.'/cnf1min_'.$key, $storeId);
$cnf1max = (int) Mage::getStoreConfig('shippingmax_times/'.$country.'/cnf1max_'.$key, $storeId);
$cnf2min = (int) Mage::getStoreConfig('shippingmax_times/'.$country.'/cnf2min_'.$key, $storeId);
$cnf2max = (int) Mage::getStoreConfig('shippingmax_times/'.$country.'/cnf2max_'.$key, $storeId);
$cnf3 = Mage::getStoreConfigFlag('shippingmax_times/'.$country.'/cnf3_'.$key, $storeId);
$cnf1min = (int) ($config['cnf1min_'.$key] ?? 0);
$cnf1max = (int) ($config['cnf1max_'.$key] ?? 0);
$cnf2min = (int) ($config['cnf2min_'.$key] ?? 0);
$cnf2max = (int) ($config['cnf2max_'.$key] ?? 0);
$cnf3 = $config['cnf3_'.$key] ?? false;
if (!empty($cnf2min))
break;
}
Expand Down
4 changes: 2 additions & 2 deletions src/app/code/community/Kyrena/Shippingmax/etc/config.xml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
* Created V/12/04/2019
* Updated L/23/01/2023
* Updated V/03/02/2023
*
* Copyright 2019-2023 | Fabrice Creuzot <fabrice~cellublue~com>
* Copyright 2019-2022 | Jérôme Siau <jerome~cellublue~com>
Expand All @@ -21,7 +21,7 @@
<config>
<modules>
<Kyrena_Shippingmax>
<version>3.0.0</version>
<version>3.1.0</version>
</Kyrena_Shippingmax>
</modules>
<global>
Expand Down
Loading

0 comments on commit bbce2bf

Please sign in to comment.