* @copyright 2016-2017 GFI Informatique, 2016-2017 TNT * @license https://opensource.org/licenses/MIT MIT License */ require_once _PS_MODULE_DIR_.'tntofficiel/libraries/TNTOfficiel_Debug.php'; class TNTOfficiel_Parcel { /** * @var int */ private $parcelId; /** * @var array */ private $productList; /** * @var float */ private $weight = 0; /** * @var int */ private $lastAddedProductId; /** * Constructor. */ public function __construct() { TNTOfficiel_Debug::log(array('msg' => '>>', 'file' => __FILE__, 'line' => __LINE__)); } /** * @return int */ public function getParcelId() { TNTOfficiel_Debug::log(array('msg' => '>>', 'file' => __FILE__, 'line' => __LINE__)); return $this->parcelId; } /** * @param int $parcelId */ public function setParcelId($parcelId) { TNTOfficiel_Debug::log(array('msg' => '>>', 'file' => __FILE__, 'line' => __LINE__)); $this->parcelId = $parcelId; } /** * @return array */ public function getProductList() { TNTOfficiel_Debug::log(array('msg' => '>>', 'file' => __FILE__, 'line' => __LINE__)); return $this->productList; } /** * @return float */ public function getWeight() { TNTOfficiel_Debug::log(array('msg' => '>>', 'file' => __FILE__, 'line' => __LINE__)); return $this->weight; } /** * Add a product to the product list and update the weight;. * * @param $product */ public function addProduct($product) { TNTOfficiel_Debug::log(array('msg' => '>>', 'file' => __FILE__, 'line' => __LINE__)); $this->productList[$product['id_product']] = $product; //add the product $this->weight += $product['weight']; //update the parcel's weight $this->lastAddedProductId = $product['id_product']; //save the last added product id } }