add order route

This commit is contained in:
Your Name
2021-06-19 23:26:37 +03:00
parent fe4db1b3e0
commit d328ffa7b0
9 changed files with 144 additions and 6 deletions

View File

@@ -4,7 +4,6 @@ function product_kuri($slug){
$book = bookid_kuri($slug);
$breadcrumbs = [
$book['categoryname'] => SITE.'category/'.$book['categoryslug'],
'page' => $book['pricename']
@@ -25,6 +24,11 @@ function product_kuri($slug){
# купил ли эту книжку
$buy_status = client_status_book($books['book_id'], CLIENT_ID);
}
# линки на оформление заказа
$link_online = SITE.'checkout/'.$book['priceslug'].'/1';
$link_offline = SITE.'checkout/'.$book['priceslug'].'/2';
$link_subscript = SITE.'checkout/podpiska-na-elektronnuyu-versiyu-gazety-argumenty-nedeli-na-god/1';
$tempcontent = VIEWPATH.'book.phtml';
include VIEWPATH.'layout.phtml';

View File

@@ -92,8 +92,6 @@ function restoration_kuri(){
$hashlink = SITE.'resetlink/'.$hash;
}
echo $hashlink;
$tempcontent = VIEWPATH.'restore_add.phtml';
include VIEWPATH.'layout.phtml';
}

69
app/routes/order.php Normal file
View File

@@ -0,0 +1,69 @@
<?php
/**
* оформление заказа
*/
function checkout_kuri($priceslug, $buy_type = 1){
$price_id = db_get("SELECT * FROM `price` WHERE `priceslug` = '$priceslug' LIMIT 1");
if (isset($price_id['price_id'])) {
if ($buy_type == 1){ // тип товара
$price = $price_id['price']; // электронная книжка
}
else {
$price = $price_id['offline_price']; // бумажная книжка
}
if (defined('CLIENT_ID')){
$client = client_find_id(CLIENT_ID);
if (isset($client['result']['client_id'])){
$clienthash = $client['result']['clienthash'];
}
}
if (isset($_POST['clientmail'])){
$clientmail = $_POST['clientmail'];
if (!filter_var($clientmail, FILTER_VALIDATE_EMAIL)){
$error_mail = True;
}
else {
# получаем хэш клиента чтобы отправить на оплату
$clienthash = api_add_client($clientmail);
}
}
if (isset($clienthash) and $clienthash) {
$paylink = PAYSITE."anpay/$priceslug/$clienthash";
header("Location: $paylink");
return True;
}
}
else {
$error_price = True;
}
$submit_link = SITE."checkout/$priceslug/$buy_type";
include VIEWPATH.'checkout.phtml';
}