本文整理匯總了PHP中Products::getProduct方法的典型用法代碼示例。如果您正苦於以下問題:PHP Products::getProduct方法的具體用法?PHP Products::getProduct怎麽用?PHP Products::getProduct使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Products
的用法示例。
在下文中一共展示了Products::getProduct方法的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: order_act
//.........這裏部分代碼省略.........
if (isset($item["order_type"])) {
if (is_array($item["order_type"])) {
if ($item["order_type"]["flash_sale"] == true) {
// test OK
$goods_info = array("product_id" => $item["product_id"], 'goods_id' => $item['goods_id']);
$flash_sale = array();
$ret = $prom_inst->get_flash_sale($goods_info);
if ($ret["status"] == 1 && isset($ret["data"])) {
$flash_sale = $ret["data"];
// 搶購促銷校驗
// 是否有庫存
if ($flash_sale['max_num'] <= 0) {
// test OK
$error = 1;
$error_item = array("msg" => '商品:' . $item['name'] . '--庫存已經沒有!', "product_id" => $item['product_id']);
$error_list[] = $error_item;
} else {
if ($flash_sale['max_num'] < $item["num"]) {
// test OK
$error = 1;
$error_item = array("msg" => '商品:' . $item['name'] . '--庫存隻有' . $flash_sale['max_num'] . '個!', "product_id" => $item['product_id']);
$error_list[] = $error_item;
}
}
} else {
$error = 1;
$error_item = array("msg" => '商品:' . $item['name'] . '--搶購已經結束!', "product_id" => $item['product_id']);
$error_list[] = $error_item;
}
} elseif ($item["order_type"]["prom_series"] == true && $item["order_type"]["prom_goods"] == true) {
//2 判斷商品促銷(單品)
$products_inst = new Products();
$products_item = array();
$ret = $products_inst->getProduct($item['product_id']);
// 獲取商品信息 item = product
if (isset($ret['status']) && $ret['status'] == 1) {
$item_new = $ret['data'];
}
$item_new['goods_nums'] = $item['num'];
// get prom goods 需要傳參數goods_nums
$prom_goods = $prom_inst->get_prom_goods($item_new);
if (!empty($prom_goods)) {
$prom_goods['parse'] = $prom_inst->do_prom_goods($item_new, $prom_goods);
if (isset($prom_goods['parse']['note']) && $prom_goods['parse']['note'] != '') {
$prom_goods['parse']['note'] = '商品優惠:' . $prom_goods['parse']['note'];
}
$amount = sprintf("%01.2f", $prom_goods['parse']['real_price'] * $item["num"]);
$sell_total = $item['sell_price'] * $item["num"];
// 是否有庫存
if ($item_new['store_nums'] <= 0) {
// test OK
$error = 1;
$error_item = array("msg" => '商品:' . $item['name'] . '--庫存已經沒有!', "product_id" => $item['product_id']);
$error_list[] = $error_item;
} else {
if ($item_new['store_nums'] < $item["num"]) {
// test OK
$error = 1;
$error_item = array("msg" => '商品:' . $item['name'] . '--庫存隻有' . $item_new['store_nums'] . '個!', "product_id" => $item['product_id']);
$error_list[] = $error_item;
}
}
//修改ITEM內容 價格
$item_ref['real_price'] = $prom_goods['parse']['real_price'];
} else {
// 單品--商品促銷結束
示例2: modifyProductNum
public function modifyProductNum($goods, $num = 1)
{
$product_id = NULL;
$ship_id = NULL;
$goods_id = NULL;
if (isset($goods["product_id"]) && $goods["product_id"] > 0) {
$product_id = $goods["product_id"];
} else {
$ret["msg"] = "修改商品失敗";
$ret["status"] = false;
return $ret;
}
$products_inst = new Products();
$ret = $products_inst->getProduct($product_id);
// 獲取購物車 所有的商品
$item = array();
if (isset($ret['status']) && $ret['status'] == 1) {
$item = $ret['data'];
} else {
$ret["msg"] = "修改商品數量失敗,沒有商品ID或ship_id";
$ret["status"] = false;
return $ret;
}
if (empty($item)) {
$ret["msg"] = "修改商品數量失敗,沒有商品ID或ship_id";
$ret["status"] = false;
return $ret;
}
if (isset($goods["goods_id"]) && $goods["goods_id"] > 0 && isset($goods["ship_id"]) && $goods["ship_id"] > 0) {
$goods_id = $goods["goods_id"];
$ship_id = $goods["ship_id"];
} else {
if (isset($item["goods_id"]) && isset($item["ship_id"])) {
$goods_id = $item["goods_id"];
$ship_id = $item["ship_id"];
// 為非空
} else {
$ret["msg"] = "修改商品數量失敗,沒有商品ID或ship_id";
$ret["status"] = false;
return $ret;
}
}
$goods_info = array("ship_id" => $ship_id, "goods_id" => $goods_id, "product_id" => $product_id);
//Tiny::log(__FILE__.__LINE__.var_export($goods_info, true));
if (!$this->hasProducts($goods_info)) {
$ret["msg"] = "修改商品數量失敗,沒有商品";
$ret["status"] = false;
return $ret;
}
//SKM 判斷商品是否超過庫存量
// todo products.num + bundling.num > store_nums
$bund_num = $this->productsInBundling($ship_id, $product_id);
$max_nums = $item['store_nums'] - $bund_num;
// products.num > store_nums
if ($num + $bund_num > $item['store_nums']) {
$this->items[$ship_id]["products"][$goods_id][$product_id]['num'] = $item['store_nums'] - $bund_num;
$this->items[$ship_id]["products"][$goods_id][$product_id]['max_nums'] = $max_nums;
// 最大購買數
} else {
if ($num < 0) {
$ret["msg"] = "修改商品數量失敗: num 不能為 {$num}";
$ret["status"] = false;
return $ret;
} else {
$this->items[$ship_id]["products"][$goods_id][$product_id]['num'] = $num;
$this->items[$ship_id]["products"][$goods_id][$product_id]['max_nums'] = $max_nums;
// 最大購買數
}
}
//Tiny::log(__FILE__.__LINE__.var_export($this->items[$ship_id]["products"][$goods_id][$product_id], true));
$ret["msg"] = "修改商品數量成功";
$ret["status"] = true;
//$ret["data"] = $bund_num;
return $ret;
}
示例3: runMiddle
public function runMiddle()
{
$product = Products::getProduct($this->params[0]);
include dirname(__FILE__) . "/../views/product.php";
}
示例4: array
<?php
$games = array();
$items = new Products();
$games = $items->listProducts();
if (isset($_GET['id'])) {
$document['template'] = 'game';
$game = $items->getProduct($_GET['id']);
$product = Gameservices::validateGame($game);
$smarty->assign('game', $product);
} else {
$document['template'] = 'games';
/*********Games For View************/
foreach ($games as $value) {
$products[] = Gameservices::validateGameList($value);
}
/********************************/
$smarty->assign('games', $products);
}
?>
示例5: Products
<?php
if (isset($_SESSION['products_id'])) {
$document['template'] = 'cart';
$items = new Products();
foreach ($_SESSION['products_id'] as $value) {
$products[] = Gameservices::validateCartGames($items->getProduct($value));
}
$total = count($products) . "Games";
$smarty->assign('total', $total);
$smarty->assign('products', $products);
} else {
//$products = 'Server Error';
$document['template'] = 'emptycart';
}