diff --git a/htdocs/product/class/product.class.php b/htdocs/product/class/product.class.php index fc5f613d08d..56a00b2419d 100644 --- a/htdocs/product/class/product.class.php +++ b/htdocs/product/class/product.class.php @@ -1987,31 +1987,29 @@ class Product extends CommonObject $this->stats_commande['rows']=$obj->nb_rows; $this->stats_commande['qty']=$obj->qty?$obj->qty:0; - // if it's a virtual product, maybe it is in order by extension - $TFather = $this->getFather(); - if(is_array($TFather) && !empty($TFather)) { - - foreach($TFather as &$fatherData) { - - $pFather = new Product($this->db); - $pFather->id = $fatherData['id']; - $qtyCoef = $fatherData['qty']; - - if($fatherData['incdec']) { - $pFather->load_stats_commande($socid, $filtrestatut); - - $this->stats_commande['customers']+=$pFather->stats_commande['customers']; - $this->stats_commande['nb']+=$pFather->stats_commande['nb']; - $this->stats_commande['rows']+=$pFather->stats_commande['rows']; - $this->stats_commande['qty']+=$pFather->stats_commande['qty'] * $qtyCoef; - + // if it's a virtual product, maybe it is in order by extension + if (! empty($conf->global->ORDER_ADD_ORDERS_WITH_PARENT_PROD_IF_INCDEC)) + { + $TFather = $this->getFather(); + if (is_array($TFather) && !empty($TFather)) { + foreach($TFather as &$fatherData) { + $pFather = new Product($this->db); + $pFather->id = $fatherData['id']; + $qtyCoef = $fatherData['qty']; + + if ($fatherData['incdec']) { + $pFather->load_stats_commande($socid, $filtrestatut); + + $this->stats_commande['customers']+=$pFather->stats_commande['customers']; + $this->stats_commande['nb']+=$pFather->stats_commande['nb']; + $this->stats_commande['rows']+=$pFather->stats_commande['rows']; + $this->stats_commande['qty']+=$pFather->stats_commande['qty'] * $qtyCoef; + + } } - - } - } - + return 1; } else