Skip to content
Snippets Groups Projects
processCartContents.php 896 B
Newer Older
jchua's avatar
jchua committed
<?php
jchua's avatar
jchua committed
session_start();
jchua's avatar
jchua committed

jchua's avatar
jchua committed
$orders = simplexml_load_file('private/orders.xml');
$newOrder = $orders->addChild('order');

$delivery = $newOrder->addChild('delivery');
$name = $delivery->addChild('name', $_SESSION['deliveryName']);
jchua's avatar
jchua committed
$username = $delivery->addChild('username', $_SESSION['authenticatedUser']);
jchua's avatar
jchua committed
$email = $delivery->addChild('email', $_SESSION['deliveryEmail']);
$address = $delivery->addChild('address', $_SESSION['deliveryAddress1']);
$city = $delivery->addChild('city', $_SESSION['deliveryCity']);
$postcode = $delivery->addChild('postcode', $_SESSION['deliveryPostcode']);

$items = $newOrder->addChild('items');
jchua's avatar
jchua committed

jchua's avatar
jchua committed
$arr = json_decode(file_get_contents("php://input"));
jchua's avatar
jchua committed
foreach ($arr as $value){
jchua's avatar
jchua committed
    $item = $items->addChild('item');
    $title = $item->addChild('title', $value->title);
    $price = $item->addChild('price', $value->price);
jchua's avatar
jchua committed
}

jchua's avatar
jchua committed
$orders->saveXML('private/orders.xml');
jchua's avatar
jchua committed