public function addBasket($id) { $size = Goods::getSize($_GET['size']); $sql = ' SELECT * FROM {{orders_items}} WHERE orders=' . $_GET['id'] . ' AND size=\'' . $size['name'] . '\' AND tree=' . $_GET['tree'] . ' '; $row = DB::getRow($sql); if ($row) { $sql = 'UPDATE {{orders_items}} SET num=\'' . $_GET['num'] . '\' WHERE id=' . $row['id'] . ''; DB::exec($sql); } else { $sql = ' SELECT {{catalog}}.*, {{tree}}.* FROM {{catalog}} INNER JOIN {{tree}} ON {{catalog}}.tree={{tree}}.id WHERE {{tree}}.id =' . $_GET['tree'] . ' '; $model = DB::getRow($sql); $price = Goods::getPrice($_GET['id'], $_GET['size']); $sql = ' INSERT INTO {{orders_items}} SET orders=' . $_GET['id'] . ', tree=' . $_GET['tree'] . ', name=\'' . $model['name'] . '\', size=\'' . $size['name'] . '\', num=\'' . $_GET['num'] . '\', price=\'' . $price . '\' '; DB::exec($sql); } }
public static function getPrice($goods, $sizeId) { $size = Goods::getSize($sizeId); $price = $size['baseRetailPriceRUR']; return $price; }