itemdata = $binstack->get('items', ['itemid', 'catid', 'name', 'text1', 'qty', 'want', 'cost', 'price'], ['itemid' => $itemid]); $this->itemid = $itemid; } function getId() { return $this->itemid; } function getPrice($customer = null) { global $database; $binprice = $this->itemdata['price']; if (!is_null($customer)) { if ($database->has('customer_pricing', ['AND' => ['itemid' => $this->itemid, 'customerid' => $customer]])) { return $database->get('customer_pricing', 'price', ['AND' => ['itemid' => $this->itemid, 'customerid' => $customer]]); } } return $binprice; } function getName() { return $this->itemdata['name']; } function getDescription() { return $this->itemdata['text1']; } function getQty() { return $this->itemdata['qty']; } function getWant() { return $this->itemdata['want']; } function getCategoryName() { global $binstack; return $binstack->get('items', ['[>]categories' => 'catid'], 'catname', ['itemid' => $this->itemid]); } function getCategoryId() { return $this->itemdata['catid']; } } class RenderItem { static function card(Item $item) { $id = $item->getId(); $name = $item->getName(); $catid = $item->getCategoryId(); $catname = $item->getCategoryName(); $price = $item->getPrice(); $html = <<
$name
$$price
END; return $html; } static function line(Item $item) { $id = $item->getId(); $name = $item->getName(); $catid = $item->getCategoryId(); $catname = $item->getCategoryName(); $price = $item->getPrice(); $html = <<

$name

$$price
END; return $html; } static function cart(Item $item, int $qty) { $id = $item->getId(); $name = $item->getName(); $catid = $item->getCategoryId(); $catname = $item->getCategoryName(); $price = $item->getPrice(); $linetotal = number_format($price * $qty, 2); $html = <<

$name

$$price
$$linetotal
END; return $html; } }