私は JavaScript の初心者で、自分で解決策を見つけることができません...一部の PHP 変数で sendform チェックアウトを行った後、アイテムのサイズを取得したいと考えています。
コンテキスト:
1 - お客様がサイズと数量を選択し、製品をバスケットに追加できる製品ページです。
2 - サム、数量、サイズ、価格などを含むチェックアウト ページと、sendform による検証 (チェックアウト ページにフォームはありません。php ですべてのアイテム変数を取得するためだけです)
3 - 戻るページPHP のすべてのアイテム (顧客は各アイテムの写真をアップロードする必要があります):
$content = $_POST;
$item_number = array(); // compteur d items
$item = array(); // tableaux qui récupere les valeurs de chaque items
for($i=1; $i < $content['itemCount'] + 1; $i++)
{
$name = 'item_name_'.$i;
$quantity = 'item_quantity_'.$i;
$price = 'item_price_'.$i;
$thumb = 'item_thumb_'.$i;
$id = 'item_id_'.$i;
$size = 'item_size_'.$i;
$item_number['total'] = $i;
$item[$i]['name'] = $content[$name];
$item[$i]['quantity'] = $content[$quantity];
$item[$i]['price'] = $content[$price];
$item[$i]['thumb'] = $content[$thumb];
$item[$i]['id'] = $content[$id];
$item[$i]['size'] = $content[$size];
}
$total = $item_number['total'];
$line = 0;
while ($line <= $total -1)
{
$line++;
echo $item[$line]['name'];
echo $item[$line]['size'];
}?>
サイズ以外はすべて正常に動作しているようです...アイテムページでは、チェックアウトページに正しく表示される「item_size」クラスのサイズの選択フォームを使用していますが、3番目のページには何もありません。 ..
誰かこの嘆願を手伝ってくれませんか...
編集:誰かが私の後にこれを疑問に思うなら、解決策を見つけました:
この場合、アイテムに追加するカスタムクラス属性
class="item_size"
と呼ばれるJavaScript配列に格納されます
item_options
そのため、php 変数で item_option を取得し、explode 関数で chars チェーンを分割する必要があります。
$content = $_POST;
$item_number = array(); // compteur d items
$item = array(); // tableaux qui récupere les valeurs de chaque items
for($i=1; $i < $content['itemCount'] + 1; $i++)
{
//I passed two params in item_options, the size and a path to an picture
$options = 'item_options_'.$i; //let s get the name of the java var in a php var
$item_number['total'] = $i; //let s count the number of items
$item[$i]['options'] = $content[$options]; //let s get the values of item_options
}
$total = $item_number['total'];
$line = 0;
while ($line <= $total -1)
{
$line++;
$split_options = explode(",", $item[$line]['options']); // explode the chain in few chains
$split_thumb = explode(":", $split_options[0]); // for each chain, cut the useless part before ":", for exemple thumbPath: ../pictures
$split_size = explode(":", $split_options[1]);
echo $split_thumb[1]; // display the path of my thumb
echo $split_size[1]; // display the size of my item
}?>