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
//плагин на событие msOnBeforeAddToCart. | |
$cartArray = $cart->get(); // Массив корзины | |
$cartStatus = $cart->status(); // Состояние корзины | |
$totalCount = $cartStatus['total_count']; // Общее количество товаров в корзине | |
foreach ($cartArray as &$cartProduct) { // Обрабатываем все товары корзины | |
if ($product = $modx->getObject('msProduct', $cartProduct['id'])) { // Получаем объект товара по его ID в корзине | |
$quanity = $product->get('count_prod)'; | |
$cartQuantity = $cartProduct["count"]; | |
if($cartQuantity > $quanity){ | |
$cartProduct['count'] = $quanity; |
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 | |
/** | |
Класс оплаты в кредит или рассрочку для Тинькофф | |
*/ | |
require_once MODX_CORE_PATH . 'components/minishop2/model/minishop2/mspaymenthandler.class.php'; | |
class Tinkoff extends msPaymentHandler implements msPaymentInterface{ | |
public $demo; |
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 | |
/** | |
на событие OnMODXInit | |
*/ | |
$rand = rand(1, 1000); | |
if ($rand === 1) { | |
$gcMaxlifetime = (integer) $modx->getOption('session_gc_maxlifetime', null, @ini_get('session.gc_maxlifetime'), true); | |
$access = time() - $gcMaxlifetime; | |
$modx->exec(" | |
DELETE FROM {$modx->getTableName('modSession')} WHERE `access` < {$access}; |
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
BreadcrumbList | |
Реализуем с помощью стандартного pdoCrumbs | |
{$_modx->runSnippet('pdoCrumbs',[ | |
'showHome'=> 1, | |
'showCurrent' => 1, | |
'from' => '0' | |
'tplWrapper'=> '@INLINE | |
<script type="application/ld+json"> |
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
{set $output = '!pdoResources' | snippet: [ | |
'parents' => '35|bb,39|bb' | |
'limit' => 0, | |
'includeTVs' => 'block_image', | |
'tvPrefix' => '', | |
'sortby' => '{ "menuindex":"ASC" }', | |
'where' => '{"parent:IN":[35|bb,39|bb]}', | |
'return' => 'json', | |
'select' => 'id,pagetitle,parent' | |
]} |
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
{set $par = $_modx->resource.parent | url} | |
{set $getTag = $_modx->resource.id | url | replace : $par : ''} | |
{set $parents = $_modx->resource.parent} | |
{*Находим шаблон родителя*} | |
{set $parentTemplate = $parents | resource: 'template'} | |
{*Если это тег, значит поднимаемся выше для получения родителя*} | |
{if $parentTemplate == 27} | |
{set $parents = $parents | resource: 'parent'} |
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
Список ресурсов сделан списком и выведен через процессор в msFieldsManager для свойств товара | |
'optionFilters' => '{ "collection:!=":"" }', | |
'where' => ['collection.value' => $_modx->resource.pagetitle], |
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 | |
$resources = $modx->getCollection('modResource', [ | |
'class_key' => 'msProduct' | |
]); | |
foreach ($resources as $res) { | |
$res->save(); | |
} |
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
{set $main = $_modx->resource.main | fromJSON} | |
<div data-youtube="{$main[0]['url']}"></div> | |
<script src="/assets/js/youtube-background.js"></script> | |
<script> | |
jQuery(document).ready(function() { | |
jQuery('[data-youtube]').youtube_background(); | |
}); | |
</script> |
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
{set $time = '' | date_format : "%s" - (24*60*60)} | |
{$time | date_format : "%b %d, %Y"} | |
или сниппет | |
<?php | |
$yesterday = date('F j, Y', time()-86400); | |
return $yesterday; |