Fix trouble with product id = -1

This commit is contained in:
Laurent Destailleur
2021-07-04 21:02:02 +02:00
parent 5853aa4c1e
commit f6efe51032
17 changed files with 61 additions and 60 deletions

View File

@@ -1518,7 +1518,7 @@ class Commande extends CommonOrder
$this->db->begin();
$product_type = $type;
if (!empty($fk_product)) {
if (!empty($fk_product) && $fk_product > 0) {
$product = new Product($this->db);
$result = $product->fetch($fk_product);
$product_type = $product->type;
@@ -4389,7 +4389,7 @@ class OrderLine extends CommonOrderLine
$sql .= " '".price2num($this->localtax2_tx)."',";
$sql .= " '".$this->db->escape($this->localtax1_type)."',";
$sql .= " '".$this->db->escape($this->localtax2_type)."',";
$sql .= ' '.(!empty($this->fk_product) ? $this->fk_product : "null").',';
$sql .= ' '.((!empty($this->fk_product) && $this->fk_product > 0) ? $this->fk_product : "null").',';
$sql .= " '".$this->db->escape($this->product_type)."',";
$sql .= " '".price2num($this->remise_percent)."',";
$sql .= " ".(price2num($this->subprice) !== '' ?price2num($this->subprice) : "null").",";