diff --git a/ChangeLog.md b/ChangeLog.md index 6fcf63f..9e96768 100644 --- a/ChangeLog.md +++ b/ChangeLog.md @@ -1,5 +1,9 @@ # ChangeLog +## [14.0.12] - 30-08-2024 +- Correction et amelioration du support WPML pour les produits variables traduits synchronisés +- Correction de la recuperation de l'id du pays pour les code pays des domtom + ## [14.0.11] - 22-08-2024 - Correction et amelioration du support WPML pour les produits variables traduits synchronisés - Correction de warnings et divers @@ -931,7 +935,8 @@ - Initial version. -[Non Distribué]: https://github.com/OPEN-DSI/ecommerceng_woosync/compare/14.0.11...HEAD +[Non Distribué]: https://github.com/OPEN-DSI/ecommerceng_woosync/compare/14.0.12...HEAD +[14.0.12]: https://github.com/OPEN-DSI/ecommerceng_woosync/commits/14.0.12 [14.0.11]: https://github.com/OPEN-DSI/ecommerceng_woosync/commits/14.0.11 [14.0.10]: https://github.com/OPEN-DSI/ecommerceng_woosync/commits/14.0.10 [14.0.9]: https://github.com/OPEN-DSI/ecommerceng_woosync/commits/14.0.9 diff --git a/VERSION b/VERSION index 6bd3187..c859491 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -14.0.11 \ No newline at end of file +14.0.12 \ No newline at end of file diff --git a/class/business/eCommerceSynchro.class.php b/class/business/eCommerceSynchro.class.php index f543ceb..20026bd 100755 --- a/class/business/eCommerceSynchro.class.php +++ b/class/business/eCommerceSynchro.class.php @@ -3690,10 +3690,15 @@ public function synchronizeProduct($product_data, $object_origin = null) } } } + } + if (!$error && (!$bypass || + count(array_diff($this->eCommerceProduct->other_data['translations_ids'] ?? [], $product_data['other_data']['translations_ids'] ?? [])) > 0 || + count(array_diff($product_data['other_data']['translations_ids'] ?? [], $this->eCommerceProduct->other_data['translations_ids'] ?? [])) > 0) + ) { // Update the link of the synchronization //-------------------------------------------- - if (!$error && !empty($product_data['remote_id'])) { + if (!empty($product_data['remote_id'])) { $this->eCommerceProduct->last_update = $product_data['last_update']; if ($this->eCommerceSite->stock_sync_direction == 'ecommerce2dolibarr') $this->eCommerceProduct->last_update_stock = $product_data['last_update']; $this->eCommerceProduct->fk_product = $product->id > 0 ? $product->id : 0; diff --git a/class/data/woocommerce/eCommerceRemoteAccessWoocommerce.class.php b/class/data/woocommerce/eCommerceRemoteAccessWoocommerce.class.php index d732c3c..e48c2be 100755 --- a/class/data/woocommerce/eCommerceRemoteAccessWoocommerce.class.php +++ b/class/data/woocommerce/eCommerceRemoteAccessWoocommerce.class.php @@ -620,7 +620,7 @@ public function convertCustomerDataIntoProcessedData($remote_data) 'address' => $remote_data['billing']['address_1'] . (!empty($remote_data['billing']['address_1']) && !empty($remote_data['billing']['address_2']) ? "\n" : "") . $remote_data['billing']['address_2'], 'zip' => $remote_data['billing']['postcode'], 'town' => $remote_data['billing']['city'], - 'country_id' => getCountry($remote_data['billing']['country'], 3), + 'country_id' => $this->getCountryId($remote_data['billing']['country'], 3), 'phone' => $remote_data['billing']['phone'], 'default_lang' => $mysoc->default_lang, 'remote_datas' => $remote_data, @@ -740,7 +740,7 @@ public function convertRemoteObjectIntoDolibarrSocpeople($remoteCompany) 'address' => $bContact['address_1'] . (!empty($bContact['address_1']) && !empty($bContact['address_2']) ? "\n" : "") . $bContact['address_2'], 'zip' => $bContact['postcode'], 'town' => $bContact['city'], - 'country_id' => getCountry($bContact['country'], 3), + 'country_id' => $this->getCountryId($bContact['country'], 3), 'email' => !empty($bContact['email']) ? $bContact['email'] : $remoteCompany['email'], 'phone' => $bContact['phone'], 'fax' => null, @@ -776,7 +776,7 @@ public function convertRemoteObjectIntoDolibarrSocpeople($remoteCompany) 'address' => $sContact['address_1'] . (!empty($sContact['address_1']) && !empty($sContact['address_2']) ? "\n" : "") . $sContact['address_2'], 'zip' => $sContact['postcode'], 'town' => $sContact['city'], - 'country_id' => getCountry($sContact['country'], 3), + 'country_id' => $this->getCountryId($sContact['country'], 3), 'email' => null, 'phone' => null, 'fax' => null, @@ -2027,7 +2027,7 @@ public function convertOrderDataIntoProcessedData($remote_data) 'address' => $bContact['address_1'] . (!empty($bContact['address_1']) && !empty($bContact['address_2']) ? "\n" : "") . $bContact['address_2'], 'zip' => $bContact['postcode'], 'town' => $bContact['city'], - 'country_id' => getCountry($bContact['country'], 3), + 'country_id' => $this->getCountryId($bContact['country'], 3), 'email' => $bContact['email'], 'phone' => $bContact['phone'], 'fax' => null, @@ -2078,7 +2078,7 @@ public function convertOrderDataIntoProcessedData($remote_data) 'address' => $sContact['address_1'] . (!empty($sContact['address_1']) && !empty($sContact['address_2']) ? "\n" : "") . $sContact['address_2'], 'zip' => $sContact['postcode'], 'town' => $sContact['city'], - 'country_id' => getCountry($sContact['country'], 3), + 'country_id' => $this->getCountryId($sContact['country'], 3), 'email' => $email, 'phone' => isset($sContact['phone']) ? $sContact['phone'] : null, 'fax' => null, @@ -4109,7 +4109,7 @@ public function updateRemoteSocpeople($remote_id, $object) 'city' => $object->town, // string City name. //'state' => '', // string ISO code or name of the state, province or district. 'postcode' => $object->zip, // string Postal code. - 'country' => getCountry($object->country_id, 2), // string ISO code of the country. + 'country' => $this->getCountryId($object->country_id, 2), // string ISO code of the country. 'email' => $object->email, // string Email address. 'phone' => $object->phone_pro, // string Phone number. ], @@ -4127,7 +4127,7 @@ public function updateRemoteSocpeople($remote_id, $object) 'city' => $object->town, // string City name. //'state' => '', // string ISO code or name of the state, province or district. 'postcode' => $object->zip, // string Postal code. - 'country' => getCountry($object->country_id, 2), // string ISO code of the country. + 'country' => $this->getCountryId($object->country_id, 2), // string ISO code of the country. ], ]; } @@ -5830,6 +5830,40 @@ private function getDateTimeToGMTDateTime($datetime) return $dt; } + /** + * Get country ID from CODE. + * + * @param string|int $searchkey Id or code of country to search + * @param string $withcode '0'=Return label, + * '1'=Return code + label, + * '2'=Return code from id, + * '3'=Return id from code, + * 'all'=Return array('id'=>,'code'=>,'label'=>) + * + * @return int|string =0 if not found, >0 if OK + */ + private function getCountryId($searchkey, $withcode = '3') + { + // Translate country code for state in real country code + if ($withcode == 3) { + if (in_array($searchkey, [ 'MQ', 'YT', 'GP', 'GF', 'RE' ])) $searchkey = 'FR'; + } + + $result = getCountry($searchkey, $withcode); + if (empty($result) && $withcode == 2) { + $result = (int) $result; + } elseif ($result == 'NotDefined') { + $this->errors[] = "Country code $searchkey not found."; + dol_syslog(__METHOD__ . " - (Code: $searchkey, Mode: $withcode) " . $this->errorsToString(), LOG_ERR); + } elseif ($result == 'error') { + $this->errors[] = "Error when search country code."; + $this->errors[] = $this->db->lasterror(); + dol_syslog(__METHOD__ . " - (Code: $searchkey, Mode: $withcode) " . $this->errorsToString(), LOG_ERR); + } + + return $result; + } + public function __destruct() { ini_set("memory_limit", "528M");