我有一個用于汽車零件的 PhP 購物車,我需要捕獲所有選擇的產(chǎn)品,然后在單擊“提交訂單”后將它們與聯(lián)系表格一起發(fā)送到我的電子郵件中。到目前為止,我已經(jīng)成功地發(fā)送了第一個選擇的產(chǎn)品,但我需要捕獲所有選擇的產(chǎn)品,而不僅僅是一個。我嘗試使用所選產(chǎn)品的所有屬性捕獲數(shù)組本身,但它只向我發(fā)送了第一個選擇的產(chǎn)品。博士<?phpif(!empty($_GET["action"])) {switch($_GET["action"]) { case "add": if(!empty($_POST["quantity"])) { $productByCode = $db_handle->runQuery("SELECT * FROM mystuff WHERE mscode='" . $_GET["mscode"] . "'"); $itemArray = array($productByCode[0]["mscode"]=>array('mscategory'=>$productByCode[0]["mscategory"], 'mscatnum'=>$productByCode[0]["mscatnum"], 'msnomer'=>$productByCode[0]["msnomer"], 'msmark'=>$productByCode[0]["msmark"], 'msmodel'=>$productByCode[0]["msmodel"], 'msyear'=>$productByCode[0]["msyear"],'mscode'=>$productByCode[0]["mscode"], 'quantity'=>$_POST["quantity"], 'msprice'=>$productByCode[0]["msprice"], 'msimage'=>$productByCode[0]["msimage"])); if(!empty($_SESSION["cart_item"])) { if(in_array($productByCode[0]["mscode"],array_keys($_SESSION["cart_item"]))) { foreach($_SESSION["cart_item"] as $k => $v) { if($productByCode[0]["mscode"] == $k) { if(empty($_SESSION["cart_item"][$k]["quantity"])) { $_SESSION["cart_item"][$k]["quantity"] = 0; } $_SESSION["cart_item"][$k]["quantity"] += $_POST["quantity"]; } } } else { $_SESSION["cart_item"] = array_merge($_SESSION["cart_item"],$itemArray); } } else { $_SESSION["cart_item"] = $itemArray; } } break; case "empty": unset($_SESSION["cart_item"]); break; }}?>
- 1 回答
- 0 關(guān)注
- 127 瀏覽
添加回答
舉報
0/150
提交
取消