Skip to content

Instantly share code, notes, and snippets.

@Sentinel-7
Sentinel-7 / .htaccess
Created September 27, 2021 06:50
Если не работает dadata
на вашем хостинге нужно было создать файл .htaccess
с
RewriteCond %{HTTP:Authorization} !^$
RewriteRule ^(.*)$ $1?http_auth=%{HTTP:Authorization} [QSA]
@Sentinel-7
Sentinel-7 / msProduct.content.tpl
Last active February 2, 2023 14:53
Выводим опции с проверкой остатков msOptionsPrice2
{set $tmp = '!msOptionsPrice.modification'|snippet:[
'product' => $_modx->resource.id,
'tpl' => 'tpl.msOptionsPrice.modification',
'return' => 'data',
'processOptions' => 1,
'showZeroPrice' => 0
]}
{if $tmp?}
<div class="size-row">
{'!msOptionsPrice.option' | snippet : [
@Sentinel-7
Sentinel-7 / numCat.php
Created October 14, 2021 14:37
Считаем количество товаров в категории
<?php
if (empty($parent)) {$parent = $id;}
$pids = array_merge(array($parent), $modx->getChildIds($parent));
$ids = array();
$q = $modx->newQuery('msProduct');
$q->where(array('class_key' => 'msProduct','parent:IN' => $pids,'published' => 1,'deleted' => 0));
$q->select('`msProduct`.`id`');
if ($q->prepare() && $q->stmt->execute()) {
$ids = $q->stmt->fetchAll(PDO::FETCH_COLUMN);
@Sentinel-7
Sentinel-7 / round.php
Last active May 29, 2024 20:48
плагин на округление цены в ms2
<?php
switch($modx->event->name) {
case 'msOnGetProductPrice':
$returned_values = & $modx->event->returnedValues;
$values = $modx->event->params['data'];
$returned_values['price'] = ceil($values['price']/100)*100; // округляем в большу сторону
break;
@Sentinel-7
Sentinel-7 / OnSendMessageTelegram
Last active March 24, 2023 14:41
отправляем сообщение в телеграм из EasyComm
<?php
switch($modx->event->name){
// событие на OnEcMessageSave
case 'OnEcMessageSave':
if($object){
$data = $object->toArray();
$time = time();
$newMessage = 5;
$createdon = strtotime($object->get("createdon")) + $newMessage;
if ($createdon > $time) {