Answer the question
In order to leave comments, you need to log in
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
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
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');
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question