P
P
Protein_R2019-12-01 13:39:18
opencart
Protein_R, 2019-12-01 13:39:18

How to fix Opencart payment method error: 'You must specify a payment method!'?

We switched the cart to ajax, and the following bug appeared: a cart was created, then at least one product was removed from the cart. After that, the order cannot be formed, the error 'It is necessary to specify a payment method!' falls, although in the post it is clear that the payment method is correctly received. I'm practically unfamiliar with opencart, I don't want to mess around a lot so as not to break anything. Error is thrown on these checks

the code

if (!isset($this->request->post['shipping_method'])) {
                $json['error']['warning'] = $this->language->get('error_shipping');
            } else {
                $shipping = explode('.', $this->request->post['shipping_method']);

                if (!isset($shipping[0]) || !isset($shipping[1]) || !isset($this->session->data['shipping_methods'][$shipping[0]]['quote'][$shipping[1]])) {
                    $json['error']['warning'] = $this->language->get('error_shipping');
                }
            }

            if (!isset($this->request->post['payment_method'])) {
                $json['error']['warning'] = $this->language->get('error_payment');
            } elseif (!isset($this->session->data['payment_methods'][$this->request->post['payment_method']])) {
                $json['error']['warning'] = $this->language->get('error_payment');
            }

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Anton R., 2019-12-01
@anton_reut

if (!isset($this->request->post['payment_method'])) {
                $json['error']['warning'] = $this->language->get('error_payment');
            } elseif (!isset($this->session->data['payment_methods'][$this->request->post['payment_method']])) {
                $json['error']['warning'] = $this->language->get('error_payment');
            }

what's next in else?

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question