R
R
Ruslan2021-12-24 13:40:37
opencart
Ruslan, 2021-12-24 13:40:37

How to disable opencart payment method selection warning?

You can remove the message in the cart You must choose a payment method! in opencart 2.3?
I hid the methods themselves in the display. In the admin panel, I left only one method enabled - Payment on delivery.
But in the payment_method.php controller, there is a check for the existence of a payment method

$results = $this->model_extension_extension->getExtensions('payment');

      $recurring = $this->cart->hasRecurringProducts();

      foreach ($results as $result) {
        if ($this->config->get($result['code'] . '_status')) {
          $this->load->model('extension/payment/' . $result['code']);

          $method = $this->{'model_extension_payment_' . $result['code']}->getMethod($this->session->data['payment_address'], $total);
                    
          if ($method) {
            if ($recurring) {
              if (property_exists($this->{'model_extension_payment_' . $result['code']}, 'recurringPayments') && $this->{'model_extension_payment_' . $result['code']}->recurringPayments()) {
                $method_data[$result['code']] = $method;
              }
            } else {
              $method_data[$result['code']] = $method;
            }
          }
        }
      }

      $sort_order = array();

      foreach ($method_data as $key => $value) {
        $sort_order[$key] = $value['sort_order'];
      }

      array_multisort($sort_order, SORT_ASC, $method_data);

      $this->session->data['payment_methods'] = $method_data;

  if (empty($this->session->data['payment_methods'])) {
      $data['error_warning'] = sprintf($this->language->get('error_no_payment'), $this->url->link('information/contact'));
    } else {
      $data['error_warning'] = '';
    }

    if (isset($this->session->data['payment_methods'])) {
      $data['payment_methods'] = $this->session->data['payment_methods'];
    } else {
      $data['payment_methods'] = array();
    }

    if (isset($this->session->data['payment_method']['code'])) {
      $data['code'] = $this->session->data['payment_method']['code'];
    } else {
      $data['code'] = '';
    }

As I understand it, the session is recorded. Can I substitute something there so that it takes this value? And in what form should it be?

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question