Skip to content

Instantly share code, notes, and snippets.

{var $key = $table ~ $delimeter ~ $filter}
<input type="hidden" name="{$filter}[]" value="" />
<label for="mse2_{$key}_{$idx}" class="checkbox-label {$disabled}">
<input type="checkbox" name="{$filter}[]" id="mse2_{$key}_{$idx}" value="{$value}" {$checked} {$disabled}
{('fi.' ~ $filter) | placeholder | FormItIsChecked : $value}>
<span class="checkmark"></span>
{$title}
</label>{*$num*}
@Sentinel-7
Sentinel-7 / getip.php
Created June 24, 2021 08:13
getIp определяем ip пользователя
/*
<input type="hidden" name="{$formID}_ip" value="{'!getIP' | snippet}" />
*/
<?php
if (!function_exists('getIp')) {
function getIp() {
$keys = [
'HTTP_CLIENT_IP',
'HTTP_X_FORWARDED_FOR',
'REMOTE_ADDR'
@Sentinel-7
Sentinel-7 / catalog.tpl
Last active August 6, 2021 07:31
Считаем кол-во выведенных товаров на странице - mFilter2
<div class="mt-textbox">
<p>Showing
<strong id="START">{$_modx->getPlaceholder('mse2_start_page')}</strong> –
<strong id="END">{$_modx->getPlaceholder('mf_limit')}</strong> of
<strong>{$_modx->getPlaceholder('mf_total')}</strong> results</p>
</div>
<script>
$(document).on('mse2_load', function(e, data) {
let page = data.data.page;
@Sentinel-7
Sentinel-7 / card.tpl
Created August 10, 2021 07:48
Click a + input radio checked
<script>
$(document).ready(function() {
miniShop2.Callbacks.add('Order.getcost.response.success', 'Order_submit_response_success', function(responce) {
var cost = responce.data['cost'],
min_price = {'price_config' | config};
if (cost < min_price) {
miniShop2.Callbacks.add('Order.submit.before', 'Order_submit_before', function() {
miniShop2.Message.error('Недостаточная сумма заказа, заказ отправляется от ' + min_price + ' {'ms2_frontend_currency' | lexicon}!');
$('#error_message').text('Недостаточная сумма заказа, заказ отправляется от ' + min_price + ' {'ms2_frontend_currency' | lexicon}!');
return false;
@Sentinel-7
Sentinel-7 / catalog.tpl
Last active August 19, 2021 09:44
достаем картинки для товаров, когда нужно вывести пару картинок для одной карточке в списке
{'!msProducts' | snippet : [
'parents'=>$_modx->resource.id,
'leftJoin' => '{ "images": { "class":"msProductFile","alias":"images", "on": "images.product_id = msProduct.id AND images.path LIKE \'%/small/\'" }}',
'select' => '{ "images":"GROUP_CONCAT(images.url SEPARATOR \';;\') as images"}',
'limit'=>0,
'sortby'=>'menuindex',
'sortdir'=>'ASC',
'showLog'=>0,
'tpl'=>'@FILE chunks/item/product.tpl'
]}
@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?}
@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 / order.js
Created August 25, 2021 11:40
Изменяем url после оформления заказа, для отслеживания конверсий
jQuery(window).on('load', function() {
"use strict";
history.pushState(null, '', '/?msorder');
});
@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 / 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,
));