Init
This commit is contained in:
40
ajax/order.php
Normal file
40
ajax/order.php
Normal file
@@ -0,0 +1,40 @@
|
||||
<?php
|
||||
session_start();
|
||||
chdir('..');
|
||||
error_reporting(0);
|
||||
require_once('api/Simpla.php');
|
||||
$simpla = new Simpla();
|
||||
|
||||
if($simpla->request->method('post'))
|
||||
{
|
||||
$order->name = $simpla->request->post('name');
|
||||
$order->phone = $simpla->request->post('phone');
|
||||
$order->comment = $simpla->request->post('comment', 'string');
|
||||
if(empty($order->name))
|
||||
$simpla->design->assign('error', 'Введите имя');
|
||||
elseif(empty($order->phone))
|
||||
$simpla->design->assign('error', 'Введите телефон');
|
||||
//elseif(empty($order->comment))
|
||||
// $simpla->design->assign('error', 'Введите сообщение');
|
||||
else{
|
||||
$order->ip = $_SERVER['REMOTE_ADDR'];
|
||||
$order_id = $simpla->orders->add_order($order);
|
||||
//if(trim($item_product_name))
|
||||
// $simpla->orders->add_purchase(array('order_id'=>$order_id, 'product_name'=>item_product_name));
|
||||
$simpla->orders->add_purchase(array('order_id'=>$order_id, 'variant_id'=>$simpla->request->post('variant', 'integer'), 'amount'=>$simpla->request->post('amount', 'integer')));
|
||||
|
||||
$simpla->notify->email_order_admin($order_id);
|
||||
|
||||
$simpla->design->assign('result', 1);
|
||||
$simpla->design->assign('order_id', $order_id);
|
||||
}
|
||||
}
|
||||
$result = $simpla->design->fetch('order_result.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;
|
||||
Reference in New Issue
Block a user