public function __isset($name) { if (in_array($name, array('base_amount', 'discount_amount', 'net_amount', 'tax_amount', 'gross_amount'))) { return true; } return parent::__isset($name); }
public function __get($name) { if ($name == 'metadata') { return $this->getMetadata(); } return parent::__get($name); }
/** * Constructor * * @param null $data */ public function __construct($data) { $this->setProduct(new SimpleProduct($data)); $this->cart_product_srl = $data->cart_product_srl; $this->cart_product_title = $data->cart_product_title; $this->cart_product_price = $data->cart_product_price; $this->quantity = $data->quantity ? $data->quantity : 1; parent::__construct(); }
/** * Constructor override - initialises default values when none given */ public function __construct($args = NULL) { parent::__construct($args); if (!isset($this->description)) { $this->description = ""; } if (!isset($this->short_description)) { $this->short_description = ""; } if (!isset($this->status)) { $this->status = "enabled"; } }
public function __construct($data = NULL) { if (!is_null($data) && !is_numeric($data) && !is_array($data) && !$data instanceof stdClass) { throw new ShopException('Invalid $data type'); } if (is_array($data) || $data instanceof stdClass) { $this->loadFromArray((array) $data); } /** * Look for Item repository. * For IDE purposes like code completion $this->repo's type should be hinted in each Item the way I did in Cart. */ $repoClass = $this->getRepo(); $reflection = new ReflectionClass($repoClass); $repoClass = (string) $reflection->getName(); $this->repo = $reflection->isInstantiable() ? new $repoClass() : null; /** * Look for srl field if it's not already set in class $meta */ $reflection = new ReflectionClass($this); if ($srlField = $this->getMeta('srl')) { //if srl is given if (!$reflection->hasProperty($srlField)) { throw new ShopException("Srl field '{$srlField}' doesn't exist"); } } elseif ($reflection->hasProperty('srl')) { $this->setMeta('srl', 'srl'); } else { //else return the first _srl field foreach ($this as $field => $value) { if (substr($field, strlen($field) - 4, strlen($field)) === '_srl') { $this->setMeta('srl', $field); break; } } if (!$this->getMeta('srl')) { throw new ShopException('Couldn\'t identify the _srl column'); } } //data can also be a serial if (is_numeric($data)) { if ($obj = $this->repo->get($data, "get%E", get_called_class())) { $this->copy($obj); } else { throw new ShopException("No such {$this->repo->entity} srl {$data}"); } } if (is_null(self::$cache)) { self::$cache = new ShopCache(); } }
public function __construct($data = null) { if ($data) { if ($data instanceof Cart) { $this->cart = $data; $this->loadFromCart($data); parent::__construct(); return; } foreach (array('billing_address', 'shipping_address', 'shipping_method', 'payment_method') as $val) { if (!isset($orderData[$val])) { //throw new ShopException("Missing $val, can't continue."); } } } parent::__construct($data); }
/** * Returns a peer instance associated with this om. * * Since Peer classes are not to have any instance attributes, this method returns the * same instance for all member of this class. The method could therefore * be static, but this would prevent one from overriding the behavior. * * @return ItemPeer */ public function getPeer() { if (self::$peer === null) { self::$peer = new ItemPeer(); } return self::$peer; }
/** * Return the bookstore used price for an item. * @param bool $includeTax whether to include tax */ public function getBUsed($includeTax = true) { return parent::getBUsed(); }
public function __construct(&$db, $row) { parent::__construct($db, $row); }
/** * Insert overrides the parent class method because we need for $code unicity * * @param string $query * @return object * @throws ShopException */ public function insert($query = 'insert%E') { if ($this->code) { $existentCoupons = $this->repo->getByCode($this->code, $this->module_srl); if ($existentCoupons && !empty($existentCoupons)) { if ($r = $this->getMeta('random')) { $this->generateCode($r['length'], $r['type'], $r['pattern'], $r['separateEvery'], $r['separator']); } else { throw new ShopException('Code already exists'); } } } else { if ($this->parent_srl) { throw new ShopException('Child coupon must have a code at insert'); } } return parent::insert($query); }