本文整理汇总了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';
}