コード例 #1
0
ファイル: cart.php プロジェクト: jeffersonchaves/SimpleStore
/**
 * Adds one product to the cart
 */
function add_product_to_cart($product_id)
{
    $cart_items = array_key_exists('cart_items', $_SESSION) ? $_SESSION['cart_items'] : [];
    foreach ($cart_items as $cart_item) {
        if ($cart_item['product_id'] == $product_id) {
            return false;
        }
    }
    $product = get_product_by_id($product_id);
    $cart_items[] = ['product_id' => $product_id, 'price' => $product['price']];
    $_SESSION['cart_items'] = $cart_items;
}
コード例 #2
0
function create_product_edit_dlg()
{
    global $wb;
    include PATH_FORM . "yc_product_edit.form.php";
    //-------- view detail -------
    if ($id = $wb->current_ids) {
        get_product_by_id($winmain, $id);
        //		wb_message_box($wb->mainwin,$id);//implode(",",$all_ctrl)
    }
    if ($wb->current_action == "insert") {
        wb_set_enabled(wb_get_control($winmain, IDC_SAVE), true);
        wb_set_enabled(wb_get_control($winmain, IDC_UPDATE), false);
    } else {
        wb_set_enabled(wb_get_control($winmain, IDC_SAVE), false);
        wb_set_enabled(wb_get_control($winmain, IDC_UPDATE), true);
    }
    wb_set_handler($winmain, "process_product_edit");
    wb_set_visible($winmain, true);
}
コード例 #3
0
ファイル: inventory.mod.php プロジェクト: mwcs01/openpantry
function render_edit_product($productid)
{
    global $inventory_framework_render;
    global $parameters;
    foreach ($parameters as $parameter) {
        global ${$parameter};
    }
    $content = "";
    $product = get_product_by_id($productid);
    $inventory_product_edit = new Template();
    $inventory_product_edit->load('inventory_product_edit');
    $inventory_product_edit_render['id'] = $product['productid'];
    $inventory_product_edit_render['name'] = $product['name'];
    $inventory_product_edit_render['quantity'] = $product['quantity'];
    $inventory_product_edit->set_vars($inventory_product_edit_render);
    $inventory_product_edit->parse();
    $content .= $inventory_product_edit->final;
    $inventory_framework_render['content'] = $content;
    render_all();
}
コード例 #4
0
            }
            redirect_to("page_index.php?deleted=1");
        } else {
            // Deletion failed
            echo "<p>Page deletion failed.</p>";
            echo "<p>" . mysql_error() . "</p>";
            echo "<a href=\"index.php\">Return to Admin</a>";
        }
    } else {
        redirect_to('index.php');
    }
}
// delete from products index page !
if (isset($_GET['product'])) {
    $p_id = mysql_prep($_GET['product']);
    if ($product = get_product_by_id(NULL, $p_id)) {
        $pro_page_id = $product['page_id'];
        $query = "DELETE FROM products WHERE id = {$product['id']} LIMIT 1";
        $result = mysql_query($query);
        if (mysql_affected_rows() == true) {
            $query_page = "DELETE FROM page_data WHERE id = {$pro_page_id}";
            $run = mysql_query($query_page);
            if (mysql_affected_rows() == true) {
                // Successfully deleted
                redirect_to("page_index.php?deleted=2");
            }
            redirect_to("page_index.php?deleted=1");
        } else {
            // Deletion failed
            echo "<p>Page deletion failed.</p>";
            echo "<p>" . mysql_error() . "</p>";
コード例 #5
0
// check if subject get set
if (isset($_GET['subject'])) {
    $sel_subject = get_subject_by_id($_GET['subject']);
} else {
    $sel_subject = NULL;
}
// check if subject get set
if (isset($_GET['child'])) {
    $sel_subject_child = get_subject_by_id($_GET['child']);
} else {
    $sel_subject_child = NULL;
}
// check if page get set
if (isset($_GET['page'])) {
    $sel_page = get_page_by_id($_GET['page']);
    $sel_product = get_product_by_id($_GET['page'], '');
} else {
    $sel_page = NULL;
    $sel_product = NULL;
}
if (isset($_REQUEST['command']) || isset($_REQUEST['pid']) || isset($_REQUEST['productid'])) {
    // for add to cart
    if ($_REQUEST['command'] == 'add' && $_REQUEST['productid'] > 0) {
        $pid = $_REQUEST['productid'];
        $p_qty = $_REQUEST['productqty'];
        $p_note = $_REQUEST['productnote'];
        addtocart($pid, $p_qty, $p_note);
        header("location:shoppingcart.php?qty=" . $p_qty);
        exit;
    }
    if ($_REQUEST['command'] == 'delete' && $_REQUEST['pid'] > 0) {
コード例 #6
0
							<th>Product Name</th>
							<th>Note</th>
							<th>Quantity</th>
							<th>Price</th>
							<th>Total</th>
						</tr>
						<?php 
foreach ($sel_orderDetail as $row) {
    ?>
							<tr>
								<td><?php 
    echo $row['product_id'];
    ?>
</td>
								<td><?php 
    $pro_name = get_product_by_id($row['product_id']);
    echo $pro_name['name'];
    ?>
</td>
								<td><?php 
    echo $row['note'];
    ?>
</td>
								<td><?php 
    echo $row['quantity'];
    ?>
</td>
								<td>$<?php 
    echo $row['price'];
    ?>
</td>
コード例 #7
0
<?php

require __DIR__ . '/../src/bootstrap_admin.php';
if (has_post()) {
    $product = get_product_by_id($_POST['product_id']);
    $updated_product = ['id' => get_from_post('product_id', $product['id']), 'name' => get_from_post('name', $product['name']), 'price' => get_from_post('price', $product['price']), 'brand' => get_from_post('brand', $product['brand']), 'description' => get_from_post('description', $product['description']), 'categories' => get_from_post('categories', $product['categories'])];
    update_product($updated_product);
    header('Location: /admin/index.php');
    die;
}
if (!array_key_exists('product_id', $_GET)) {
    header('Location: /admin/index.php');
    die;
}
$product = get_product_by_id($_GET['product_id']);
echo render_admin_template('product_form', ['title' => 'Edit product', 'product' => $product, 'user' => get_current_admin_user()]);
コード例 #8
0
ファイル: products.php プロジェクト: jahswant/pharmacy
<?php

include 'functions.php';
include 'model.php';
echo embed('tpl/home.tpl.php', array('header' => embed('tpl/header.tpl.php', array()), 'sidebar_first' => embed('tpl/category.tpl.php', array('result' => get_category())), 'body' => embed('tpl/product.tpl.php', array('result' => get_product_by_id($_GET['id'])))));