Ошибка Uncaught TypeError: $.loadLocations is not a function
Вроде все поправил, но опять ничего не работает. Форма грузится, прелоадер крутится без остановки
Подскажите, где ошибка!?
Здесь:
<?php
Core_Session::start();
$oShop = Core_Entity::factory('Shop', Core_Array::get(Core_Page::instance()->libParams, 'shopId'
);
$ShopControllerShow = new Shop_Controller_Show($oShop);
$ShopControllerShow
->limit(99999)
->parseUrl();
Core_Page::instance()->object = $ShopControllerShow;
//прячем страницы товара
if ($ShopControllerShow->item){
$ShopControllerShow->error404();
}
// Добавление товара в корзину
if (Core_Array::getRequest('add'
){
$shopItemId = intval(Core_Array::getRequest('add'
);
if ($shopItemId){
$oShopCartController = Shop_Cart_Controller::instance();
$oShopCartController
->checkStock(FALSE)
->shop_item_id($shopItemId)
->quantity(Core_Array::getRequest('count', 1))
->add();
}
$coupon = trim(strval(Core_Array::getRequest('coupon_text'
));
// Ajax
if (Core_Array::getRequest('_', FALSE)){
ob_start();
// Краткая корзина
$curXsl = Core_Array::getRequest('xsl', false) ? Core_Array::getRequest('xsl'
: Core_Array::get(Core_Page::instance()->libParams, 'littleCartXsl'
;
$ShopCartControllerShow = new Shop_Cart_Controller_Show($oShop);
$ShopCartControllerShow
->xsl(
Core_Entity::factory('Xsl'
->getByName(strval($curXsl))
)
->couponText($coupon)
->show();
echo json_encode(ob_get_clean());
exit();
}
}
// Удаляение товара из корзины
if (Core_Array::getGet('delete'
){
$shopItemId = intval(Core_Array::getGet('delete'
);
if ($shopItemId){
$ShopCartControllerShow = Shop_Cart_Controller::instance();
$ShopCartControllerShow
->shop_item_id($shopItemId)
->delete();
}
$coupon = trim(strval(Core_Array::getRequest('coupon_text'
));
// Ajax
if (Core_Array::getRequest('_', FALSE)){
ob_start();
// Краткая корзина
$curXsl = Core_Array::getRequest('xsl', false) ? Core_Array::getRequest('xsl'
: Core_Array::get(Core_Page::instance()->libParams, 'fullCartXsl'
;
$ShopCartControllerShow = new Shop_Cart_Controller_Show($oShop);
$ShopCartControllerShow
->xsl(
Core_Entity::factory('Xsl'
->getByName(strval($curXsl))
)
->couponText($coupon)
->show();
echo json_encode(ob_get_clean());
exit();
}
}
// Пересчёт
if (Core_Array::getGet('recount'
){
$ShopCartControllerShow = Shop_Cart_Controller::instance();
$aCart = $ShopCartControllerShow->getAll($oShop);
foreach ($aCart as $oShopCart){
$ShopCartControllerShow
->checkStock(FALSE)
->shop_item_id($oShopCart->shop_item_id)
->quantity(Core_Array::getGet('quantity_' . $oShopCart->shop_item_id))
->update();
}
// Запоминаем купон
$coupon = trim(strval(Core_Array::getRequest('coupon_text'
));
//$_SESSION['hostcmsOrder']['coupon_text'] = trim(strval(Core_Array::getGet('coupon_text'
));
// Ajax
if (Core_Array::getRequest('_', FALSE)){
//var_dump($_SESSION['hostcmsOrder']['coupon_text']);
//var_dump(Core_Array::get($_SESSION, 'coupon_text'
);
ob_start();
$curXsl = Core_Array::getRequest('xsl', false) ? Core_Array::getRequest('xsl'
: Core_Array::get(Core_Page::instance()->libParams, 'fullCartXsl'
;
$ShopCartControllerShow = new Shop_Cart_Controller_Show($oShop);
$ShopCartControllerShow
->xsl(
Core_Entity::factory('Xsl'
->getByName(strval($curXsl))
)
->couponText($coupon)
->show();
echo json_encode(ob_get_clean());
exit();
}
}
if (!is_null(Core_Array::getGet('ajaxLoad'
))
{
$aObjects = array();
if (Core_Array::getGet('shop_country_id'
)
{
$oShop_Country_Location = Core_Entity::factory('Shop_Country_Location'
;
$oShop_Country_Location
->queryBuilder()
->where('shop_country_id', '=', intval(Core_Array::getGet('shop_country_id'
));
$aObjects = $oShop_Country_Location->getAllByActive(1);
}
elseif (Core_Array::getGet('shop_country_location_id'
)
{
$oShop_Country_Location_City = Core_Entity::factory('Shop_Country_Location_City'
;
$oShop_Country_Location_City
->queryBuilder()
->where('shop_country_location_id', '=', intval(Core_Array::getGet('shop_country_location_id'
));
$aObjects = $oShop_Country_Location_City->getAllByActive(1);
}
elseif (Core_Array::getGet('shop_country_location_city_id'
)
{
$oShop_Country_Location_City_Area = Core_Entity::factory('Shop_Country_Location_City_Area'
;
$oShop_Country_Location_City_Area
->queryBuilder()
->where('shop_country_location_city_id', '=', intval(Core_Array::getGet('shop_country_location_city_id'
));
$aObjects = $oShop_Country_Location_City_Area->getAllByActive(1);
}
$aArray = array('…'
;
foreach ($aObjects as $Object)
{
//$aArray['_' . $Object->id] = $Object->name;
$aArray['_' . $Object->id] = $Object->getName();
}
Core::showJson($aArray);
}
if (Core_Array::getPost('recount'
){
$ShopCartControllerShow = Shop_Cart_Controller::instance();
$aCart = $ShopCartControllerShow->getAll($oShop);
foreach ($aCart as $oShopCart){
$ShopCartControllerShow
->checkStock(FALSE)
->shop_item_id($oShopCart->shop_item_id)
->quantity(Core_Array::getPost('quantity_' . $oShopCart->shop_item_id))
->update();
}
// Запоминаем купон
//$_SESSION['hostcmsOrder']['coupon_text'] = trim(strval(Core_Array::getPost('coupon_text'
));
$coupon = trim(strval(Core_Array::getRequest('coupon_text'
));
//$_SESSION['hostcmsOrder']['coupon_text'] = trim(strval(Core_Array::getGet('coupon_text'
));
// Ajax
if (Core_Array::getRequest('_', FALSE)){
//var_dump($_SESSION['hostcmsOrder']['coupon_text']);
//var_dump(Core_Array::get($_SESSION, 'coupon_text'
);
ob_start();
$curXsl = Core_Array::getRequest('xsl', false) ? Core_Array::getRequest('xsl'
: Core_Array::get(Core_Page::instance()->libParams, 'fullCartXsl'
;
$ShopCartControllerShow = new Shop_Cart_Controller_Show($oShop);
$ShopCartControllerShow
->xsl(
Core_Entity::factory('Xsl'
->getByName(strval($curXsl))
)
->couponText($coupon)
->show();
echo json_encode(ob_get_clean());
exit();
}
}
// Обновление
if(Core_Array::getGet('refresh'
){
// Ajax
ob_start();
$curXsl = Core_Array::getRequest('xsl', false) ? Core_Array::getRequest('xsl'
: Core_Array::get(Core_Page::instance()->libParams, 'fullCartXsl'
;
$coupon = trim(strval(Core_Array::getRequest('coupon_text'
));
$ShopCartControllerShow = new Shop_Cart_Controller_Show($oShop);
$ShopCartControllerShow
->xsl(
Core_Entity::factory('Xsl'
->getByName(strval($curXsl))
)
->couponText($coupon)
->show();
echo json_encode(ob_get_clean());
exit();
}
// Оформление заказа
if (Core_Array::getGet('checkout'
){
// Ajax
$_SESSION['last_order_id'] = 0;
ob_start();
$ShopCartController = Shop_Cart_Controller::instance();
$aCart = $ShopCartController->getAll($oShop);
// TODO: Сделать правильное оформление заказа
// Должны обрабатываться поля: surname, name, patronymic, email, phone, address (см. оригинал оформления)
//
// TODO: !!!!!!!! Форма не должна отправлятся с перезагрузкой страницы
$userPhone = '7'.strval(Core_Array::getGet('phone'
);
$_SESSION['hostcmsOrder']['orderAdminNotificationXsl'] = Core_Array::get(Core_Page::instance()->libParams, 'orderAdminNotificationXsl'
;
$_SESSION['hostcmsOrder']['orderUserNotificationXsl'] = Core_Array::get(Core_Page::instance()->libParams, 'orderUserNotificationXsl'
;
$_SESSION['hostcmsOrder']['checkoutXsl'] = Core_Array::get(Core_Page::instance()->libParams, 'checkoutXsl'
;
$_SESSION['hostcmsOrder']['shop_country_id'] = intval(Core_Array::getGet('shop_country_id', 175));
$_SESSION['hostcmsOrder']['shop_country_location_id'] = intval(Core_Array::getGet('shop_country_location_id', 13));
$_SESSION['hostcmsOrder']['shop_country_location_city_id'] = intval(Core_Array::getGet('shop_country_location_city_id', 532));
// $_SESSION['hostcmsOrder']['shop_country_location_city_area_id'] = intval(Core_Array::getGet('shop_country_location_city_area_id', 0));
$_SESSION['hostcmsOrder']['surname'] = strval(Core_Array::getGet('surname'
);
$_SESSION['hostcmsOrder']['name'] = strval(Core_Array::getGet('name'
);
$_SESSION['hostcmsOrder']['patronymic'] = strval(Core_Array::getGet('patronymic'
);
$_SESSION['hostcmsOrder']['email'] = strval(Core_Array::getGet('email'
);
$_SESSION['hostcmsOrder']['address'] = strval(Core_Array::getGet('address'
);
$_SESSION['hostcmsOrder']['phone'] = $userPhone;
$_SESSION['hostcmsOrder']['shop_delivery_condition_id'] = intval(Core_Array::getGet('shop_delivery_condition_id', 0));
$_SESSION['hostcmsOrder']['shop_delivery_id'] = intval(Core_Array::getGet('shop_delivery_id', 7));
$shop_payment_system_id = $_SESSION['hostcmsOrder']['shop_payment_system_id'] = 27;
Shop_Payment_System_Handler::factory(
Core_Entity::factory('Shop_Payment_System', $shop_payment_system_id)
)
->orderParams($_SESSION['hostcmsOrder'])
->execute();
echo json_encode(ob_get_clean());
exit();
}
Или здесь
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE xsl:stylesheet>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:exsl="http://exslt.org/common"
extension-element-prefixes="exsl">
<xsl:output method="xml"
doctype-public="XSLT-compat"
doctype-system="http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"
omit-xml-declaration="yes"
encoding="UTF-8"
indent="yes"/>
<xsl
ecimal-format name="my" decimal-separator="," grouping-separator=" "/>
<xsl:template match="/shop">
<h4 class="h2">Оформление заказа</h4>
<xsl:choose>
<xsl:when test="count(shop_cart) = 0">
<p>Для оформления заказа нужно сначала добавить товары.</p>
</xsl:when>
<xsl:otherwise>
<div id="makeCheckOut">
<form action="/" class="validate" method="post">
<div class="row">
<div class="col-sm-8">
<div class="padTable">
<table class="table table-responsive">
<xsl:call-template name="tableHeader"/>
<xsl:choose>
<xsl:when test="count(shop_purchase_discount) > 0">
<tbody>
<xsl:apply-templates select="shop_cart[postpone = 0]"/>
<xsl:apply-templates select="shop_purchase_discount"/>
</tbody>
<tfoot>
<tr>
<th></th>
<th class="text-right">Итого:</th>
<th></th>
<th class="text-right">
<xsl:value-of select="format-number(total_amount, '### ##0', 'my'
"/><xsl:text> </xsl:text><span class="rub">Р</span>
</th>
<th></th>
</tr>
</tfoot>
</xsl:when>
<xsl:otherwise>
<tbody>
<xsl:apply-templates select="shop_cart[postpone = 0]"/>
</tbody>
<xsl:call-template name="tableFooter">
<xsl:with-param name="nodes" select="shop_cart[postpone = 0]"/>
</xsl:call-template>
</xsl:otherwise>
</xsl:choose>
</table>
</div>
<div class="row">
<div class="col-sm-6">
<div class="form-group">
<xsl:choose>
<xsl:when test="//coupon_value_from != ''">
<input type="text" class="form-control input-sm" name="coupon_text" placeholder="Промо-код" value="{//coupon_value_from}"/>
</xsl:when>
<xsl:otherwise>
<input type="text" class="form-control input-sm" name="coupon_text" placeholder="Промо-код" value="{coupon_text}"/>
</xsl:otherwise>
</xsl:choose>
</div>
</div>
<div class="col-sm-2 text-right">
<input type="button" name="recount" class="btn btn-sm footerBtn" onclick="return $.recountCart('/', '#makeCheckOutFull', ''
" value="Пересчитать"/>
</div>
</div>
</div>
<div class="col-sm-4">
<div class="checkOut stickyeah" data-stickyeah-offset="96" data-stickyeah-push="sub" data-stickyeah-class="open">
<div class="cnt">
<div>Общая стоимость</div>
<div class="total">
<strong><xsl:value-of select="format-number(total_amount, '### ##0', 'my'
"/><xsl:text> </xsl:text><span class="rub">Р</span></strong>
</div>
<div class="checkOutBtn">
<div class="control-group form-group">
<label class="control-label">Ваш e-mail:</label>
<div class="controls">
<input type="text" size="30" name="email" placeholder="Ваш email" class="form-control" required="required" data-bv-message="Обязательно укажите email"/>
<div class="help-block"></div>
</div>
</div>
<div class="control-group form-group">
<label class="control-label">Ваше имя:</label>
<div class="controls">
<input type="text" size="30" name="name" placeholder="Ваше имя" class="form-control" required="required" data-bv-message="Укажите как к Вам обращаться"/>
<div class="help-block"></div>
</div>
</div>
<div class="control-group form-group">
<label class="control-label">Телефон</label>
<div class="controls">
<div class="input-group input-group-sm">
<span class="input-group-addon">+7</span>
<input type="text" size="30" class="form-control" placeholder="9124785527" name="phone" required="required" data-bv-message="Обязательно укажите телефон" data-bv-between="true" data-bv-between-inclusive="true" data-bv-between-message=" " data-bv-between-min="1000000000" data-bv-between-max="9999999999" maxlength="10" pattern="^[0-9]+$" aria-invalid="false" />
</div>
<div class="help-block"></div>
</div>
</div>
<div class="control-group form-group">
<label class="control-label">Адрес доставки:</label>
<div class="controls">
<textarea name="address" placeholder="Адрес доставки" class="form-control input-sm" rows="4" required="required" data-bv-message="Обязательно укажите адрес доставки"></textarea>
<div class="row">
<div class="caption">Страна:</div>
<div class="field">
<select id="shop_country_id" name="shop_country_id" onchange="$.loadLocations('{/shop/url}cart/', $(this).val())">
<option value="0">…</option>
<xsl:apply-templates select="shop_country" />
</select>
<span class="redSup"> *</span>
</div>
</div>
<div class="row">
<div class="caption">Область:</div>
<div class="field">
<select name="shop_country_location_id" id="shop_country_location_id" onchange="$.loadCities('{/shop/url}cart/', $(this).val())">
<option value="0">…</option>
<xsl:apply-templates select="shop_country_location" />
</select>
<span class="redSup"> *</span>
</div>
</div>
<div class="row">
<div class="caption">Город:</div>
<div class="field">
<select name="shop_country_location_city_id" id="shop_country_location_city_id" onchange="$.loadCityAreas('{/shop/url}cart/', $(this).val())">
<option value="0">…</option>
<xsl:apply-templates select="shop_country_location_city" />
</select>
</div>
</div>
<div class="row">
<div class="caption">Район города:</div>
<div class="field">
<select name="shop_country_location_city_area_id" id="shop_country_location_city_area_id">
<option value="0">…</option>
</select>
</div>
</div>
<div class="help-block"></div>
</div>
</div>
<br/>
<input type="submit" name="checkout" class="btn btn-sm footerBtn" onclick="return $.checkOut('/', '#makeCheckOutFull'
" value="Оформить заказ"/>
<!--<button type="submit" class="btn btn-sm footerBtn" onclick="return $.checkOut('/', '#makeCheckOutFull'
">
<strong>Оформить заказ</strong>
</button>-->
</div>
</div>
</div>
</div>
</div>
</form>
<xsl:if test="not(/shop/current_shop_country_location_id/node())">
<SCRIPT type="text/javascript">
$(function() {
$.loadLocations('<xsl:value-of select="/shop/url" />cart/', $('#shop_country_id'
.val());
});
</SCRIPT>
</xsl:if>
<!-- add если область выбрана, то загружаем города -->
<xsl:if test="(/shop/current_shop_country_location_id/node())">
<SCRIPT type="text/javascript">
$(function() {
$.loadCities('<xsl:value-of select="/shop/url" />cart/', $('#shop_country_location_id'
.val());
});
</SCRIPT>
</xsl:if>
</div>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
<xsl:template name="tableHeader">
<thead>
<tr>
<th class="col-sm-6">Название</th>
<th class="text-right">Цена</th>
<th class="col-sm-1">Кол-во</th>
<th class="text-right">Сумма</th>
<th></th>
</tr>
</thead>
</xsl:template>
<xsl:template name="tableFooter">
<xsl:param name="nodes"/>
<xsl:variable name="subTotals">
<xsl:for-each select="$nodes">
<sum><xsl:value-of select="shop_item/price * quantity"/></sum>
</xsl:for-each>
</xsl:variable>
<tfoot>
<tr>
<th></th>
<th class="text-right">Итого:</th>
<th></th>
<th class="text-right nobr">
<xsl:choose>
<xsl:when test="sum(exsl:node-set($subTotals)/sum) = 0">
<strong>Бесплатно</strong>
</xsl:when>
<xsl:otherwise>
<strong><xsl:value-of select="format-number(sum(exsl:node-set($subTotals)/sum), '### ##0', 'my'
"/><xsl:text> </xsl:text><span class="rub">Р</span></strong>
</xsl:otherwise>
</xsl:choose>
</th>
<th></th>
</tr>
</tfoot>
</xsl:template>
<xsl:template name="resultPrice">
<xsl:param name="nodes"/>
<xsl:variable name="subTotals">
<xsl:for-each select="$nodes">
<sum><xsl:value-of select="shop_item/price * quantity"/></sum>
</xsl:for-each>
</xsl:variable>
<xsl:value-of select="sum(exsl:node-set($subTotals)/sum)"/>
</xsl:template>
<xsl:template match="shop_purchase_discount">
<tr>
<td class="col-sm-6">
<strong><xsl:value-of disable-output-escaping="yes" select="name"/></strong>
</td>
<td class="text-right"></td>
<td class="col-sm-1"></td>
<td class="text-right nobr">
<strong><xsl:value-of disable-output-escaping="yes" select="format-number(discount_amount * -1, '### ##0', 'my'
"/> <span class="rub">Р</span></strong>
</td>
<td class="text-center"></td>
</tr>
</xsl:template>
<xsl:template match="shop_cart">
<xsl:variable name="gId" select="shop_item/shop_group_id"/>
<tr>
<td class="col-sm-6">
<xsl:value-of disable-output-escaping="yes" select="shop_item/name"/>
<xsl:if test="shop_item/marking != ''">
<div class="small text-muted">
<xsl:value-of disable-output-escaping="yes" select="shop_item/marking"/>
</div>
</xsl:if>
</td>
<td class="text-right">
<xsl:choose>
<xsl:when test="shop_item/price = 0">
Бесплатно
</xsl:when>
<xsl:otherwise>
<xsl:value-of disable-output-escaping="yes" select="format-number(shop_item/price, '### ##0', 'my'
"/> <span class="rub">Р</span>
</xsl:otherwise>
</xsl:choose>
</td>
<td class="col-sm-1">
<div class="form-group">
<input type="text" size="3" class="form-control input-sm valI" name="quantity_{shop_item/@id}" id="quantity_{shop_item/@id}" value="{format-number(quantity, '### ##0', 'my'
}"/>
</div>
</td>
<td class="text-right nobr">
<xsl:variable name="summ" select="shop_item/price * quantity"/>
<xsl:choose>
<xsl:when test="$summ = 0">
<strong>Бесплатно</strong>
</xsl:when>
<xsl:otherwise>
<strong><xsl:value-of disable-output-escaping="yes" select="format-number($summ, '### ##0', 'my'
"/> <span class="rub">Р</span></strong>
</xsl:otherwise>
</xsl:choose>
</td>
<td class="text-center">
<a href="?delete={shop_item/@id}" class="del" onclick="return $.removeFromCart('/', {shop_item/@id}, '#makeCheckOutFull', ''
" title="Удалить товар из корзины"><i class="fa fa-close"></i></a>
</td>
</tr>
</xsl:template>
<xsl:template match="shop_country">
<option value="{@id}">
<xsl:if test="/shop/current_shop_country_location_id=@id" >
<xsl:attribute name="selected">selected</xsl:attribute>
</xsl:if>
<xsl:value-of select="name" />
</option>
</xsl:template>
<xsl:template match="shop_country_location">
<option value="{@id}">
<xsl:if test="/shop/current_shop_country_location_id = @id">
<xsl:attribute name="selected">selected</xsl:attribute>
</xsl:if>
<xsl:value-of select="name" />
</option>
</xsl:template>
<xsl:template match="shop_country_location_city">
<option value="{@id}">
<xsl:if test="/shop/current_shop_country_location_city_id = @id">
<xsl:attribute name="selected">selected</xsl:attribute>
</xsl:if>
<xsl:value-of select="name" />
</option>
</xsl:template>
</xsl:stylesheet>
Здесь:
<?php
Core_Session::start();
$oShop = Core_Entity::factory('Shop', Core_Array::get(Core_Page::instance()->libParams, 'shopId'
);$ShopControllerShow = new Shop_Controller_Show($oShop);
$ShopControllerShow
->limit(99999)
->parseUrl();
Core_Page::instance()->object = $ShopControllerShow;
//прячем страницы товара
if ($ShopControllerShow->item){
$ShopControllerShow->error404();
}
// Добавление товара в корзину
if (Core_Array::getRequest('add'
){$shopItemId = intval(Core_Array::getRequest('add'
);if ($shopItemId){
$oShopCartController = Shop_Cart_Controller::instance();
$oShopCartController
->checkStock(FALSE)
->shop_item_id($shopItemId)
->quantity(Core_Array::getRequest('count', 1))
->add();
}
$coupon = trim(strval(Core_Array::getRequest('coupon_text'
));// Ajax
if (Core_Array::getRequest('_', FALSE)){
ob_start();
// Краткая корзина
$curXsl = Core_Array::getRequest('xsl', false) ? Core_Array::getRequest('xsl'
: Core_Array::get(Core_Page::instance()->libParams, 'littleCartXsl'
;$ShopCartControllerShow = new Shop_Cart_Controller_Show($oShop);
$ShopCartControllerShow
->xsl(
Core_Entity::factory('Xsl'
->getByName(strval($curXsl)))
->couponText($coupon)
->show();
echo json_encode(ob_get_clean());
exit();
}
}
// Удаляение товара из корзины
if (Core_Array::getGet('delete'
){$shopItemId = intval(Core_Array::getGet('delete'
);if ($shopItemId){
$ShopCartControllerShow = Shop_Cart_Controller::instance();
$ShopCartControllerShow
->shop_item_id($shopItemId)
->delete();
}
$coupon = trim(strval(Core_Array::getRequest('coupon_text'
));// Ajax
if (Core_Array::getRequest('_', FALSE)){
ob_start();
// Краткая корзина
$curXsl = Core_Array::getRequest('xsl', false) ? Core_Array::getRequest('xsl'
: Core_Array::get(Core_Page::instance()->libParams, 'fullCartXsl'
;$ShopCartControllerShow = new Shop_Cart_Controller_Show($oShop);
$ShopCartControllerShow
->xsl(
Core_Entity::factory('Xsl'
->getByName(strval($curXsl)))
->couponText($coupon)
->show();
echo json_encode(ob_get_clean());
exit();
}
}
// Пересчёт
if (Core_Array::getGet('recount'
){$ShopCartControllerShow = Shop_Cart_Controller::instance();
$aCart = $ShopCartControllerShow->getAll($oShop);
foreach ($aCart as $oShopCart){
$ShopCartControllerShow
->checkStock(FALSE)
->shop_item_id($oShopCart->shop_item_id)
->quantity(Core_Array::getGet('quantity_' . $oShopCart->shop_item_id))
->update();
}
// Запоминаем купон
$coupon = trim(strval(Core_Array::getRequest('coupon_text'
));//$_SESSION['hostcmsOrder']['coupon_text'] = trim(strval(Core_Array::getGet('coupon_text'
));// Ajax
if (Core_Array::getRequest('_', FALSE)){
//var_dump($_SESSION['hostcmsOrder']['coupon_text']);
//var_dump(Core_Array::get($_SESSION, 'coupon_text'
);ob_start();
$curXsl = Core_Array::getRequest('xsl', false) ? Core_Array::getRequest('xsl'
: Core_Array::get(Core_Page::instance()->libParams, 'fullCartXsl'
;$ShopCartControllerShow = new Shop_Cart_Controller_Show($oShop);
$ShopCartControllerShow
->xsl(
Core_Entity::factory('Xsl'
->getByName(strval($curXsl)))
->couponText($coupon)
->show();
echo json_encode(ob_get_clean());
exit();
}
}
if (!is_null(Core_Array::getGet('ajaxLoad'
)){
$aObjects = array();
if (Core_Array::getGet('shop_country_id'
){
$oShop_Country_Location = Core_Entity::factory('Shop_Country_Location'
;$oShop_Country_Location
->queryBuilder()
->where('shop_country_id', '=', intval(Core_Array::getGet('shop_country_id'
));$aObjects = $oShop_Country_Location->getAllByActive(1);
}
elseif (Core_Array::getGet('shop_country_location_id'
){
$oShop_Country_Location_City = Core_Entity::factory('Shop_Country_Location_City'
;$oShop_Country_Location_City
->queryBuilder()
->where('shop_country_location_id', '=', intval(Core_Array::getGet('shop_country_location_id'
));$aObjects = $oShop_Country_Location_City->getAllByActive(1);
}
elseif (Core_Array::getGet('shop_country_location_city_id'
){
$oShop_Country_Location_City_Area = Core_Entity::factory('Shop_Country_Location_City_Area'
;$oShop_Country_Location_City_Area
->queryBuilder()
->where('shop_country_location_city_id', '=', intval(Core_Array::getGet('shop_country_location_city_id'
));$aObjects = $oShop_Country_Location_City_Area->getAllByActive(1);
}
$aArray = array('…'
;foreach ($aObjects as $Object)
{
//$aArray['_' . $Object->id] = $Object->name;
$aArray['_' . $Object->id] = $Object->getName();
}
Core::showJson($aArray);
}
if (Core_Array::getPost('recount'
){$ShopCartControllerShow = Shop_Cart_Controller::instance();
$aCart = $ShopCartControllerShow->getAll($oShop);
foreach ($aCart as $oShopCart){
$ShopCartControllerShow
->checkStock(FALSE)
->shop_item_id($oShopCart->shop_item_id)
->quantity(Core_Array::getPost('quantity_' . $oShopCart->shop_item_id))
->update();
}
// Запоминаем купон
//$_SESSION['hostcmsOrder']['coupon_text'] = trim(strval(Core_Array::getPost('coupon_text'
));$coupon = trim(strval(Core_Array::getRequest('coupon_text'
));//$_SESSION['hostcmsOrder']['coupon_text'] = trim(strval(Core_Array::getGet('coupon_text'
));// Ajax
if (Core_Array::getRequest('_', FALSE)){
//var_dump($_SESSION['hostcmsOrder']['coupon_text']);
//var_dump(Core_Array::get($_SESSION, 'coupon_text'
);ob_start();
$curXsl = Core_Array::getRequest('xsl', false) ? Core_Array::getRequest('xsl'
: Core_Array::get(Core_Page::instance()->libParams, 'fullCartXsl'
;$ShopCartControllerShow = new Shop_Cart_Controller_Show($oShop);
$ShopCartControllerShow
->xsl(
Core_Entity::factory('Xsl'
->getByName(strval($curXsl)))
->couponText($coupon)
->show();
echo json_encode(ob_get_clean());
exit();
}
}
// Обновление
if(Core_Array::getGet('refresh'
){// Ajax
ob_start();
$curXsl = Core_Array::getRequest('xsl', false) ? Core_Array::getRequest('xsl'
: Core_Array::get(Core_Page::instance()->libParams, 'fullCartXsl'
;$coupon = trim(strval(Core_Array::getRequest('coupon_text'
));$ShopCartControllerShow = new Shop_Cart_Controller_Show($oShop);
$ShopCartControllerShow
->xsl(
Core_Entity::factory('Xsl'
->getByName(strval($curXsl)))
->couponText($coupon)
->show();
echo json_encode(ob_get_clean());
exit();
}
// Оформление заказа
if (Core_Array::getGet('checkout'
){// Ajax
$_SESSION['last_order_id'] = 0;
ob_start();
$ShopCartController = Shop_Cart_Controller::instance();
$aCart = $ShopCartController->getAll($oShop);
// TODO: Сделать правильное оформление заказа
// Должны обрабатываться поля: surname, name, patronymic, email, phone, address (см. оригинал оформления)
//
// TODO: !!!!!!!! Форма не должна отправлятся с перезагрузкой страницы
$userPhone = '7'.strval(Core_Array::getGet('phone'
);$_SESSION['hostcmsOrder']['orderAdminNotificationXsl'] = Core_Array::get(Core_Page::instance()->libParams, 'orderAdminNotificationXsl'
;$_SESSION['hostcmsOrder']['orderUserNotificationXsl'] = Core_Array::get(Core_Page::instance()->libParams, 'orderUserNotificationXsl'
;$_SESSION['hostcmsOrder']['checkoutXsl'] = Core_Array::get(Core_Page::instance()->libParams, 'checkoutXsl'
;$_SESSION['hostcmsOrder']['shop_country_id'] = intval(Core_Array::getGet('shop_country_id', 175));
$_SESSION['hostcmsOrder']['shop_country_location_id'] = intval(Core_Array::getGet('shop_country_location_id', 13));
$_SESSION['hostcmsOrder']['shop_country_location_city_id'] = intval(Core_Array::getGet('shop_country_location_city_id', 532));
// $_SESSION['hostcmsOrder']['shop_country_location_city_area_id'] = intval(Core_Array::getGet('shop_country_location_city_area_id', 0));
$_SESSION['hostcmsOrder']['surname'] = strval(Core_Array::getGet('surname'
);$_SESSION['hostcmsOrder']['name'] = strval(Core_Array::getGet('name'
);$_SESSION['hostcmsOrder']['patronymic'] = strval(Core_Array::getGet('patronymic'
);$_SESSION['hostcmsOrder']['email'] = strval(Core_Array::getGet('email'
);$_SESSION['hostcmsOrder']['address'] = strval(Core_Array::getGet('address'
);$_SESSION['hostcmsOrder']['phone'] = $userPhone;
$_SESSION['hostcmsOrder']['shop_delivery_condition_id'] = intval(Core_Array::getGet('shop_delivery_condition_id', 0));
$_SESSION['hostcmsOrder']['shop_delivery_id'] = intval(Core_Array::getGet('shop_delivery_id', 7));
$shop_payment_system_id = $_SESSION['hostcmsOrder']['shop_payment_system_id'] = 27;
Shop_Payment_System_Handler::factory(
Core_Entity::factory('Shop_Payment_System', $shop_payment_system_id)
)
->orderParams($_SESSION['hostcmsOrder'])
->execute();
echo json_encode(ob_get_clean());
exit();
}
Или здесь
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE xsl:stylesheet>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:exsl="http://exslt.org/common"
extension-element-prefixes="exsl">
<xsl:output method="xml"
doctype-public="XSLT-compat"
doctype-system="http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"
omit-xml-declaration="yes"
encoding="UTF-8"
indent="yes"/>
<xsl
ecimal-format name="my" decimal-separator="," grouping-separator=" "/><xsl:template match="/shop">
<h4 class="h2">Оформление заказа</h4>
<xsl:choose>
<xsl:when test="count(shop_cart) = 0">
<p>Для оформления заказа нужно сначала добавить товары.</p>
</xsl:when>
<xsl:otherwise>
<div id="makeCheckOut">
<form action="/" class="validate" method="post">
<div class="row">
<div class="col-sm-8">
<div class="padTable">
<table class="table table-responsive">
<xsl:call-template name="tableHeader"/>
<xsl:choose>
<xsl:when test="count(shop_purchase_discount) > 0">
<tbody>
<xsl:apply-templates select="shop_cart[postpone = 0]"/>
<xsl:apply-templates select="shop_purchase_discount"/>
</tbody>
<tfoot>
<tr>
<th></th>
<th class="text-right">Итого:</th>
<th></th>
<th class="text-right">
<xsl:value-of select="format-number(total_amount, '### ##0', 'my'
"/><xsl:text> </xsl:text><span class="rub">Р</span></th>
<th></th>
</tr>
</tfoot>
</xsl:when>
<xsl:otherwise>
<tbody>
<xsl:apply-templates select="shop_cart[postpone = 0]"/>
</tbody>
<xsl:call-template name="tableFooter">
<xsl:with-param name="nodes" select="shop_cart[postpone = 0]"/>
</xsl:call-template>
</xsl:otherwise>
</xsl:choose>
</table>
</div>
<div class="row">
<div class="col-sm-6">
<div class="form-group">
<xsl:choose>
<xsl:when test="//coupon_value_from != ''">
<input type="text" class="form-control input-sm" name="coupon_text" placeholder="Промо-код" value="{//coupon_value_from}"/>
</xsl:when>
<xsl:otherwise>
<input type="text" class="form-control input-sm" name="coupon_text" placeholder="Промо-код" value="{coupon_text}"/>
</xsl:otherwise>
</xsl:choose>
</div>
</div>
<div class="col-sm-2 text-right">
<input type="button" name="recount" class="btn btn-sm footerBtn" onclick="return $.recountCart('/', '#makeCheckOutFull', ''
" value="Пересчитать"/></div>
</div>
</div>
<div class="col-sm-4">
<div class="checkOut stickyeah" data-stickyeah-offset="96" data-stickyeah-push="sub" data-stickyeah-class="open">
<div class="cnt">
<div>Общая стоимость</div>
<div class="total">
<strong><xsl:value-of select="format-number(total_amount, '### ##0', 'my'
"/><xsl:text> </xsl:text><span class="rub">Р</span></strong></div>
<div class="checkOutBtn">
<div class="control-group form-group">
<label class="control-label">Ваш e-mail:</label>
<div class="controls">
<input type="text" size="30" name="email" placeholder="Ваш email" class="form-control" required="required" data-bv-message="Обязательно укажите email"/>
<div class="help-block"></div>
</div>
</div>
<div class="control-group form-group">
<label class="control-label">Ваше имя:</label>
<div class="controls">
<input type="text" size="30" name="name" placeholder="Ваше имя" class="form-control" required="required" data-bv-message="Укажите как к Вам обращаться"/>
<div class="help-block"></div>
</div>
</div>
<div class="control-group form-group">
<label class="control-label">Телефон</label>
<div class="controls">
<div class="input-group input-group-sm">
<span class="input-group-addon">+7</span>
<input type="text" size="30" class="form-control" placeholder="9124785527" name="phone" required="required" data-bv-message="Обязательно укажите телефон" data-bv-between="true" data-bv-between-inclusive="true" data-bv-between-message=" " data-bv-between-min="1000000000" data-bv-between-max="9999999999" maxlength="10" pattern="^[0-9]+$" aria-invalid="false" />
</div>
<div class="help-block"></div>
</div>
</div>
<div class="control-group form-group">
<label class="control-label">Адрес доставки:</label>
<div class="controls">
<textarea name="address" placeholder="Адрес доставки" class="form-control input-sm" rows="4" required="required" data-bv-message="Обязательно укажите адрес доставки"></textarea>
<div class="row">
<div class="caption">Страна:</div>
<div class="field">
<select id="shop_country_id" name="shop_country_id" onchange="$.loadLocations('{/shop/url}cart/', $(this).val())">
<option value="0">…</option>
<xsl:apply-templates select="shop_country" />
</select>
<span class="redSup"> *</span>
</div>
</div>
<div class="row">
<div class="caption">Область:</div>
<div class="field">
<select name="shop_country_location_id" id="shop_country_location_id" onchange="$.loadCities('{/shop/url}cart/', $(this).val())">
<option value="0">…</option>
<xsl:apply-templates select="shop_country_location" />
</select>
<span class="redSup"> *</span>
</div>
</div>
<div class="row">
<div class="caption">Город:</div>
<div class="field">
<select name="shop_country_location_city_id" id="shop_country_location_city_id" onchange="$.loadCityAreas('{/shop/url}cart/', $(this).val())">
<option value="0">…</option>
<xsl:apply-templates select="shop_country_location_city" />
</select>
</div>
</div>
<div class="row">
<div class="caption">Район города:</div>
<div class="field">
<select name="shop_country_location_city_area_id" id="shop_country_location_city_area_id">
<option value="0">…</option>
</select>
</div>
</div>
<div class="help-block"></div>
</div>
</div>
<br/>
<input type="submit" name="checkout" class="btn btn-sm footerBtn" onclick="return $.checkOut('/', '#makeCheckOutFull'
" value="Оформить заказ"/><!--<button type="submit" class="btn btn-sm footerBtn" onclick="return $.checkOut('/', '#makeCheckOutFull'
"><strong>Оформить заказ</strong>
</button>-->
</div>
</div>
</div>
</div>
</div>
</form>
<xsl:if test="not(/shop/current_shop_country_location_id/node())">
<SCRIPT type="text/javascript">
$(function() {
$.loadLocations('<xsl:value-of select="/shop/url" />cart/', $('#shop_country_id'
.val());});
</SCRIPT>
</xsl:if>
<!-- add если область выбрана, то загружаем города -->
<xsl:if test="(/shop/current_shop_country_location_id/node())">
<SCRIPT type="text/javascript">
$(function() {
$.loadCities('<xsl:value-of select="/shop/url" />cart/', $('#shop_country_location_id'
.val());});
</SCRIPT>
</xsl:if>
</div>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
<xsl:template name="tableHeader">
<thead>
<tr>
<th class="col-sm-6">Название</th>
<th class="text-right">Цена</th>
<th class="col-sm-1">Кол-во</th>
<th class="text-right">Сумма</th>
<th></th>
</tr>
</thead>
</xsl:template>
<xsl:template name="tableFooter">
<xsl:param name="nodes"/>
<xsl:variable name="subTotals">
<xsl:for-each select="$nodes">
<sum><xsl:value-of select="shop_item/price * quantity"/></sum>
</xsl:for-each>
</xsl:variable>
<tfoot>
<tr>
<th></th>
<th class="text-right">Итого:</th>
<th></th>
<th class="text-right nobr">
<xsl:choose>
<xsl:when test="sum(exsl:node-set($subTotals)/sum) = 0">
<strong>Бесплатно</strong>
</xsl:when>
<xsl:otherwise>
<strong><xsl:value-of select="format-number(sum(exsl:node-set($subTotals)/sum), '### ##0', 'my'
"/><xsl:text> </xsl:text><span class="rub">Р</span></strong></xsl:otherwise>
</xsl:choose>
</th>
<th></th>
</tr>
</tfoot>
</xsl:template>
<xsl:template name="resultPrice">
<xsl:param name="nodes"/>
<xsl:variable name="subTotals">
<xsl:for-each select="$nodes">
<sum><xsl:value-of select="shop_item/price * quantity"/></sum>
</xsl:for-each>
</xsl:variable>
<xsl:value-of select="sum(exsl:node-set($subTotals)/sum)"/>
</xsl:template>
<xsl:template match="shop_purchase_discount">
<tr>
<td class="col-sm-6">
<strong><xsl:value-of disable-output-escaping="yes" select="name"/></strong>
</td>
<td class="text-right"></td>
<td class="col-sm-1"></td>
<td class="text-right nobr">
<strong><xsl:value-of disable-output-escaping="yes" select="format-number(discount_amount * -1, '### ##0', 'my'
"/> <span class="rub">Р</span></strong></td>
<td class="text-center"></td>
</tr>
</xsl:template>
<xsl:template match="shop_cart">
<xsl:variable name="gId" select="shop_item/shop_group_id"/>
<tr>
<td class="col-sm-6">
<xsl:value-of disable-output-escaping="yes" select="shop_item/name"/>
<xsl:if test="shop_item/marking != ''">
<div class="small text-muted">
<xsl:value-of disable-output-escaping="yes" select="shop_item/marking"/>
</div>
</xsl:if>
</td>
<td class="text-right">
<xsl:choose>
<xsl:when test="shop_item/price = 0">
Бесплатно
</xsl:when>
<xsl:otherwise>
<xsl:value-of disable-output-escaping="yes" select="format-number(shop_item/price, '### ##0', 'my'
"/> <span class="rub">Р</span></xsl:otherwise>
</xsl:choose>
</td>
<td class="col-sm-1">
<div class="form-group">
<input type="text" size="3" class="form-control input-sm valI" name="quantity_{shop_item/@id}" id="quantity_{shop_item/@id}" value="{format-number(quantity, '### ##0', 'my'
}"/></div>
</td>
<td class="text-right nobr">
<xsl:variable name="summ" select="shop_item/price * quantity"/>
<xsl:choose>
<xsl:when test="$summ = 0">
<strong>Бесплатно</strong>
</xsl:when>
<xsl:otherwise>
<strong><xsl:value-of disable-output-escaping="yes" select="format-number($summ, '### ##0', 'my'
"/> <span class="rub">Р</span></strong></xsl:otherwise>
</xsl:choose>
</td>
<td class="text-center">
<a href="?delete={shop_item/@id}" class="del" onclick="return $.removeFromCart('/', {shop_item/@id}, '#makeCheckOutFull', ''
" title="Удалить товар из корзины"><i class="fa fa-close"></i></a></td>
</tr>
</xsl:template>
<xsl:template match="shop_country">
<option value="{@id}">
<xsl:if test="/shop/current_shop_country_location_id=@id" >
<xsl:attribute name="selected">selected</xsl:attribute>
</xsl:if>
<xsl:value-of select="name" />
</option>
</xsl:template>
<xsl:template match="shop_country_location">
<option value="{@id}">
<xsl:if test="/shop/current_shop_country_location_id = @id">
<xsl:attribute name="selected">selected</xsl:attribute>
</xsl:if>
<xsl:value-of select="name" />
</option>
</xsl:template>
<xsl:template match="shop_country_location_city">
<option value="{@id}">
<xsl:if test="/shop/current_shop_country_location_city_id = @id">
<xsl:attribute name="selected">selected</xsl:attribute>
</xsl:if>
<xsl:value-of select="name" />
</option>
</xsl:template>
</xsl:stylesheet>
В рамках форума в данном вопросе проблематично помочь. Рекомендуем обратиться в поддержку
«Не выходи из комнаты, не совершай ошибку…»
подскажите, как получить список стран?
в описании сказано что список стран генерируется и выводится xsl , остальное уже обрабатывается скриптом
если указать в коде <select class="form-control" id="shop_country_id" name="shop_country_id" onload="$.loadLocations('/', $(this).val())">
<option value="175">…</option>
<xsl:apply-templates select="/shop_country" />
</select>
то селектор области заполняется, при выборе области также заполняется селектор города, но видимо что-то идет не так, потому что крутится ajaxLoader. запрос обрабатывается ?ajaxLoad&shop_country_location_id=13, но нажать ничего нельзя.
в описании сказано что список стран генерируется и выводится xsl , остальное уже обрабатывается скриптом
если указать в коде <select class="form-control" id="shop_country_id" name="shop_country_id" onload="$.loadLocations('/', $(this).val())">
<option value="175">…</option>
<xsl:apply-templates select="/shop_country" />
</select>
то селектор области заполняется, при выборе области также заполняется селектор города, но видимо что-то идет не так, потому что крутится ajaxLoader. запрос обрабатывается ?ajaxLoad&shop_country_location_id=13, но нажать ничего нельзя.
axyal писал(а):
Получить список стран можно так:
axyal писал(а):
Если не попадает в XML тег данные shop_country то их надо добавить через addEntity
axyal писал(а):
Все верно потому что не поступили данные в XML для обработки.
llirik, вас попросил обратиться в поддержку.
Либо опубликовать задачу и довериться специалистам.
подскажите, как получить список стран?
Получить список стран можно так:
$oCountry = Core_Entity::factory('Shop_Country');
$oCountry->queryBuilder()
->orderBy('sorting')
->orderBy('name');
$aCountries = $oCountry->findAll();
$oCountry->queryBuilder()
->orderBy('sorting')
->orderBy('name');
$aCountries = $oCountry->findAll();
axyal писал(а):
в описании сказано что список стран генерируется и выводится xsl
Если не попадает в XML тег данные shop_country то их надо добавить через addEntity
axyal писал(а):
запрос обрабатывается ?ajaxLoad&shop_country_location_id=13, но нажать ничего нельзя.
Все верно потому что не поступили данные в XML для обработки.
llirik, вас попросил обратиться в поддержку.
Либо опубликовать задачу и довериться специалистам.
E-mail: info@syrbek.ru / телега: @syrbek /skype: activexm / syrbek.ru / Поддержка сайтов / г. Москва [HTML, CSS (Bootstrap), JS(JQuery, ExtJS), PHP, MySQL, MSSql, Posgres, Git, SVN, Redmine]
Авторизация