Exemplo n.º 1
0
    $colors = implode(",", $colorArr);
    $productMgr->updateProduct($product_id, $product_name, $symbol_code, $price, $colors, $description, $stock);
    header("Location: admin.php#viewProduct");
} elseif ($operation === "add_product_to_cart") {
    session_start();
    $customer_id = $_SESSION["userid"];
    //$customer_id = filter_input(INPUT_POST,'customer_id');
    $product_id = filter_input(INPUT_POST, 'product_id');
    $qty = filter_input(INPUT_POST, 'product_qty');
    $productMgr->addProductToShoppingCart($customer_id, $product_id, $qty);
    //$_SESSION["message_add_cart"] = "Your Selected Prodcut has been added";
    //header("Location: testAddToCart.php");
} elseif ($operation === "deletePhoto") {
    $product_id = addslashes(filter_input(INPUT_POST, 'product_id'));
    $photo_type = addslashes(filter_input(INPUT_POST, 'photo_type'));
    $photoMgr->deletePhoto($product_id, $photo_type);
    $color_str = $productMgr->getColor($product_id);
    $color_arr = explode(",", $color_str);
    if (($key = array_search($photo_type, $color_arr)) !== false) {
        unset($color_arr[$key]);
    }
    $new_color_str = implode(",", $color_arr);
    $productMgr->updateColor($product_id, $new_color_str);
    $productMgr->deleteColorOptionalCodeByProductColor($product_id, $photo_type);
    $return = [];
    $return['status'] = 'success';
    echo json_encode($return);
} elseif ($operation === "updateColor") {
    $product_id = addslashes(filter_input(INPUT_POST, 'product_id'));
    $new_color = addslashes(filter_input(INPUT_POST, 'new_color'));
    $old_color = addslashes(filter_input(INPUT_POST, 'old_color'));