本文整理汇总了PHP中product::add_product方法的典型用法代码示例。如果您正苦于以下问题:PHP product::add_product方法的具体用法?PHP product::add_product怎么用?PHP product::add_product使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类product
的用法示例。
在下文中一共展示了product::add_product方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: product
<?php
if (isset($_REQUEST['pcode'])) {
include "../classes/product.php";
$obj = new product();
$pcode = $_REQUEST['pcode'];
$name = $_REQUEST['name'];
$sp = $_REQUEST['sprice'];
$cp = $_REQUEST['cprice'];
$stock = $_REQUEST['quantity'];
$obj->add_product($pcode, $name, $sp, $cp, $stock);
}
//echo "http://cs.ashesi.edu.gh/~csashesi/class2016/obed-nsiah/mobileweb/pos/desktop/addstock.html";
//header(Location: ../desktop/addstock.html);
?>
示例2: elseif
if (isset($_POST['submit']) && $_POST['submit'] == tr('Add New Product')) {
// Perform checks
if ($_POST['amount'] == '') {
$template->add_message("You did not specify a product amount.", 'error');
} elseif (!is_numeric($_POST['amount'])) {
$template->add_message("Invalid product amount specified.", 'error');
} elseif ($_POST['amount'] < 0) {
$template->add_message("Invalid product amount specified.", 'error');
}
if ($_POST['product_name'] == '') {
$template->add_message("You did not specify a product name", 'error');
}
// Add product, if needed
if ($template->has_errors != 1) {
$client = new product();
$client->add_product($_POST['amount'], $_POST['currency'], $_POST['product_name'], $_POST['description']);
$template->add_message("Successfully created new product, {$_POST['product_name']}.");
}
// Delete checked products
} elseif (isset($_POST['submit']) && $_POST['submit'] == tr('Delete Checked Products')) {
// Get IDs
$ids = get_chk('product_id');
// Disable
foreach ($ids as $id) {
if (!$id > 0) {
continue;
}
DB::query("UPDATE products SET is_enabled = 0 WHERE id = %d", $id);
}
// User message
$template->add_message("Successfully deleted checked products.");
示例3: add_product
function add_product()
{
$name = $_GET['name'];
$barcode = $_GET['barcode'];
$price = $_GET['price'];
include_once 'product.php';
$obj = new product();
if (!$obj->connect()) {
$json = '{"status":2, "products":{}, "Failed to connect to the database."}';
echo $json;
exit;
}
if ($obj->add_product($name, $barcode, $price)) {
$json = '{"status":0, "products":{}, "message":"Product added."}';
echo $json;
} else {
$json = '{"status":1, "products":{}, "message":"Product was not added."}';
echo $json;
}
}