Last active
November 14, 2019 11:59
-
-
Save 0test/c0c88cf858f3d82784f6b6610fc73962 to your computer and use it in GitHub Desktop.
Поиск и быстрая покупка аякс
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
define('MODX_API_MODE', true); | |
include_once("index.php"); | |
$modx->db->connect(); | |
if (empty ($modx->config)){ | |
$modx->getSettings(); | |
} | |
$modx->invokeEvent("OnWebPageInit"); | |
if(!isset($_SERVER['HTTP_X_REQUESTED_WITH']) || (strtolower($_SERVER['HTTP_X_REQUESTED_WITH']) != 'xmlhttprequest')){ | |
$modx->sendRedirect($modx->config['site_url']); | |
} | |
switch($_REQUEST['q']){ | |
case 'search': | |
$phrase = $modx->db->escape($_POST['search']); | |
$result = $modx->runSnippet('DocLister', array( | |
'parents' => 7, | |
'depth' => 4, | |
'tpl' => '@CODE: <div class="sres"><a href="[+url+]">[+pagetitle+]</a><span>артикул [+article+]</span></div>', | |
'tvPrefix' => '', | |
'tvList' => 'article', | |
'addWhereList' => 'c.template = 10', | |
'filters' => 'OR(content:pagetitle:like:'.$phrase.';tvd:article:like:'.$phrase.')', | |
'ownerTPL' => '@CODE: [+dl.wrap+]', | |
'noneTPL' => '@CODE: Товары не найдены. Вы можете ввести название или артикул товара', | |
'noneWrapOuter' => 1, | |
)); | |
echo $modx->parseDocumentSource($result); | |
exit; | |
break; | |
case 'qpay_form': | |
$result = $modx->runSnippet('FormLister', array( | |
'formid' => 'qpay_form', | |
'rules' => ' | |
{ | |
"name":{ | |
"required":"Обязательно введите имя" | |
}, | |
"phone":{ | |
"required":"Обязательно введите номер телефона", | |
"phone":"Введите номер правильно" | |
} | |
}', | |
'to' => '[email protected]', | |
'reportTpl' => 'qpayReport', | |
'subject' => 'Быстрый заказ с сайта Угги', | |
'errorClass' => ' has-error', | |
'requiredClass' => ' has-warning', | |
'messagesOuterTpl' => '@CODE:<div class="alert alert-danger" role="alert">[+messages+]</div>', | |
'errorTpl' => '@CODE:<span class="help-block">[+message+]</span>', | |
'formControls=`size', | |
'prepare' => array(function($modx, $data, $FormLister, $name){ | |
//делаем урл для отчёта | |
if ( isset($data['qpay_id']) && !empty($data['qpay_id']) ){ | |
$data['item_url'] = $modx->makeUrl($data['qpay_id'], '', '', 'full'); | |
} | |
return $data; | |
}), | |
'formTpl' => 'qpay_form_tpl', | |
'successTpl' => 'qpaySuccess', | |
'removeEmptyPlaceholders' => 1 | |
)); | |
echo $modx->parseDocumentSource($result); | |
exit(); | |
break; | |
default: | |
$modx->sendForward($modx->config['error_page']); | |
break; | |
} | |
?> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<form method="post" action="cart" id="qpay_form"> | |
<input name="formid" type="hidden" value="qpay_form"> | |
<input type="hidden" name="qpay_id" id="qpay_id" value="[+qpay_id+]"> | |
[+form.messages+] | |
<div class="row"> | |
<div class="col-sm-12"> | |
<fieldset id="account"> | |
<div class="form-group required [+name.errorClass+][+name.requiredClass+]"> | |
<label class="control-label" for="input-name">Имя</label> | |
<input type="text" name="name" placeholder="" class="form-control" value="[+name+]"> | |
[+name.error+] | |
</div> | |
<div class="form-group required [+phone.errorClass+][+name.requiredClass+]"> | |
<label class="control-label" for="input-phone">Телефон</label> | |
<input type="text" name="phone" placeholder="" class="form-control" value="[+phone+]"> | |
[+phone.error+] | |
</div> | |
<div class="form-group required"> | |
<label class="control-label" for="input-address">Размер</label> | |
<input type="text" name="size" id="size_qform" placeholder="" class="form-control" value="[+size+]"> | |
</div> | |
[+append_elements+] | |
</fieldset> | |
</div> | |
</div> | |
<div class="buttons"> | |
<div class="pull-left"> | |
<button type="submit" name="submit" class="button button-cart">Отправить <i class="material-design-forward18"></i></button> | |
</div> | |
</div> | |
</form> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment