$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')); $color_str = $productMgr->getColor($product_id); $new_color_str = str_replace($old_color, $new_color, $color_str); $productMgr->updateColor($product_id, $new_color_str); $productMgr->updateColorInOptionalCodeTable($product_id, $new_color, $old_color); $photoMgr->updateColorInPhotoTable($product_id, $new_color, $old_color); $return = []; $return['status'] = 'success'; echo json_encode($return);