Fix autocalculation of surface and volume.

This commit is contained in:
Laurent Destailleur 2017-01-16 10:55:33 +01:00
parent 1b1bab94ca
commit fafe71ec52

View File

@ -641,18 +641,18 @@ class Product extends CommonObject
$this->height = price2num($this->height);
$this->height_units = trim($this->height_units);
// set unit not defined
if (! $this->width_units && $this->length_units) $this->width_units = $this->length_units; // Not used yet
if (! $this->height_units && $this->length_units) $this->height_units = $this->length_units; // Not used yet
if ($this->length_units) $this->width_units = $this->length_units; // Not used yet
if ($this->length_units) $this->height_units = $this->length_units; // Not used yet
// Automated compute surface and volume if not filled
if (empty($this->surface) && !empty($this->length) && !empty($this->width) && $this->length_units == $this->width_units)
{
$this->surface = $this->length * $this->width;
$this->surface_units = $this->width_units;
if (empty($this->volume) && !empty($this->height) && $this->length_units == $this->height_units)
{
$this->volume = $this->surface * $this->height;
$this->volume_units = $this->height_units;
}
$this->surface_units = $this->length_units + $this->width_units;
}
if (empty($this->volume) && !empty($this->surface_units) && !empty($this->height) && $this->length_units == $this->height_units)
{
$this->volume = $this->surface * $this->height;
$this->volume_units = $this->surface_units + $this->height_units;
}
$this->surface = price2num($this->surface);