Files
AtomicOld/ajax/preorder.php

44 lines
1.5 KiB
PHP
Raw Permalink Normal View History

2026-02-14 19:34:54 +03:00
<?php
session_start();
chdir('..');
error_reporting(E_ALL);
require_once('api/Simpla.php');
$simpla = new Simpla();
if($simpla->request->method('post'))
{
$order->name2 = $simpla->request->post('name2');
$order->name = $simpla->request->post('name');
$order->phone = $simpla->request->post('phone');
$order->email = $simpla->request->post('email');
$order->comment = $simpla->request->post('comment');
// if(empty($order->name))
// $simpla->design->assign('error', 'empty_name');
// if(empty($order->name2))
// $simpla->design->assign('error', 'empty_name2');
if(empty($order->phone))
$simpla->design->assign('error', 'empty_phone');
//elseif(empty($order->email))
// $simpla->design->assign('error', 'empty_email');
else{
$order->ip = $_SERVER['REMOTE_ADDR'];
$order_id = $simpla->orders->add_order($order);
$simpla->orders->add_purchase(array('order_id'=>$order_id, 'variant_id'=>$simpla->request->post('variant', 'integer'), 'amount'=>1));
$simpla->notify->email_order_admin($order_id);
$simpla->design->assign('result', 1);
$simpla->design->assign('order_id', $order_id);
}
}
$result = $simpla->design->fetch('ajax_order.tpl');
//header("Content-type: application/json; charset=UTF-8");
header("Content-type: text/html; charset=UTF-8");
header("Cache-Control: must-revalidate");
header("Pragma: no-cache");
header("Expires: -1");
//print_r( $_POST );
//print json_encode($result);
print $result;