data = $data; } /** * Get the item name. * * @return string */ public function get_name() { return !empty($this->data['name']) ? $this->data['name'] : ''; } /** * Get the item quantity. * * @return int */ public function get_quantity() { return !empty($this->data['quantity']) ? (int)$this->data['quantity'] : 0; } public function get_price() { return !empty($this->data['price']) ? (float)$this->data['price'] : 0; } public function get_total() { return $this->get_price() * $this->get_quantity(); } public function get_product_id() { return $this->data['product_id'] ?? 0; } }