Skip to content

Instantly share code, notes, and snippets.

@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) {
@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 / 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 / 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 / .htaccess
Created September 27, 2021 06:50
Если не работает dadata
на вашем хостинге нужно было создать файл .htaccess
с
RewriteCond %{HTTP:Authorization} !^$
RewriteRule ^(.*)$ $1?http_auth=%{HTTP:Authorization} [QSA]
@Sentinel-7
Sentinel-7 / class_key.php
Created September 23, 2021 11:02
Замена tickets на msProducts (замена тикетов на товары)
<?php
// Id корня, глубина, контекст
$child = $modx->getChildIds(11, 10, array('context' => 'web'));
$q = $modx->newQuery('Ticket');
$q->where(array(
'id:IN' => $child,
'published' => true,
'deleted' => false,
'searchable' => true,
));
@Sentinel-7
Sentinel-7 / msptinkoffCredit.class.php
Last active May 3, 2024 10:39
Тиньков рассрочка или кредит
<?php
// строка 32,38,39,40 создаем поля в системных и прописываем там идентификаторы
// ini_set('display_errors', 1);
// ini_set('error_reporting', -1);
require_once MODX_CORE_PATH . 'components/minishop2/model/minishop2/mspaymenthandler.class.php';
class TinkoffCredit extends msPaymentHandler implements msPaymentInterface{
public $demo;
@Sentinel-7
Sentinel-7 / order.js
Created August 25, 2021 11:40
Изменяем url после оформления заказа, для отслеживания конверсий
jQuery(window).on('load', function() {
"use strict";
history.pushState(null, '', '/?msorder');
});
@Sentinel-7
Sentinel-7 / getUrl.js
Created August 24, 2021 15:13
Добавляем url после отправки формы AjaxForm
$(document).on('af_complete', function (event, response) {
$('#getAQuoteModal').modal('hide');
if (response.success) {
$('#thanks').modal('show');
let form = $(response.form[0]);
form.attr('action', '-%thks');
let url = window.location.href;
@Sentinel-7
Sentinel-7 / productTabs.tpl
Last active August 23, 2021 09:54
Выводим по 2 товара minishop2 в слайдере
<div class="mt-product1 mt-paddingbottom20 ms2_product">
<form method="post" class="ms2_form">
<input type="hidden" name="id" value="{$id}">
<input type="hidden" name="count" value="1">
<input type="hidden" name="options" value="[]">
<div class="box">
<div class="b1">
<div class="b2">
<a href="{$id | url}">
{if $thumb?}