Jump to content
Rubik

PHP Unknown: Object of class Session could not be converted to string

Recommended Posts

Добрый день. Подскажите пж куда копать

 

PHP Unknown:  Object of class Session could not be converted to string system/storage/modification/catalog/controller/checkout/success.php on line 21

Сверял файл success.php с оригинальным отличий нет.

 

Установлен модуль simple автор модуля пишет что ошибка в файле CMS https://prnt.sc/p5oe8z

20:   $this->model_account_activity->addActivity('order_account', $activity_data);
21:     } else {
22:   $activity_data = array(

 

Спойлер

<?php
class ControllerCheckoutSuccess extends Controller {
   public function index() {
      $this->load->language('checkout/success');

      if (isset($this->session->data['order_id'])) {
         $this->cart->clear();

         // Add to activity log
         if ($this->config->get('config_customer_activity')) {
            $this->load->model('account/activity');

            if ($this->customer->isLogged()) {
               $activity_data = array(
                  'customer_id' => $this->customer->getId(),
                  'name'        => $this->customer->getFirstName() . ' ' . $this->customer->getLastName(),
                  'order_id'    => $this->session->data['order_id']
               );

               $this->model_account_activity->addActivity('order_account', $activity_data);
            } else {
               $activity_data = array(
                  'name'     => $this->session->data['guest']['firstname'] . ' ' . $this->session->data['guest']['lastname'],
                  'order_id' => $this->session->data['order_id']
               );

               $this->model_account_activity->addActivity('order_guest', $activity_data);
            }
         }

         unset($this->session->data['shipping_method']);
         unset($this->session->data['shipping_methods']);
         unset($this->session->data['payment_method']);
         unset($this->session->data['payment_methods']);
         unset($this->session->data['guest']);
         unset($this->session->data['comment']);
         unset($this->session->data['order_id']);
         unset($this->session->data['coupon']);
         unset($this->session->data['reward']);
         unset($this->session->data['voucher']);
         unset($this->session->data['vouchers']);
         unset($this->session->data['totals']);
      }

      $this->document->setTitle($this->language->get('heading_title'));

      $data['breadcrumbs'] = array();

      $data['breadcrumbs'][] = array(
         'text' => $this->language->get('text_home'),
         'href' => $this->url->link('common/home')
      );

      $data['breadcrumbs'][] = array(
         'text' => $this->language->get('text_basket'),
         'href' => $this->url->link('checkout/cart')
      );

      $data['breadcrumbs'][] = array(
         'text' => $this->language->get('text_checkout'),
         'href' => $this->url->link('checkout/checkout', '', true)
      );

      $data['breadcrumbs'][] = array(
         'text' => $this->language->get('text_success'),
         'href' => $this->url->link('checkout/success')
      );

      $data['heading_title'] = $this->language->get('heading_title');

      if ($this->customer->isLogged()) {
         $data['text_message'] = sprintf($this->language->get('text_customer'), $this->url->link('account/account', '', true), $this->url->link('account/order', '', true), $this->url->link('account/download', '', true), $this->url->link('information/contact'));
      } else {
         $data['text_message'] = sprintf($this->language->get('text_guest'), $this->url->link('information/contact'));
      }

      $data['button_continue'] = $this->language->get('button_continue');

      $data['continue'] = $this->url->link('common/home');

      $data['column_left'] = $this->load->controller('common/column_left');
      $data['column_right'] = $this->load->controller('common/column_right');
      $data['content_top'] = $this->load->controller('common/content_top');
      $data['content_bottom'] = $this->load->controller('common/content_bottom');
      $data['footer'] = $this->load->controller('common/footer');
      $data['header'] = $this->load->controller('common/header');

      $this->response->setOutput($this->load->view('common/success', $data));
   }
}

 

Share this post


Link to post
Share on other sites

попробуйте в этом файле перед строкой с ошибкой добавить

var_dump($this->session->data['order_id']);

Share this post


Link to post
Share on other sites
5 минут назад, AlexDW сказал:

попробуйте в этом файле перед строкой с ошибкой добавить

var_dump($this->session->data['order_id']);

Добавил перед 21 строкой но ошибка осталась

Share this post


Link to post
Share on other sites

она и не должна пропасть

var_dump используется для отладки и показывает тип/содержимое

конкретно в вашем случае - чтобы понять, что за фигня и почему в $this->session->data['order_id'] у вас объект, а не строка

Share this post


Link to post
Share on other sites
11 минут назад, AlexDW сказал:

var_dump используется для отладки и показывает тип/содержимое

Где по смотреть содержимое?

Share this post


Link to post
Share on other sites

на странице, где видите текст ошибки - прямо перед ним должно быть

Share this post


Link to post
Share on other sites

Все дело в том что ошибка та же на странице и в админке других ошибок не где нет.

 

страница

Спойлер

 

Unknown: Object of class Session could not be converted to string in www/system/storage/modification/catalog/controller/checkout/success.php on line 21

 

журнал ошибок

Спойлер

PHP Unknown:  Object of class Session could not be converted to string in /www/system/storage/modification/catalog/controller/checkout/success.php on line 21
 

 

Share this post


Link to post
Share on other sites

Возможно не туда вставил код

 

Спойлер

$this->model_account_activity->addActivity('order_account', $activity_data);
вставил код                var_dump($this->session->data['order_id']);
была 21 строка } else {
   $activity_data = array(
      'name'     => $this->session->data['guest']['firstname'] . ' ' . $this->session->data['guest']['lastname'],
      'order_id' => $this->session->data['order_id']
   );

   $this->model_account_activity->addActivity('order_guest', $activity_data);

 

Share this post


Link to post
Share on other sites

нужно строкой выше, перед

$this->model_account_activity->addActivity('order_account', $activity_data);

Share this post


Link to post
Share on other sites
31 минуту назад, AlexDW сказал:

нужно строкой выше, перед

$this->model_account_activity->addActivity('order_account', $activity_data);

И так пробовал но новых ошибок нету и в инспекторе нет ошибок

Share this post


Link to post
Share on other sites
Цитата

www/system/storage/modification/catalog/controller/checkout/success.php on line 21

 

Вы точно, то самый файл открыли для проверки?

  • +1 1

Share this post


Link to post
Share on other sites

Пардон смотрел не модифицированный файл

Share this post


Link to post
Share on other sites

Добрый день. Не правильно написал в модифицированном файле немного друго код

 

21 строка с ошибкой

Спойлер

  17: $pixel = "fbq('track', 'Purchase', {
  18: content_ids: [". implode(',', $prduct_ids) ."],
  19: content_type: 'product',
  20: value: ". $order_info['total'] .",
  21: currency: $this->session->data['currency']
  22: });";

$this->document->setPixel($pixel);

 

system/storage/modification/catalog/controller/checkout/success.php on line 21

Спойлер

<?php
class ControllerCheckoutSuccess extends Controller {
   public function index() {
      $this->load->language('checkout/success');

      if (isset($this->session->data['order_id'])) {

      $this->load->model('checkout/order');

        $order_info = $this->model_checkout_order->getOrder($this->session->data['order_id']);

        $prduct_ids = array();
          foreach ($this->cart->getProducts() as $prducts) {
            $prduct_ids[] = $prducts['product_id'];
          }

        $pixel = "fbq('track', 'Purchase', {
        content_ids: [". implode(',', $prduct_ids) ."],
        content_type: 'product',
        value: ". $order_info['total'] .",
        currency: $this->session->data['currency']
        });";

      $this->document->setPixel($pixel);
      

          $this->load->model('setting/setting');
          $id = $this->config->get('config_store_id');
          
          if($this->config->get('google_remarketing_status_'.$id))
          {
            //DYNAMIC TYPE 
            if($this->config->get('google_remarketing_type_'.$id) == 0)
              $_SESSION['previus_cart'] = $this->cart->getProducts();
          }
        
         $this->cart->clear();

         // Add to activity log
         if ($this->config->get('config_customer_activity')) {
            $this->load->model('account/activity');

            if ($this->customer->isLogged()) {
               $activity_data = array(
                  'customer_id' => $this->customer->getId(),
                  'name'        => $this->customer->getFirstName() . ' ' . $this->customer->getLastName(),
                  'order_id'    => $this->session->data['order_id']
               );

               $this->model_account_activity->addActivity('order_account', $activity_data);
                    var_dump($this->session->data['order_id']);
            } else {
               $activity_data = array(
                  'name'     => $this->session->data['guest']['firstname'] . ' ' . $this->session->data['guest']['lastname'],
                  'order_id' => $this->session->data['order_id']
               );

               $this->model_account_activity->addActivity('order_guest', $activity_data);
            }
         }

         unset($this->session->data['shipping_method']);
         unset($this->session->data['shipping_methods']);
         unset($this->session->data['payment_method']);
         unset($this->session->data['payment_methods']);
         unset($this->session->data['guest']);
         unset($this->session->data['comment']);
         unset($this->session->data['order_id']);
         unset($this->session->data['coupon']);
         unset($this->session->data['reward']);
         unset($this->session->data['voucher']);
         unset($this->session->data['vouchers']);
         unset($this->session->data['totals']);
      }

      $this->document->setTitle($this->language->get('heading_title'));

      $data['breadcrumbs'] = array();

      $data['breadcrumbs'][] = array(
         'text' => $this->language->get('text_home'),
         'href' => $this->url->link('common/home')
      );

      $data['breadcrumbs'][] = array(
         'text' => $this->language->get('text_basket'),
         'href' => $this->url->link('checkout/cart')
      );

      $data['breadcrumbs'][] = array(
         'text' => $this->language->get('text_checkout'),
         'href' => $this->url->link('checkout/checkout', '', true)
      );

      $data['breadcrumbs'][] = array(
         'text' => $this->language->get('text_success'),
         'href' => $this->url->link('checkout/success')
      );

      $data['heading_title'] = $this->language->get('heading_title');

      if ($this->customer->isLogged()) {
         $data['text_message'] = sprintf($this->language->get('text_customer'), $this->url->link('account/account', '', true), $this->url->link('account/order', '', true), $this->url->link('account/download', '', true), $this->url->link('information/contact'));
      } else {
         $data['text_message'] = sprintf($this->language->get('text_guest'), $this->url->link('information/contact'));
      }

      $data['button_continue'] = $this->language->get('button_continue');

      $data['continue'] = $this->url->link('common/home');

      $data['column_left'] = $this->load->controller('common/column_left');
      $data['column_right'] = $this->load->controller('common/column_right');
      $data['content_top'] = $this->load->controller('common/content_top');
      $data['content_bottom'] = $this->load->controller('common/content_bottom');
      $data['footer'] = $this->load->controller('common/footer');
      $data['header'] = $this->load->controller('common/header');

      $this->response->setOutput($this->load->view('common/success', $data));
   }
}

 

Share this post


Link to post
Share on other sites

по итогу, как в анекдоте

 

такое стоит?

https://www.opencart.com/index.php?route=marketplace/extension/info&extension_id=32453

 

к его автору или в комментариях смотрите, там есть ответ

 

Share this post


Link to post
Share on other sites

Установлен

1. Facebook Pixel

2. Facebook Ads Extension https://prnt.sc/p5yyis

В группах пользователей Разрешить просмотр и Разрешить редактировать - разрешено

 

Возможно это модуль  Facebook Pixel ошибку кидает

Edited by Rubik

Share this post


Link to post
Share on other sites

Доброе время суток. Данная ошибка связана с модулем Facebook Conversion Tracking Pixel

 

В файле facebook_pixel.ocmod.xml

 

Найти

Спойлер

$pixel = "fbq('track', 'Purchase', {
content_ids: [". implode(',', $prduct_ids) ."],
content_type: 'product',
value: ". $order_info['total'] .",
currency: $this->session->data['currency']
});";

 

Заменить на

Спойлер

$pixel = "fbq('track', 'Purchase', {
content_ids: [". implode(',', $prduct_ids) ."],
content_type: 'product',
value: ". $order_info['total'] .",
currency: '".$this->session->data['currency']."'
});";

 

Тему можно закрыть.

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
You are posting as a guest. If you have an account, please sign in.
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


  • Recently Browsing   0 members

    No registered users viewing this page.

×

Important Information

On our site, cookies are used and personal data is processed to improve the user interface. To find out what and what personal data we are processing, please go to the link. If you click "I agree," it means that you understand and accept all the conditions specified in this Privacy Notice.