Problem: I have a variables from magento that stored in the model class and can be get as
$productArray[] = array();
foreach ($order->getAllItems() as $item) {
$productArray[] = array(
"product" => $item->getName(),
"qty" => $item->getQtyOrdered(),
"amount" => $item->getPrice(),
);
}
This are the values if print_r the $productArray[]:
Sample Output 1:
array(1) {
[0]=>
array(3) {
["product_name"]=>
string(12) "Test Product"
["product_qty"]=>
string(6) "2.0000"
["product_price"]=>
string(7) "12.0000"
}
}
Sample Output 2:
array(2) {
[0]=>
array(3) {
["product_name"]=>
string(12) "Test Product"
["product_qty"]=>
string(6) "2.0000"
["product_price"]=>
string(7) "12.0000"
}
[1]=>
array(3) {
["product_name"]=>
string(6) "Test 2"
["product_qty"]=>
string(6) "5.0000"
["product_price"]=>
string(7) "22.0000"
}
}
And how can you make it like this?(should be print like this)
If output 1: Final Output 1
<input type="hidden" name="product" value="Test Product" />
<input type="hidden" name="amount" value="24.00" />
If output 2: Final Output 2
<input type="hidden" name="product1" value="Test Product" />
<input type="hidden" name="amount1" value="24.00" />
<input type="hidden" name="product2" value="Test 2" />
<input type="hidden" name="amount2" value="110.00" />
The amount value will be get in product_price * product_qty.
Have some fun :) This is only a dummy problem, but this can be helpful to others