- Final step
It's time for the money to travel from one hand to another
| Album | Product | Quantity | Unit price | Total price |
';
$items=array_keys(json_decode($_POST['item'], true));
$_POST['shipping']=json_decode($_POST['shipping'], true);
$order=json_decode($_POST['item'], true);
$options=json_decode($_POST['option'], true);
$tip=floatval($_POST['tip']);
$currency=$material_currency;
$bill=Array();
$bill['order']=$order;
$bill['options']=$options;
$bill['shipping']=$_POST['shipping'];
$bill['tip']=$tip;
$bill['currency']=$currency;
$productcount=0;
$unitcount=0;
$pricecount=0;
foreach ($items as $item){
$products=array_keys($order[$item]);
foreach ($products as $product){
if (is_numeric($order[$item][$product])&&intval($order[$item][$product])>0){
echo '| '.htmlspecialchars($item).' | '.htmlspecialchars($product);
if (in_array($product, array_keys($material_support))){
$that=$material_support[$product]['option'];
if (isset($that)&&$that!==''){
echo ' Option: ';
if (isset($options[$item][$product])){
echo htmlspecialchars($options[$item][$product]);
}
else {
echo 'Please select an option for this item, otherwise we will consider you do not mind and chose it randomly in our stock';
}
}
}
echo ' | ';
echo ''.htmlspecialchars($order[$item][$product]);
echo ' | ';
$howmany=intval($order[$item][$product]);
$unitprice=$material_support[$product]['price'];
$totalprice=$unitprice * $howmany;
echo ''.htmlspecialchars($unitprice).' | ';
echo ''.htmlspecialchars($totalprice).' | ';
echo '
';
$unitcount+=$howmany;
$pricecount+=$totalprice;
$productcount+=$order[$item][$product];
}
}
}
echo '| Raw total | ';
echo ''.htmlspecialchars($unitcount).' | ';
echo 'N/A | ';
echo ''.htmlspecialchars($pricecount).' | ';
echo '
';
echo '';
echo '| Shipping | ';
echo ''.htmlspecialchars($_POST['shipping']).' | ';
if (in_array($_POST['shipping'],array_keys($material_shipping))){
$shipping_price=floatval($material_shipping[$_POST['shipping']]);
}
else
{ die(); }
echo ''.htmlspecialchars($unitcount).' | ';
echo ''.htmlspecialchars($shipping_price).' | ';
$totalshipping=$unitcount*$shipping_price;
echo ''.htmlspecialchars($totalshipping).' | ';
echo '
';
echo '| Net total | ';
echo ''.htmlspecialchars($totalshipping+$pricecount).' | ';
echo '
';
echo '';
$bill['amount']=$totalshipping+$pricecount;
$total=$totalshipping+$pricecount+(floor($tip*100)/100);
$totalminusshipping=$pricecount+(floor($tip*100)/100);
$bill['total']=$total;
if ($ismaterialnameyourprice){
$bill['amount']=0;
$bill['total']=(floor($tip*100)/100);
}
if (file_exists('./d/orders')&&!is_dir('./d/orders')) {
echo 'The system is misconfigured. "orders" must be a directory. Please fix this, if you are the webmaster. If you are not, please tell him to do so.';
} else if (file_exists('./d/material_messages')&&!is_dir('./d/material_messages')) {
echo 'The system is misconfigured. "material_messages" must be a directory. Please fix this, if you are the webmaster. If you are not, please tell him to do so.';
}
else {
if (!file_exists('./d/orders')) {
mkdir('./d/orders');
}
if (!file_exists('./d/material_messages')) {
mkdir('./d/material_messages');
}
$past_bills=array_diff(scandir('./d/orders/'), array('..', '.'));
$orderid=(count($past_bills)+1).'-'.microtime(true);
$orderdata=serialize ($bill);
mkdir ('./d/material_messages/'.$orderid);
if (file_put_contents('./d/orders/'.$orderid.'.dat', $orderdata)){
echo 'Your order has been correctly recorded in our system under the reference '.htmlspecialchars($orderid).'. Please click on the above button to be redirected to a secure money transfer service and process the payment : ';
?>