Post by sameerkale » Wed Nov 15, 2017 5:48 pm

I am using OpenCart 3.x
SHOPPING CART PAGE Totals ->

Code: Select all

                          Sub-Total:	₹261.00
      Gift Certificate (TESTV1):	₹-261.00 --> Voucher of 500 Rs is applied here.
                             Total:	₹0.00
Continue Shopping Checkout
CHECKOUT PAGE TOTALS as below

Code: Select all

Product Name	  Model	Quantity	Unit Price	Total
TEST	                       TEST	          1	   ₹261.00	₹261.00
                                                             Sub-Total: ₹261.00
                                       India MH State (Weight: 0.29kg): ₹45.00
                                      Gift Certificate (TESTV1):	₹-306.00
                                                                 Total: ₹0.00

When i Click Confirm Order, page is routed to Payment Gateway, which i think is incorrect. Because I have applied a Gift Certificate worth 500.
I have enabled only Payment Gateway as payment method.

Suggest What settings should be done to make sure that, when total is 0 when Gift Voucher/Certificate is applied then Payment Gateways should not be called and also Order Must Be Created.

Newbie

Posts

Joined
Thu Jun 29, 2017 1:09 pm

Post by straightlight » Wed Nov 15, 2017 10:16 pm

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:

Code: Select all

// Payment Methods
add above:

Code: Select all

if ($total < 0) {
				$total = 0;
			}
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.
Last edited by straightlight on Thu Nov 16, 2017 1:22 am, edited 1 time in total.

Dedication and passion goes to those who are able to push and merge a project.

Regards,
Straightlight
Programmer / Opencart Tester


Legendary Member

Posts

Joined
Mon Nov 14, 2011 11:38 pm
Location - Canada, ON

Post by Johnathan » Wed Nov 15, 2017 11:49 pm

This is generally handled within the payment method itself. Most of them have a Total setting, so that you can deactivate it if the total is $0.00. You can then enable Free Checkout, which will only show up if the total is 0, and it should let the customer confirm their order.

Image Image Image Image Image


User avatar
Administrator

Posts

Joined
Fri Dec 18, 2009 3:08 am

Who is online

Users browsing this forum: No registered users and 5 guests