Тодор

Тодор

Был в сети 29 июня 2026, 13:05
Заказы не принимаю
Ето ты сделал?
public function getReceiverId() {
  error_log("🔥🔥🔥 getCustomerId() НАЧАЛО 🔥🔥🔥");
  $customer = null;
  $response = $this->ms2->invokeEvent('msOnBeforeGetOrderCustomer', [//вместо $this->
    'order' => $this,//Вместо $this->order,
    'customer' => $customer,
  ]);
  if (!$response['success']) {
    return $response['message'];
  }

  if (!$customer) {
    $data = $this->get();//Вместо $this->order->get();
    
    ...
      $this->set($data);//Вмесо $this->order->set($data);
    ...
  }

  $response = $this->ms2->invokeEvent('msOnGetOrderCustomer', [//Вместо $this->
    'order' => $this, // Вместо $this->order,
    'customer' => $customer,
  ]);
  if (!$response['success']) {
    return $response['message'];
  }

  return $customer instanceof modUser ? $customer->get('id') : 0;
}
возможно что-то упустил
Етот кусок кода отвечает за то что бы менялась настройка ms2_services
<?php
if ($miniShop2 = $modx->getService('miniShop2')) {
  $miniShop2->addService('order', 'my_OrderHandler',
      '{core_path}components/minishop2/custom/order/my_msorderhandler.class.php');
}
После чего у тебя ms2_services должен быть таким
{"cart":[],"order":{"my_OrderHandler":"{core_path}components\/minishop2\/custom\/order\/my_msorderhandler.class.php"},"payment":[],"delivery":{"mydelivery":"{core_path}components\/minishop2\/custom\/delivery\/my_msdeliveryhandler.class.php"}}
Тебе надо делать только одно из двух либо регистировать клас через консоль либо в сис. настройках.

В зависимости от версии minishopа может быть разный путь к msOrderHandler, убедись что етот файл существует
require_once MODX_CORE_PATH . 'components/minishop2/handlers/msorderhandler.class.php';
А еще в submit ты поменял $user_id = $this->ms2->getCustomerId(); на $user_id = $this->getReceiverId(); Но новый метод ты не назвал getReceiverId
  • Расширяешь класс msOrderHandler (поключение)
  • Копируете из старого submit
  • Заменяешь там
    $user_id = $this->ms2->getCustomerId();
    на
    $user_id = $this->getReceiverId();
  • Добавляешь новый метод getReceiverId в новообразованный класс и меняешь его как хочешь
Создаеш плагин на событие OnPageNotFound
switch($modx->event->name){
    case 'OnPageNotFound':
        if("Твоя порверка на соответствие"){
            $_GET['ids'] = [12, 13, 14]; //Если нужно передать какие-то даные на страницу переадресации get или post
            $modx->sendForward("ID ресурса куда делать переадресацию");
        }else{
            //Оно само перенаправит на 404 
            //Или може направить куда сам захочешь
        }
        break;
}