I agree with the above statement. Zen-Cart uses a similar functionality whereas the free checkout takes priority overall whenever the total is enforced to a value of 0 since payment providers mostly requires a minimum amount of $1.00 to complete transaction.
In each of the files:
Code: Select all
catalog/controller/api/payment.php
catalog/controller/checkout/payment_method.php
catalog/controller/extension/payment/pp_braintree.php
catalog/controller/extension/payment/pp_express.php
find:
add above:
Then, find:
Code: Select all
foreach ($results as $result) {
if ($this->config->get('payment_' . $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 (!empty($method) && is_array($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;
}
}
}
}
replace with:
Code: Select all
foreach ($results as $result) {
if ($this->config->get('payment_' . $result['code'] . '_status')) {
$this->load->model('extension/payment/' . $result['code']);
if ($total == 0 && html_entity_decode(trim(strtolower($result['code'])), ENT_QUOTES, 'UTF-8') == 'free_checkout') {
$method = $this->{'model_extension_payment_free_checkout'}->getMethod($this->session->data['payment_address'], $total);
} elseif ((float)$total > 0 && html_entity_decode(trim(strtolower($result['code'])), ENT_QUOTES, 'UTF-8') != 'free_checkout') {
$method = $this->{'model_extension_payment_' . $result['code']}->getMethod($this->session->data['payment_address'], $total);
}
if (!empty($method) && is_array($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;
}
}
}
}
This will enforce the free checkout to take priority during checkout and the API. Take note that the free checkout
must be active in order to do this.