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

Commit

Permalink
- Mise à jour de la configuration à l'activation du module
Browse files Browse the repository at this point in the history
  • Loading branch information
kkhelifa-opendsi committed Mar 10, 2023
1 parent 45008c8 commit 8974667
Show file tree
Hide file tree
Showing 3 changed files with 53 additions and 1 deletion.
1 change: 1 addition & 0 deletions ChangeLog.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

## 4.1.40.0
- Correction de l'enregistrement des correspondances entre statuts des commandes de dolibarr vers WooCommerce
- Mise à jour de la configuration à l'activation du module

## 4.1.39.0
- Optimisation et correction de la tache planifiée de mise à jour des stocks
Expand Down
38 changes: 38 additions & 0 deletions class/data/eCommerceSite.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -847,6 +847,44 @@ function setEntityValues($entity)
}
}

/**
* Upgrade the parameters configuration to the new setup
*
* @return int <0 if KO, >0 if OK
*/
public function upgradeParameters()
{
global $user;

// setup
if (!isset($this->authentication_type)) $this->authentication_type = 'oauth1_header';
// stock
if (!isset($this->parameters['order_actions']['valid_invoice_fk_warehouse'])) $this->parameters['order_actions']['valid_invoice_fk_warehouse'] = $this->parameters['order_actions']['valid_order_fk_warehouse'];
if (!isset($this->parameters['order_actions']['valid_supplier_invoice_fk_warehouse'])) $this->parameters['order_actions']['valid_supplier_invoice_fk_warehouse'] = $this->parameters['order_actions']['valid_order_fk_warehouse'];
// extra fields
$table_elements = [ 'societe', 'product', 'commande', 'commandedet' ];
foreach ($table_elements as $table_element) {
if (!isset($this->parameters['extra_fields'][$table_element])) {
if (isset($this->parameters['ef_crp'][$table_element])) {
foreach ($this->parameters['ef_crp'][$table_element] as $key => $info) {
$this->parameters['extra_fields'][$table_element]['activated']['mdt'][$key] = $info['activated'];
$this->parameters['extra_fields'][$table_element]['values']['mdt'][$key] = $info['correspondences'];
}
}
if ($table_element == 'product' && isset($this->parameters['ef_crp_attribute'])) {
foreach ($this->parameters['ef_crp_attribute'] as $key => $info) {
$this->parameters['extra_fields'][$table_element]['activated']['att'][$key] = $info['activated'];
$this->parameters['extra_fields'][$table_element]['values']['att'][$key] = $info['correspondences'];
}
}
}
}
if (isset($this->parameters['ef_crp'])) unset($this->parameters['ef_crp']);
if (isset($this->parameters['ef_crp_attribute'])) unset($this->parameters['ef_crp_attribute']);

return $this->update($user);
}

/**
* Method to output saved errors
*
Expand Down
15 changes: 14 additions & 1 deletion core/modules/modECommerceNg.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -454,9 +454,22 @@ function init($options = '')
// Delete semaphore token for cron jobs
require_once DOL_DOCUMENT_ROOT . '/core/lib/admin.lib.php';
dolibarr_del_const($this->db, 'ECOMMERCE_PROCESSING_WEBHOOK_SYNCHRONIZATION', 0);
dolibarr_del_const($this->db, 'ECOMMERCE_CHECK_WEBHOOKS_STATUS', 0);

$result=$this->load_tables($options);

// Upgrade site configuration to new setup cards
$eCommerceSite = new eCommerceSite($this->db);
$sites = $eCommerceSite->listSites('object');
if (is_array($sites)) {
foreach ($sites as $site) {
$result = $site->upgradeParameters();
if ($result < 0) {
setEventMessages($site->error, $site->errors, 'errors');
return 0;
}
}
}

$this->addSettlementTerms();
$this->addAnonymousCompany();
return $this->_init($sql, $options);
Expand Down

0 comments on commit 8974667

Please sign in to comment.