<?php
namespace Customize\Entity;
use Doctrine\ORM\Mapping as ORM;
use Eccube\Annotation\EntityExtension;
use Lm\Engine\EC\Entity\GoodsExtended;
/**
* @EntityExtension("Eccube\Entity\CartItem")
*/
trait CartItemTrait
{
/**
* @ORM\Column(name="options", type="text", nullable=true)
*/
public $options;
/**
* @ORM\Column(name="estimate_id", type="integer", nullable=true, options={"default":0, "unsigned": true})
*/
public $EstimateId;
/**
* Get options
*
* @return string options
*/
public function getOptions()
{
return $this->options;
}
/**
* Set options
*
* @return $this
*/
public function setOptions($options)
{
$this->options = $options;
return $this;
}
/**
* Get EstimateId
*
* @return int
*/
public function getEstimateId()
{
return $this->EstimateId;
}
/**
* Set EstimateId
*
* @return $this
*/
public function setEstimateId($EstimateId)
{
if (!empty($this->getOptions()) && (int)$EstimateId === 0) {
try {
throw new \Exception('[LM] #1121 - Trying set 0 to CartItem.estimateId');
} catch(\Exception $e) {
log_error($e->getMessage(), [
'Message' => $e->getMessage(),
'File' => $e->getFile(),
'Line' => $e->getLine(),
'TraceAsString' => $e->getTraceAsString(),
'$_POST' => $_POST,
'$_SERVER' => $_SERVER,
'$_SESSION' => $_SESSION,
]);
}
}
$this->EstimateId = $EstimateId;
return $this;
}
public function getOptionsData()
{
return json_decode($this->getOptions(), true);
}
public function isSusoage()
{
return ($options = $this->getOptionsData()) && !empty($options['susoage']);
}
public function isNairePrint()
{
return ($options = $this->getOptionsData()) && !empty($options['print']);
}
public function isKyouei()
{
return GoodsExtended::createByJanId($this->getProductClass()->getId())
->isKyouei()
;
}
public function isKyoueiWithNairePrint()
{
return $this->isKyouei() && $this->isNairePrint();
}
}