Community Forums

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

Free manual modifications can be contributed here. Modifications are manual snippets of code that are pasted into the forums for others to use.

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

Postby k412m4z » Mon Jan 16, 2012 11:11 am

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 :)
Last edited by k412m4z on Wed Mar 21, 2012 6:18 pm, edited 1 time in total.
k412m4z
 
Posts: 86
Joined: Fri Oct 28, 2011 2:13 am

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

Postby karma » Sat Feb 25, 2012 2:27 pm

How to have both where we can define the minimum as well as the maximum amount ?
karma
 
Posts: 17
Joined: Tue Dec 20, 2011 2:08 pm

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

Postby karma » Wed Mar 21, 2012 11:13 am

*bump*
karma
 
Posts: 17
Joined: Tue Dec 20, 2011 2:08 pm

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

Postby k412m4z » Wed Mar 21, 2012 6:11 pm

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)
k412m4z
 
Posts: 86
Joined: Fri Oct 28, 2011 2:13 am

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

Postby karma » Wed Mar 21, 2012 7:17 pm

thanks for the code
karma
 
Posts: 17
Joined: Tue Dec 20, 2011 2:08 pm

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

Postby k412m4z » Wed Mar 21, 2012 7:33 pm

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
k412m4z
 
Posts: 86
Joined: Fri Oct 28, 2011 2:13 am

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

Postby alexdaydreaming » Thu Apr 19, 2012 11:06 am

Hello,

Does this mod apply also to 1.4.9.1?

Thanks!
alexdaydreaming
 
Posts: 91
Joined: Thu May 14, 2009 2:33 am

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

Postby k412m4z » Thu Apr 19, 2012 11:36 am

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.. :)
k412m4z
 
Posts: 86
Joined: Fri Oct 28, 2011 2:13 am


Return to Modifications

Who is online

Users browsing this forum: JedAronson and 0 guests

Hosted by Arvixe Web Hosting