From 2c898b45e3d0b8e2171b472c22d4640503f73304 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?This=20Charl=C3=A8ne?= <1179011+defrance@users.noreply.github.com> Date: Wed, 20 Jul 2022 11:10:54 +0200 Subject: [PATCH 1/5] PHP - cannot use a scalar as an array warning generate an error : cannot use a scalar as an array warning (even on php V7) --- htdocs/variants/combinations.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/variants/combinations.php b/htdocs/variants/combinations.php index b6ffd948bd6..eb19b9fc29a 100644 --- a/htdocs/variants/combinations.php +++ b/htdocs/variants/combinations.php @@ -69,7 +69,7 @@ if ($id > 0 || $ref) { $object->fetch($id, $ref); } -$selectedvariant = !empty($_SESSION['addvariant_'.$object->id]) ? $_SESSION['addvariant_'.$object->id] : 0; +$selectedvariant = !empty($_SESSION['addvariant_'.$object->id]) ? $_SESSION['addvariant_'.$object->id] : Array(); // Security check if (empty($conf->variants->enabled)) { From 8cb1e138de0c4627c45e49ae0aaf1e0396590b5e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?This=20Charl=C3=A8ne?= <1179011+defrance@users.noreply.github.com> Date: Wed, 20 Jul 2022 11:15:44 +0200 Subject: [PATCH 2/5] forgotted fields --- htdocs/variants/class/ProductCombination.class.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/htdocs/variants/class/ProductCombination.class.php b/htdocs/variants/class/ProductCombination.class.php index 0e8f69958dc..a525bb41319 100644 --- a/htdocs/variants/class/ProductCombination.class.php +++ b/htdocs/variants/class/ProductCombination.class.php @@ -281,7 +281,9 @@ class ProductCombination { global $conf; - $sql = "SELECT rowid, fk_product_parent, fk_product_child, variation_price, variation_price_percentage, variation_weight FROM ".MAIN_DB_PREFIX."product_attribute_combination WHERE fk_product_parent = ".((int) $fk_product_parent)." AND entity IN (".getEntity('product').")"; + $sql = "SELECT rowid, fk_product_parent, fk_product_child, variation_price, variation_price_percentage, variation_ref_ext, variation_weight"; + $sql.= " FROM ".MAIN_DB_PREFIX."product_attribute_combination"; + $sql.= " WHERE fk_product_parent = ".((int) $fk_product_parent)." AND entity IN (".getEntity('product').")"; $query = $this->db->query($sql); From 3e8cb1de571c6df02ef98d0a81b6cdb6ed4154e7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?This=20Charl=C3=A8ne?= <1179011+defrance@users.noreply.github.com> Date: Wed, 20 Jul 2022 11:31:20 +0200 Subject: [PATCH 3/5] php V8 warning --- htdocs/variants/class/ProductCombination.class.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/variants/class/ProductCombination.class.php b/htdocs/variants/class/ProductCombination.class.php index a525bb41319..215536ac43a 100644 --- a/htdocs/variants/class/ProductCombination.class.php +++ b/htdocs/variants/class/ProductCombination.class.php @@ -491,10 +491,10 @@ class ProductCombination $child->price_autogen = $parent->price_autogen; $child->weight = $parent->weight; // Only when Parent Status are updated - if ($parent->oldcopy && ($parent->status != $parent->oldcopy->status)) { + if (!empty($parent->oldcopy) && ($parent->status != $parent->oldcopy->status)) { $child->status = $parent->status; } - if ($parent->oldcopy && ($parent->status_buy != $parent->oldcopy->status_buy)) { + if (!empty($parent->oldcopy) && ($parent->status_buy != $parent->oldcopy->status_buy)) { $child->status_buy = $parent->status_buy; } From 54c2cc245d663f4e887471e19833bf3da13e18a0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?This=20Charl=C3=A8ne?= <1179011+defrance@users.noreply.github.com> Date: Wed, 20 Jul 2022 11:34:01 +0200 Subject: [PATCH 4/5] PHP V8 warning --- htdocs/variants/combinations.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/htdocs/variants/combinations.php b/htdocs/variants/combinations.php index eb19b9fc29a..fd4f116f51b 100644 --- a/htdocs/variants/combinations.php +++ b/htdocs/variants/combinations.php @@ -154,7 +154,7 @@ if (($action == 'add' || $action == 'create') && empty($massaction) && !GETPOST( $price_impact = price2num($price_impact); // for conf PRODUIT_MULTIPRICES - if ($conf->global->PRODUIT_MULTIPRICES) { + if (!empty($conf->global->PRODUIT_MULTIPRICES)) { $level_price_impact = array_map('price2num', $level_price_impact); } else { $level_price_impact = array(1 => $price_impact); @@ -279,7 +279,7 @@ if (($action == 'add' || $action == 'create') && empty($massaction) && !GETPOST( $prodcomb->variation_weight = price2num($weight_impact); // for conf PRODUIT_MULTIPRICES - if ($conf->global->PRODUIT_MULTIPRICES) { + if (!empty($conf->global->PRODUIT_MULTIPRICES)) { $level_price_impact = array_map('price2num', $level_price_impact); $prodcomb->variation_price = $level_price_impact[1]; @@ -292,7 +292,7 @@ if (($action == 'add' || $action == 'create') && empty($massaction) && !GETPOST( $prodcomb->variation_price_percentage = $price_impact_percent; } - if ($conf->global->PRODUIT_MULTIPRICES) { + if (!empty($conf->global->PRODUIT_MULTIPRICES)) { $prodcomb->combination_price_levels = array(); for ($i = 1; $i <= $conf->global->PRODUIT_MULTIPRICES_LIMIT; $i++) { $productCombinationLevel = new ProductCombinationLevel($db); From 083b785ec873afa4877764e1c74a39b673606f9b Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sun, 24 Jul 2022 20:13:48 +0200 Subject: [PATCH 5/5] Update combinations.php --- htdocs/variants/combinations.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/variants/combinations.php b/htdocs/variants/combinations.php index fd4f116f51b..f01e674c44a 100644 --- a/htdocs/variants/combinations.php +++ b/htdocs/variants/combinations.php @@ -69,7 +69,7 @@ if ($id > 0 || $ref) { $object->fetch($id, $ref); } -$selectedvariant = !empty($_SESSION['addvariant_'.$object->id]) ? $_SESSION['addvariant_'.$object->id] : Array(); +$selectedvariant = !empty($_SESSION['addvariant_'.$object->id]) ? $_SESSION['addvariant_'.$object->id] : array(); // Security check if (empty($conf->variants->enabled)) {