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

Commit

Permalink
4.0.103.0:
Browse files Browse the repository at this point in the history
- Le lien de l'image fournt a woocommerce comptient le nom reel de l'image
- Le nom de l'image sans son extension est fournit comme nom et nom alternatif a woocommerce
- Ajout de la synchronisation de la hauteur, largeur et profondeur du produit avec woocommerce
- Correction de l'envoi de la description du produit vers woocommerce

4.0.102.0:
- Ajout d'un script executant l'action du bouton de synchro des produits de Dolibarr vers le site
  • Loading branch information
kamel committed Mar 11, 2022
1 parent 2f712fe commit 1d8ce9c
Show file tree
Hide file tree
Showing 10 changed files with 362 additions and 14 deletions.
9 changes: 9 additions & 0 deletions ChangeLog.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,14 @@
# ChangeLog

## 4.0.103.0
- Le lien de l'image fournt a woocommerce comptient le nom reel de l'image
- Le nom de l'image sans son extension est fournit comme nom et nom alternatif a woocommerce
- Ajout de la synchronisation de la hauteur, largeur et profondeur du produit avec woocommerce
- Correction de l'envoi de la description du produit vers woocommerce

## 4.0.102.0
- Ajout d'un script executant l'action du bouton de synchro des produits de Dolibarr vers le site

## 4.0.101.0
- Compatibilité v13+ pour la gestion des champs complémentaires
- Ajout du triggers sur la creation du lien d'une commande
Expand Down
6 changes: 5 additions & 1 deletion admin/eCommerceSetup.php
Original file line number Diff line number Diff line change
Expand Up @@ -331,6 +331,7 @@
'description' => isset($_POST['ecommerce_product_description_synch_direction']) ? GETPOST('ecommerce_product_description_synch_direction', 'alpha') : 'etod',
'short_description' => isset($_POST['ecommerce_product_short_description_synch_direction']) ? GETPOST('ecommerce_product_short_description_synch_direction', 'alpha') : 'etod',
'weight' => isset($_POST['ecommerce_product_weight_synch_direction']) ? GETPOST('ecommerce_product_weight_synch_direction', 'alpha') : 'etod',
'dimension' => isset($_POST['ecommerce_product_dimension_synch_direction']) ? GETPOST('ecommerce_product_dimension_synch_direction', 'alpha') : 'etod',
'tax' => isset($_POST['ecommerce_product_tax_synch_direction']) ? GETPOST('ecommerce_product_tax_synch_direction', 'alpha') : 'etod',
'status' => isset($_POST['ecommerce_product_status_synch_direction']) ? GETPOST('ecommerce_product_status_synch_direction', 'alpha') : 'etod',
);
Expand Down Expand Up @@ -361,6 +362,7 @@
'product_synch_direction' => $ecommerceProductSynchDirection,
'product_synch_price' => $ecommerceProductSynchPrice,
'product_weight_units' => $_POST['ecommerce_product_weight_units'],
'product_dimension_units' => $_POST['ecommerce_product_dimension_units'],
'product_variation_mode' => GETPOSTISSET('ecommerce_product_variation_mode') ? GETPOST('ecommerce_product_variation_mode', 'aZ09') : 'one_to_one',
'customer_roles' => $ecommerceWoocommerceCustomerRoles,
'create_invoice_type' => $ecommerceCreateInvoiceType,
Expand Down Expand Up @@ -1007,13 +1009,15 @@
}

$ecommerceProductWeightUnits = (isset($siteDb->parameters['product_weight_units']) ? $siteDb->parameters['product_weight_units'] : (empty($conf->global->MAIN_WEIGHT_DEFAULT_UNIT)?0:$conf->global->MAIN_WEIGHT_DEFAULT_UNIT));
$ecommerceProductDimensionUnits = (isset($siteDb->parameters['product_dimension_units']) ? $siteDb->parameters['product_dimension_units'] : -2); // -2 = cm

$ecommerceProductSynchPrice = isset($siteDb->parameters['product_synch_price']) ? $siteDb->parameters['product_synch_price'] : 'regular';
$ecommerceProductImageSynchDirection = isset($siteDb->parameters['product_synch_direction']['image']) ? $siteDb->parameters['product_synch_direction']['image'] : 'etod';
$ecommerceProductRefSynchDirection = isset($siteDb->parameters['product_synch_direction']['ref']) ? $siteDb->parameters['product_synch_direction']['ref'] : 'etod';
$ecommerceProductDescriptionSynchDirection = isset($siteDb->parameters['product_synch_direction']['description']) ? $siteDb->parameters['product_synch_direction']['description'] : 'etod';
$ecommerceProductShortDescriptionSynchDirection = isset($siteDb->parameters['product_synch_direction']['short_description']) ? $siteDb->parameters['product_synch_direction']['short_description'] : 'etod';
$ecommerceProductWeightSynchDirection = isset($siteDb->parameters['product_synch_direction']['weight']) ? $siteDb->parameters['product_synch_direction']['weight'] : 'etod';
$ecommerceProductWeightSynchDirection = isset($siteDb->parameters['product_synch_direction']['weight']) ? $siteDb->parameters['product_synch_direction']['weight'] : 'etod';
$ecommerceProductDimensionSynchDirection = isset($siteDb->parameters['product_synch_direction']['dimension']) ? $siteDb->parameters['product_synch_direction']['dimension'] : 'etod';
$ecommerceProductTaxSynchDirection = isset($siteDb->parameters['product_synch_direction']['tax']) ? $siteDb->parameters['product_synch_direction']['tax'] : 'etod';
$ecommerceProductStatusSynchDirection = isset($siteDb->parameters['product_synch_direction']['status']) ? $siteDb->parameters['product_synch_direction']['status'] : 'etod';
$ecommerceProductVariationMode = isset($siteDb->parameters['product_variation_mode']) ? $siteDb->parameters['product_variation_mode'] : 'one_to_one';
Expand Down
22 changes: 22 additions & 0 deletions admin/tpl/eCommerceSetup.tpl.php
Original file line number Diff line number Diff line change
Expand Up @@ -559,6 +559,28 @@ function(token) {
</td>
<td><?php print $langs->trans('ECommerceProductWeightUnitsDescription') ?></td>
</tr>
<tr <?php print $bc[$var] ?>>
<td><span><?php print $langs->trans('ECommerceProductDimensionSyncDirection') ?></span></td>
<td>
<?php
print $form->selectarray('ecommerce_product_dimension_synch_direction', $sync_direction_array, $ecommerceProductDimensionSynchDirection);
?>
</td>
<td><?php print $langs->trans('ECommerceProductDimensionSyncDirectionDescription') ?></td>
</tr>
<tr <?php print $bc[$var] ?>>
<td><span><?php print $langs->trans('ECommerceProductDimensionUnits') ?></span></td>
<td>
<?php
if (version_compare(DOL_VERSION, "10.0.0") < 0) {
print $formproduct->select_measuring_units("ecommerce_product_dimension_units", "size", $ecommerceProductDimensionUnits);
} else {
print $formproduct->selectMeasuringUnits("ecommerce_product_dimension_units", "size", $ecommerceProductDimensionUnits, 0, 2);
}
?>
</td>
<td><?php print $langs->trans('ECommerceProductDimensionUnitsDescription') ?></td>
</tr>
<tr <?php print $bc[$var] ?>>
<td><span><?php print $langs->trans('ECommerceProductTaxSyncDirection') ?></span></td>
<td>
Expand Down
8 changes: 7 additions & 1 deletion class/business/eCommerceSynchro.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ class eCommerceSynchro
private $commandeToUpdate;
private $factureToUpdate;

private $cache_categories;
public $cache_categories;

public $payment_gateways_cached;
public $product_category_cached;
Expand Down Expand Up @@ -3630,6 +3630,12 @@ public function synchronizeProduct($product_data, $object_origin = null)
$product->description = isset($product_data['description']) ? $product_data['description'] : $product->description;
$product->weight = isset($product_data['weight']) ? $product_data['weight'] : $product->weight;
$product->weight_units = isset($product_data['weight_units']) ? $product_data['weight_units'] : $product->weight_units;
$product->width = isset($product_data['width']) ? $product_data['width'] : $product->width;
$product->width_units = isset($product_data['width_units']) ? $product_data['width_units'] : $product->width_units;
$product->height = isset($product_data['height']) ? $product_data['height'] : $product->height;
$product->height_units = isset($product_data['height_units']) ? $product_data['height_units'] : $product->height_units;
$product->length = isset($product_data['length']) ? $product_data['length'] : $product->length;
$product->length_units = isset($product_data['length_units']) ? $product_data['length_units'] : $product->length_units;
$product->type = $product_data['fk_product_type'];
$product->finished = $product_data['finished'];
$product->status = $product_data['envente'];
Expand Down
56 changes: 47 additions & 9 deletions class/data/woocommerce/eCommerceRemoteAccessWoocommerce.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -985,9 +985,11 @@ public function convertProductDataIntoProcessedData($remote_data, $parent_remote
$productDescriptionSynchDirection = isset($this->site->parameters['product_synch_direction']['description']) ? $this->site->parameters['product_synch_direction']['description'] : '';
$productShortDescriptionSynchDirection = isset($this->site->parameters['product_synch_direction']['short_description']) ? $this->site->parameters['product_synch_direction']['short_description'] : '';
$productWeightSynchDirection = isset($this->site->parameters['product_synch_direction']['weight']) ? $this->site->parameters['product_synch_direction']['weight'] : '';
$productDimensionSynchDirection = isset($this->site->parameters['product_synch_direction']['dimension']) ? $this->site->parameters['product_synch_direction']['dimension'] : '';
$productTaxSynchDirection = isset($this->site->parameters['product_synch_direction']['tax']) ? $this->site->parameters['product_synch_direction']['tax'] : '';
$productStatusSynchDirection = isset($this->site->parameters['product_synch_direction']['status']) ? $this->site->parameters['product_synch_direction']['status'] : '';
$productWeightUnits = isset($this->site->parameters['product_weight_units']) ? $this->site->parameters['product_weight_units'] : (empty($conf->global->MAIN_WEIGHT_DEFAULT_UNIT)?0:$conf->global->MAIN_WEIGHT_DEFAULT_UNIT);
$productDimensionUnits = isset($this->site->parameters['product_dimension_units']) ? $this->site->parameters['product_dimension_units'] : -2; // -2 = cm
$product_variation_mode_all_to_one = !empty($this->site->parameters['product_variation_mode']) && $this->site->parameters['product_variation_mode'] == 'all_to_one';

// Categories
Expand Down Expand Up @@ -1115,6 +1117,15 @@ public function convertProductDataIntoProcessedData($remote_data, $parent_remote
$product['weight'] = empty($remote_data->weight) ? $parent_remote_data->weight : $remote_data->weight;
$product['weight_units'] = $productWeightUnits;
}
// Synchronize weight
if ($productDimensionSynchDirection == 'etod' || $productDimensionSynchDirection == 'all') {
$product['width'] = empty($remote_data->dimensions->width) ? $parent_remote_data->dimensions->width : $remote_data->dimensions->width;
$product['width_units'] = $productDimensionUnits;
$product['height'] = empty($remote_data->dimensions->height) ? $parent_remote_data->dimensions->height : $remote_data->dimensions->height;
$product['height_units'] = $productDimensionUnits;
$product['length'] = empty($remote_data->dimensions->length) ? $parent_remote_data->dimensions->length : $remote_data->dimensions->length;
$product['length_units'] = $productDimensionUnits;
}
// Synchronize tax
$tax_info = $this->getTaxInfoFromTaxClass(empty($remote_data->tax_class) ? $parent_remote_data->tax_class : $remote_data->tax_class, empty($remote_data->tax_status) ? $parent_remote_data->tax_status : $remote_data->tax_status);
if (!$isVariation) $product['tax_rate'] = $tax_info['tax_rate'];
Expand Down Expand Up @@ -1977,7 +1988,8 @@ public function convertObjectIntoProductData($remote_id, $object)
$productRefSynchDirection = isset($this->site->parameters['product_synch_direction']['ref']) ? $this->site->parameters['product_synch_direction']['ref'] : '';
$productDescriptionSynchDirection = isset($this->site->parameters['product_synch_direction']['description']) ? $this->site->parameters['product_synch_direction']['description'] : '';
$productShortDescriptionSynchDirection = isset($this->site->parameters['product_synch_direction']['short_description']) ? $this->site->parameters['product_synch_direction']['short_description'] : '';
$productWeightSynchDirection = isset($this->site->parameters['product_synch_direction']['weight']) ? $this->site->parameters['product_synch_direction']['weight'] : '';
$productWeightSynchDirection = isset($this->site->parameters['product_synch_direction']['weight']) ? $this->site->parameters['product_synch_direction']['weight'] : '';
$productDimensionSynchDirection = isset($this->site->parameters['product_synch_direction']['dimension']) ? $this->site->parameters['product_synch_direction']['dimension'] : '';
$productTaxSynchDirection = isset($this->site->parameters['product_synch_direction']['tax']) ? $this->site->parameters['product_synch_direction']['tax'] : '';
$productStatusSynchDirection = isset($this->site->parameters['product_synch_direction']['status']) ? $this->site->parameters['product_synch_direction']['status'] : '';
$product_variation_mode_all_to_one = !empty($this->site->parameters['product_variation_mode']) && $this->site->parameters['product_variation_mode'] == 'all_to_one';
Expand All @@ -1991,11 +2003,20 @@ public function convertObjectIntoProductData($remote_id, $object)
}
}

// Convert Weight
// Convert Weight
$from_unit = $object->weight_units;
$to_unit = isset($this->site->parameters['product_weight_units']) ? $this->site->parameters['product_weight_units'] : (empty($conf->global->MAIN_WEIGHT_DEFAULT_UNIT)?0:$conf->global->MAIN_WEIGHT_DEFAULT_UNIT);
$totalWeight = weight_convert($object->weight, $from_unit, $to_unit);

// Convert Dimension
$from_unit = $object->width_units;
$to_unit = isset($this->site->parameters['product_direction_units']) ? $this->site->parameters['product_direction_units'] : -2; // -2 = cm
$totalWidth = weight_convert($object->width, $from_unit, $to_unit);
$from_unit = $object->height_units;
$totalHeight = weight_convert($object->height, $from_unit, $to_unit);
$from_unit = $object->length_units;
$totalLength = weight_convert($object->length, $from_unit, $to_unit);

// Price
$error_price = 0;
if (!empty($conf->global->PRODUIT_MULTIPRICES)) {
Expand Down Expand Up @@ -2215,11 +2236,13 @@ public function convertObjectIntoProductData($remote_id, $object)
foreach ($filearray as $key => $file) {
if (empty($file['share'])) continue;

$filename = ecommerceng_wordpress_sanitize_file_name($file['name']);
$filename = pathinfo($file['name'], PATHINFO_FILENAME);
$filename = ecommerceng_wordpress_sanitize_file_name($filename);

$img = [
'name' => $filename,
'src' => $url_root . '/' . $file['share'] . '.jpg',
'alt' => $filename,
'src' => $url_root . '/' . $file['share'] . '/' . $file['name'],
'position' => $key,
];
if (isset($current_images[$filename])) {
Expand Down Expand Up @@ -2326,16 +2349,23 @@ public function convertObjectIntoProductData($remote_id, $object)
$variationData['sku'] = $object->ref;
}
if ($productDescriptionSynchDirection == 'dtoe' || $productDescriptionSynchDirection == 'all') {
$variationData['description'] = nl2br($object->array_options["options_ecommerceng_description_{$conf->entity}"]);
$variationData['description'] = dol_textishtml($object->array_options["options_ecommerceng_description_{$conf->entity}"]) ? $object->array_options["options_ecommerceng_description_{$conf->entity}"] : nl2br($object->array_options["options_ecommerceng_description_{$conf->entity}"]);

if (empty($variationData['description']) || $initial_data) {
$variationData['description'] = nl2br($object->description);
$variationData['description'] = dol_textishtml($object->description) ? $object->description : nl2br($object->description);
$object->array_options["options_ecommerceng_description_{$conf->entity}"] = $variationData['description'];
}
}
if ($productWeightSynchDirection == 'dtoe' || $productWeightSynchDirection == 'all') {
$variationData['weight'] = (!empty($totalWeight) ? $totalWeight : '');
}
if ($productDimensionSynchDirection == 'dtoe' || $productDimensionSynchDirection == 'all') {
$variationData['dimensions'] = array(
'length' => (string)(!empty($totalLength) ? $totalLength : ''),
'width' => (string)(!empty($totalWidth) ? $totalWidth : ''),
'height' => (string)(!empty($totalHeight) ? $totalHeight : ''),
);
}
if ($productTaxSynchDirection == 'dtoe' || $productTaxSynchDirection == 'all') {
$variationData['tax_status'] = 'none';

Expand Down Expand Up @@ -2553,19 +2583,26 @@ public function convertObjectIntoProductData($remote_id, $object)
$productData['sku'] = $object->ref;
}
if ($productDescriptionSynchDirection == 'dtoe' || $productDescriptionSynchDirection == 'all') {
$productData['description'] = nl2br($object->array_options["options_ecommerceng_description_{$conf->entity}"]);
$productData['description'] = dol_textishtml($object->array_options["options_ecommerceng_description_{$conf->entity}"]) ? $object->array_options["options_ecommerceng_description_{$conf->entity}"] : nl2br($object->array_options["options_ecommerceng_description_{$conf->entity}"]);

if (empty($productData['description']) || $initial_data) {
$productData['description'] = nl2br($object->description);
$productData['description'] = dol_textishtml($object->description) ? $object->description : nl2br($object->description);
$object->array_options["options_ecommerceng_description_{$conf->entity}"] = $productData['description'];
}
}
if ($productShortDescriptionSynchDirection == 'dtoe' || $productShortDescriptionSynchDirection == 'all') {
$productData['short_description'] = nl2br($object->array_options["options_ecommerceng_short_description_{$conf->entity}"]);
$productData['short_description'] = dol_textishtml($object->array_options["options_ecommerceng_short_description_{$conf->entity}"]) ? $object->array_options["options_ecommerceng_short_description_{$conf->entity}"] : nl2br($object->array_options["options_ecommerceng_short_description_{$conf->entity}"]);
}
if ($productWeightSynchDirection == 'dtoe' || $productWeightSynchDirection == 'all') {
$productData['weight'] = (!empty($totalWeight) ? $totalWeight : '');
}
if ($productDimensionSynchDirection == 'dtoe' || $productDimensionSynchDirection == 'all') {
$productData['dimensions'] = array(
'length' => (string)(!empty($totalLength) ? $totalLength : ''),
'width' => (string)(!empty($totalWidth) ? $totalWidth : ''),
'height' => (string)(!empty($totalHeight) ? $totalHeight : ''),
);
}
if ($productTaxSynchDirection == 'dtoe' || $productTaxSynchDirection == 'all') {
$productData['tax_status'] = 'none';

Expand Down Expand Up @@ -3396,6 +3433,7 @@ public function batchUpdateRemoteProducts($batch)
dol_syslog(__METHOD__ . ": Create batch products from Dolibarr products IDs: '{$ids}' for site ID {$this->site->id}", LOG_DEBUG);
global $conf, $langs;

return array(); // Todo to remake
$this->errors = array();

require_once DOL_DOCUMENT_ROOT.'/product/class/product.class.php';
Expand Down
2 changes: 1 addition & 1 deletion core/modules/modECommerceNg.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ function __construct($db)
$this->editor_url = 'http://www.open-dsi.fr';

// Possible values for version are: 'development', 'experimental', 'dolibarr' or version
$this->version = '4.0.101';
$this->version = '4.0.103';
// Key used in llx_const table to save module status enabled/disabled (where MYMODULE is value of property name of module in uppercase)
$this->const_name = 'MAIN_MODULE_' . strtoupper($this->name);
// Where to store the module in setup page (0=common,1=interface,2=others,3=very specific)
Expand Down
4 changes: 2 additions & 2 deletions document/.htaccess
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteRule (.*)\.jpg ../../../document.php?hashp=$1 [NC]
#RewriteRule (.*)\.jpg ../../../../document.php?hashp=$1 [NC]
RewriteRule (.*)/.* ../../../document.php?hashp=$1 [NC]
#RewriteRule (.*)/.* ../../document.php?hashp=$1 [NC] # if the module is installed in the htdocs and not in custom
</IfModule>
Loading

0 comments on commit 1d8ce9c

Please sign in to comment.