Page 1 of 1

MOD-Disable payment method if order total is greater than $X

Posted: Mon Jan 16, 2012 7:11 pm
by k412m4z
Also included..
A solution for setting a minimum and maximum perimeter (posted a few posts down)

Difficulty: Easy
Time: 5 Minutes
Version used when writing this tutorial: 1.5.1.3

Presently, the installed payment modules have an option to set a 'minimum' amount required before a payment option becomes available. However, another very useful option is the ability to change this so that a payment option is disabled in the event that an order reaches a certain amount.

This change can easily be made on a per-payment option basis...

To make the change simply decide which payment option(s) you want to set limits for..

We will be making 2 file edits for each payment option; 1 configuration edit and 1 language file edit.

-----

Please note: Although these are simple edits, it's always best to create back-up copies of a file before you edit it in case you make an error editing the file, or if some other issue arises. It's as simple as dropping the original files into a separate temporary folder on your desktop. Be sure to note the directories of those files, since many file names are the same and can be accidentally used to overwrite a completely different file.

-----

Edit #1 - Find the model file which determines the limitation rules..

Open the model file for your payment option under the folder:
catalog/model/payment/

The file name will look something like: my_payment_option_name.php

Search for the line of code that looks like this:

Code: Select all

if ($this->config->get('my_payment_option_name') > $total) {
And simply change 1 character (the greater than or less than symbol from > to <):

Your update will now look like:

Code: Select all

if ($this->config->get(my_payment_option_name') < $total) {
-----

Edit #2 - Change the language in your admin panel so you know what the setting does..

Open the language file for your payment option under:
admin/language/english/payment/

Again the file name will look something like: my_payment_option_name.php

Search for:

Code: Select all

$_['entry_total']
To the right you can change the text.

The default will read:

Code: Select all

Total:<br /><span class="help">The checkout total the order must reach before this payment method becomes active.</span>
So let's change that to something like:

Code: Select all

Maximum Total:<br /><span class="help">Amounts GREATER than this will DISABLE this payment option.</span>
-----

Almost done... Now we just need to apply the setting to the payment option in your admin area.. Simply add the maximum amount you want to set for the payment option.

-----

Now you're all done.

Happy selling :)

Re: MOD-Disable payment method if order total is greater tha

Posted: Sat Feb 25, 2012 10:27 pm
by karma
How to have both where we can define the minimum as well as the maximum amount ?

Re: MOD-Disable payment method if order total is greater tha

Posted: Wed Mar 21, 2012 7:13 pm
by karma
*bump*

Re: MOD-Disable payment method if order total is greater tha

Posted: Thu Mar 22, 2012 2:11 am
by k412m4z
Small adjustment.. Just add lines 3 and 4. catalog/model/payment/-------.php

Code: Select all

		if ($this->config->get('my_payment_option_name') < $total) {
			$status = false;
		} elseif (1000 > $total) {
			$status = false;
$1000 is your minimum amount.
The maximum amount is what you have set in the admin CP.

(Note: Be sure the < is pointed the correct way for line 1 in this example)

Re: MOD-Disable payment method if order total is greater tha

Posted: Thu Mar 22, 2012 3:17 am
by karma
thanks for the code

Re: MOD-Disable payment method if order total is greater tha

Posted: Thu Mar 22, 2012 3:33 am
by k412m4z
No prob. Normally I wouldn't bother (since I am not a programmer) but given your name is also karma.. I felt more inclined to figure out a solution lol :D

Re: MOD-Disable payment method if order total is greater tha

Posted: Thu Apr 19, 2012 7:06 pm
by alexdaydreaming
Hello,

Does this mod apply also to 1.4.9.1?

Thanks!

Re: MOD-Disable payment method if order total is greater tha

Posted: Thu Apr 19, 2012 7:36 pm
by k412m4z
I am not sure.. I have only used 1.5.1.3

If the files look the same, it may very well work.

Backup, and see what happens.. :)

Re: MOD-Disable payment method if order total is greater tha

Posted: Sun Aug 11, 2013 1:11 am
by rdvapors
Would it be possible to restrict payment and shipping on coupon code?

Example
Coupon Code = FREE
Conditions of Coupon Code:
Fixed amount = $x.xx

customer enters coupon code,
payment and shipping are disabled

also
if customer adds another item payment payment and shipping becomes active and coupon code fixed amount remains active.

also
if customer adds enough items to satisfy free shipping amount, coupon code remains active at fixed amount and shipping is disabled.

also
only this coupon code will work.

Visual example

Cart amount:
$5.98
Coupon Code FREE entered,
Coupon Code FREE Applied -$5.98
Cart total = $0.00
Shipping = Free
checkout success.

CONDITION 2
Cart amount:
$15.98
Coupon Code Free entered,
Coupon Code FREE Applied -$5.98
Cart total =$10.00
Shipping = "Whatever shipping"
Shipping selected,
Payment info entered,
checkout success.

CONDITION 3
Cart amount:
$50.00
Coupon Code FREE entered,
Coupon Code FREE applied -$5.98
Cart total =$44.02 "Free Shipping Triggered"
Payment info entered,
checkout success.

Re: MOD-Disable payment method if order total is greater tha

Posted: Sun Sep 22, 2013 8:07 pm
by EttlesEssentialKit
Would this work on weight based shipping?