Skip to content
This repository has been archived by the owner on Oct 4, 2024. It is now read-only.

Commit

Permalink
Merge pull request #153 from OPEN-DSI/2024_rc
Browse files Browse the repository at this point in the history
- Correction et amelioration du support WPML pour les produits variab…
  • Loading branch information
kkhelifa-opendsi authored Aug 30, 2024
2 parents c1c47d1 + 1b3ef82 commit eea1395
Show file tree
Hide file tree
Showing 4 changed files with 54 additions and 10 deletions.
7 changes: 6 additions & 1 deletion ChangeLog.md
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
14.0.11
14.0.12
7 changes: 6 additions & 1 deletion class/business/eCommerceSynchro.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
48 changes: 41 additions & 7 deletions class/data/woocommerce/eCommerceRemoteAccessWoocommerce.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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.
],
Expand All @@ -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.
],
];
}
Expand Down Expand Up @@ -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");
Expand Down

0 comments on commit eea1395

Please sign in to comment.