クラス
GroupItem
ソース ソース
ファイル: src/Types/GroupItem.php
class GroupItem extends SkuItem implements JsonSerializable
{
/**
* Group item ID
*
* @var int
*/
private $id;
/**
* Group ID
*
* @var int
*/
private $groupId;
/**
* Group item label
*
* @var string
*/
private $itemLabel;
/**
* Quantity of the group item
*
* @var int
*/
private $itemQuantity;
/**
* The amount added (or subtracted if the value is negative) to the combo item's
* base SKU price
*
* Used to adjust the total price appropriately
*
* @var int
*/
private $priceModifier = 0;
/**
* Position in the item group
*
* Lower means higher priority
*
* @var int
*/
private $position;
/**
* Created at UTC `DATETIME` string
*
* @var string
*/
private $createdAt;
/**
* Updated at UTC `DATETIME` string
*
* @var string
*/
private $updatedAt;
/**
* Constructs a group item
*
* @author Evan D Shaw <evandanielshaw@gmail.com>
* @param int $id
* @param int $groupId
* @param int $welitemSkuMetaId
* @param string $itemLabel
* @param int $itemQuantity
* @param int|float $priceModifier
* @param int $position
* @param string $createdAt
* @param string $updatedAt
* @return void
*/
public function __construct(
$id,
$groupId,
$welitemSkuMetaId,
$itemLabel,
$itemQuantity,
$priceModifier,
$position,
$createdAt,
$updatedAt
) {
parent::__construct($welitemSkuMetaId);
$this->id = (int)$id;
$this->groupId = (int)$groupId;
$this->itemLabel = $itemLabel;
$this->itemQuantity = (int)$itemQuantity;
$this->priceModifier = (float)$priceModifier;
$this->position = (int)$position;
$this->createdAt = $createdAt;
$this->updatedAt = $updatedAt;
}
/**
* Returns key-value representation of the object
*
* @author Evan D Shaw <evandanielshaw@gmail.com>
* @return array
*/
public function jsonSerialize() {
return array_merge(
parent::jsonSerialize(),
$this->getJson()
);
}
/**
* Returns key-value array for the group item, excluding item and SKU data
*
* @author Evan D Shaw <evandanielshaw@gmail.com>
* @return (int|string)[]
*/
public function getJson() {
return [
'id' => $this->id,
'groupId' => $this->groupId,
'itemLabel' => $this->itemLabel,
'itemQuantity' => $this->itemQuantity,
'priceModifier' => $this->priceModifier,
'position' => $this->position,
'createdAt' => $this->createdAt,
'updatedAt' => $this->updatedAt,
];
}
/**
* Getter for `$this->id`
*
* @author Evan D Shaw <evandanielshaw@gmail.com>
* @return int
*/
public function getId() {
return $this->id;
}
/**
* Getter for `$this->id`
*
* @author Evan D Shaw <evandanielshaw@gmail.com>
* @return int
*/
public function getGroupId() {
return $this->groupId;
}
/**
* Getter for `$this->itemLabel`
*
* @author Evan D Shaw <evandanielshaw@gmail.com>
* @return string
*/
public function getItemLabel() {
return $this->itemLabel;
}
/**
* Getter for `$this->itemQuantity`
*
* @author Evan D Shaw <evandanielshaw@gmail.com>
* @return int
*/
public function getItemQuantity() {
return $this->itemQuantity;
}
/**
* Getter for `$this->priceModifier`
*
* @author Evan D Shaw <evandanielshaw@gmail.com>
* @return float
*/
public function getPriceModifier() {
return $this->priceModifier;
}
/**
* Getter for `$this->position`
*
* @author Evan D Shaw <evandanielshaw@gmail.com>
* @return int
*/
public function getPosition() {
return $this->position;
}
/**
* Getter for `$this->createdAt`
*
* @author Evan D Shaw <evandanielshaw@gmail.com>
* @return string
*/
public function getCreatedAt() {
return $this->createdAt;
}
/**
* Getter for `$this->updatedAt`
*
* @author Evan D Shaw <evandanielshaw@gmail.com>
* @return string
*/
public function getUpdatedAt() {
return $this->updatedAt;
}
}
- __construct — Constructs a group item
- getCreatedAt — Getter for `$this->createdAt`
- getGroupId — Getter for `$this->id`
- getId — Getter for `$this->id`
- getItemLabel — Getter for `$this->itemLabel`
- getItemQuantity — Getter for `$this->itemQuantity`
- getJson — Returns key-value array for the group item, excluding item and SKU data
- getPosition — Getter for `$this->position`
- getPriceModifier — Getter for `$this->priceModifier`
- getUpdatedAt — Getter for `$this->updatedAt`
- jsonSerialize — Returns key-value representation of the object