Preprod mutu dc0edebeb0 tnt
2017-09-12 10:48:51 +02:00

96 lines
2.2 KiB
PHP

<?php
/**
* TNT OFFICIAL MODULE FOR PRESTASHOP.
*
* @author GFI Informatique <www.gfi.fr>
* @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
}
}