我试图制作推车,在某些物品上你可以拥有属性。除了我无法从某些项目中提取选项外,所有代码都有效。
PayPal IPN拉码:
$value_select = $_POST['os'.$j.'_'.$number];
$ j计数是正确的,$ number是项目ID,但我返回错误,说它不存在。
我的HTML和PhP代码:
<form target="paypal" action="https://www.paypal.com/cgi-bin/webscr" method="post">
<input type="hidden" name="business" value="medievalpvp1060@gmail.com">
<input type="hidden" name="cmd" value="_cart">
<input type="hidden" name="notify_url" value="http://www.littlemischiefs.co.uk/temp/api/ipn">
<input type="hidden" name="add" value="1">
<input type="hidden" name="item_name" value="item test">
<input type="hidden" name="item_number" value="1">
<input type="hidden" name="amount" value="0.20">
Colour:
<input type="hidden" name="on0" value="colour">
<select name="os0">
<option value="pink">pink</option>
<option value="yellow">yellow</option>
</select><br />
Text Line 0:
<input type="hidden" name="on1" value="text line 0">
<input type="text" name="os1"><br />
Text Line 2:
<input type="hidden" name="on2" value="text line 2">
<input type="text" name="os2"><br /><br/>
<input type="hidden" name="currency_code" value="GBP">
<input type="hidden" name="shopping_url" value="**************">
<input type="submit" name="submit" value="Add to Cart" />
</form>
答案 0 :(得分:1)
此代码将使$ cart_items数组中的所有订单商品都可用。
$i = 1;
$cart_items = array();
while(isset($_POST['item_number' . $i]))
{
$item_number = isset($_POST['item_number' . $i]) ? $_POST['item_number' . $i] : '';
$item_name = isset($_POST['item_name' . $i]) ? $_POST['item_name' . $i] : '';
$quantity = isset($_POST['quantity' . $i]) ? $_POST['quantity' . $i] : '';
$mc_gross = isset($_POST['mc_gross_' . $i]) ? $_POST['mc_gross_' . $i] : 0;
$mc_handling = isset($_POST['mc_handling' . $i]) ? $_POST['mc_handling' . $i] : 0;
$mc_shipping = isset($_POST['mc_shipping' . $i]) ? $_POST['mc_shipping' . $i] : 0;
$custom = isset($_POST['custom' . $i]) ? $_POST['custom' . $i] : '';
$option_name1 = isset($_POST['option_name1_' . $i]) ? $_POST['option_name1_' . $i] : '';
$option_selection1 = isset($_POST['option_selection1_' . $i]) ? $_POST['option_selection1_' . $i] : '';
$option_name2 = isset($_POST['option_name2_' . $i]) ? $_POST['option_name2_' . $i] : '';
$option_selection2 = isset($_POST['option_selection2_' . $i]) ? $_POST['option_selection2_' . $i] : '';
$option_name3 = isset($_POST['option_name3_' . $i]) ? $_POST['option_name3_' . $i] : '';
$option_selection3 = isset($_POST['option_selection3_' . $i]) ? $_POST['option_selection3_' . $i] : '';
$option_name4 = isset($_POST['option_name4_' . $i]) ? $_POST['option_name4_' . $i] : '';
$option_selection4 = isset($_POST['option_selection4_' . $i]) ? $_POST['option_selection4_' . $i] : '';
$option_name5 = isset($_POST['option_name5_' . $i]) ? $_POST['option_name5_' . $i] : '';
$option_selection5 = isset($_POST['option_selection5_' . $i]) ? $_POST['option_selection5_' . $i] : '';
$option_name6 = isset($_POST['option_name6_' . $i]) ? $_POST['option_name6_' . $i] : '';
$option_selection6 = isset($_POST['option_selection6_' . $i]) ? $_POST['option_selection6_' . $i] : '';
$option_name7 = isset($_POST['option_name7_' . $i]) ? $_POST['option_name7_' . $i] : '';
$option_selection7 = isset($_POST['option_selection7_' . $i]) ? $_POST['option_selection7_' . $i] : '';
$option_name8 = isset($_POST['option_name8_' . $i]) ? $_POST['option_name8_' . $i] : '';
$option_selection8 = isset($_POST['option_selection8_' . $i]) ? $_POST['option_selection8_' . $i] : '';
$option_name9 = isset($_POST['option_name9_' . $i]) ? $_POST['option_name9_' . $i] : '';
$option_selection9 = isset($_POST['option_selection9_' . $i]) ? $_POST['option_selection9_' . $i] : '';
$btn_id = isset($_POST['btn_id' . $i]) ? $_POST['btn_id' . $i] : '';
$current_item = array(
'item_number' => $item_number,
'item_name' => $item_name,
'quantity' => $quantity,
'mc_gross' => $mc_gross,
'mc_handling' => $mc_handling,
'mc_shipping' => $mc_shipping,
'custom' => $custom,
'option_name1' => $option_name1,
'option_selection1' => $option_selection1,
'option_name2' => $option_name2,
'option_selection2' => $option_selection2,
'option_name3' => $option_name3,
'option_selection3' => $option_selection3,
'option_name4' => $option_name4,
'option_selection4' => $option_selection4,
'option_name5' => $option_name5,
'option_selection5' => $option_selection5,
'option_name6' => $option_name6,
'option_selection6' => $option_selection6,
'option_name7' => $option_name7,
'option_selection7' => $option_selection7,
'option_name8' => $option_name8,
'option_selection8' => $option_selection8,
'option_name9' => $option_name9,
'option_selection9' => $option_selection9,
'btn_id' => $btn_id
);
array_push($cart_items, $current_item);
$i++;
}
答案 1 :(得分:1)
此问题已修复,这是为所有需要建议的人提供的。
使用os<param.catch>
(os0
)将成为捕手param0的参数。
FIX:
在html中使用os0,os1,os2 ..等作为值代码,但请务必将on0称为标签,例如<input type="hidden" value="Anything here">
。
在您的IPN电话$_POST['option_selection'.$paramcatch.'_'.$item_id]
因此,例如需要第1项和第2项的数据:
$_POST['option_selection0_1'] = os0 from item 1
$_POST['option_selection1_1'] = os1 from item 1
$_POST['option_selection2_1'] = os2 from item 1
$_POST['option_selection0_2'] = os0 from item 2
$_POST['option_selection1_2'] = os1 from item 2
$_POST['option_selection2_2'] = os2 from item 2
希望这对很多人有所帮助!我已经解决了我的问题只是想帮助你们其他人!!
感谢您的评论!