diff --git a/api/order_add.php b/api/order_add.php new file mode 100644 index 0000000..0aa269f --- /dev/null +++ b/api/order_add.php @@ -0,0 +1,50 @@ +getConnection(); + +$data = json_decode(file_get_contents("php://input")); +$shipping = array( + "full_name" => $data->profile->first_name." ".$data->profile->last_name, + "address" => $data->address, + "city" => $data->city, + "zip_code" => $data->zip_code, + "province" => $data->province +); + +$query = "INSERT INTO `orders` + (`id`, `uid`, `date`, `items`, `total`, `status`, `token`, `shipping`, `traking`) + VALUES (NULL, ".intval($data->uid).", NOW(), '".json_encode($data->cart)."', ".floatval($data->total).", + 'PAID', + '".trim($data->token)."', + '".json_encode($shipping)."', '')"; + +$stmt = $conn->prepare($query); + +if($stmt->execute()) { + http_response_code(200); + echo json_encode( + array( + "status" => 200, + "id" => $conn->lastInsertId() + )); +} else { + http_response_code(400); + echo json_encode( + array( + "status" => 400, + "message" => "Error inserting new order" + )); +} + +?> + diff --git a/api/user_add.php b/api/user_add.php index eaa998a..7db36b1 100644 --- a/api/user_add.php +++ b/api/user_add.php @@ -27,7 +27,7 @@ if($stmt->execute()) { echo json_encode( array( "status" => 200, - "profile" => $data + "id" => $conn->lastInsertId() )); } else { http_response_code(400); diff --git a/components/checkout/checkout.html b/components/checkout/checkout.html index b404fbc..28f1c15 100644 --- a/components/checkout/checkout.html +++ b/components/checkout/checkout.html @@ -30,11 +30,23 @@
+ "; + } + ?> +
Dettagli fatturazione - - Sei già nostro cliente? - + + Sei già nostro cliente? + + + + + Hai effettuato l'accesso come + . + Esci