0

PayPal を使用するショッピング カートを作成しました。ユーザーが 2 つの製品を購入すると、アレイは IPN に送信されます。デリミタを使用して新しい製品情報変数を作成する方法がわかりません。たとえば、これはユーザーが購入するものです。

ここに画像の説明を入力

配列は次のようになります。

35 *-* 1 *-* XS *-* BO-CB005B Mountain Bke Entry Level, 33 *-* 1 *-* XS *-* B014 Mountian Bike,

ユーザーに送信される電子メールには、最初のコンマの後の最後の製品のみが表示されます。前回の商品ではなく、注文した商品をすべて表示したいです。

ここに画像の説明を入力

最後の配列ではなく、すべての配列を表示するにはどうすればよいですか?

これは、アレイを IPN に送信するカート内のコードです。

$product_id_array .= "$item_id *-* " .$each_item['quantity']." *-* " . $each_item['size'] . " *-* ". $product_name . ", ";  

これはIPNスクリプトのコードです

$product_id_string = $_POST['custom'];
$product_id_string = rtrim($product_id_string, ","); // remove last comma
// Explode the string, make it an array, then query all the prices out, add them up, and make sure they match the payment_gross amount
$id_str_array = explode(",", $product_id_string); // Uses Comma(,) as delimiter(break point)
$fullAmount = 0;
foreach ($id_str_array as $key => $value) {

    $id_quantity_pair = explode("*-*", $value); // Uses Hyphen(-) as delimiter to separate product ID from its quantity
    $product_id = $id_quantity_pair[0]; // Get the product ID
    $product_quantity = $id_quantity_pair[1]; // Get the quantity
    $product_size = $id_quantity_pair[2];
    $product_name = $id_quantity_pair[3];

    $productInfo = "ID: <strong>$product_id</strong> <br />Name: <strong>$product_name</strong><br />Quantity: <strong>$product_quantity</strong><br />Size: <strong>$product_size</strong>";   

    $sql = mysql_query("SELECT price FROM productList WHERE id='$product_id' LIMIT 1");
    while($row = mysql_fetch_array($sql)){
        $product_price = $row["price"];
    }
    $product_price = $product_price * $product_quantity;
    $fullAmount = $fullAmount + $product_price;
}

「カスタム」はペイパルに送信される非表示の値です。

<input type="hidden" name="custom" value="'.$product_id_array.'">
4

1 に答える 1