Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

Activate Money Order from a price


danicasati

Recommended Posts

Hello.

In my website I actually have 3 payment modules:

 

- Money Order

- Cod

- 1 contribution (Cheque)

 

I need to display certain payment module depending of total price.

For example:

If total < 180 $ then display only MONEY ORDER

If total > 180 $ then display ALL MODULES

 

How can I do this?

Link to comment
Share on other sites

Hello.

In my website I actually have 3 payment modules:

 

- Money Order

- Cod

- 1 contribution (Cheque)

 

I need to display certain payment module depending of total price.

For example:

If total < 180 $ then display only MONEY ORDER

If total > 180 $ then display ALL MODULES

 

How can I do this?

 

you can set a disable condition in each module.

so in COD :

 

define('COD_LIMIT', 180);

 

if ($this->enabled == true) {

if ($cart->show_total() <= COD_LIMIT) {

$this->enabled = false;

}

}

Treasurer MFC

Link to comment
Share on other sites

Thank you, boxtel, for your answer.

But, where can I place exactly this code?

 

well, there is a version of COD which has an "update status" function in it but regardless.

 

right after this line:

 

$this->enabled = ((MODULE_PAYMENT_COD_STATUS == 'True') ? true : false);

 

which enables/disables the module depending on the setting in your admin configuration, you can add this code which will overrule the admin enabling based on (basically any) condition:

 

define('COD_LIMIT', 180);

 

if ($this->enabled == true) { // if the module is enabled

if ($cart->show_total() <= COD_LIMIT) { // if cart total below or equal to limit

$this->enabled = false; // disable this module

}

}

 

the define statement you can also later make an admin definition or put it in application top.

Treasurer MFC

Link to comment
Share on other sites

Right.

Which file I need to modify in order to add the "define" statement?

 

you can leave it right there in the module.

you can add it anywhere in application_top.php

you can add it to your configure.php

anywhere you like as long as it is defined before that if statement is executed.

Treasurer MFC

Link to comment
Share on other sites

you can leave it right there in the module.

you can add it anywhere in application_top.php

you can add it to your configure.php

anywhere you like as long as it is defined before that if statement is executed.

 

 

you can also add this :

 

tep_db_query("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, date_added) values ('Cart value Limit', 'COD_LIMIT', '', 'The value of the cart for disabling this module', '6', '', now())");

 

 

right after this:

 

tep_db_query("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, date_added) values ('Shipping methods allowed.', 'MODULE_PAYMENT_COD_SHIPPING', '', 'List here the shipping modules that will allow this payment method, separated by semicolons(ex: zones;table). Empty for always allowed.', '6', '', now())");

 

in the module.

 

then you will have a new entry field in admin where you can set the value.

you have to remove and re-install the module though.

Treasurer MFC

Link to comment
Share on other sites

you can also add this :

 

      tep_db_query("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, date_added) values ('Cart value Limit', 'COD_LIMIT', '', 'The value of the cart for disabling this module', '6', '', now())"); 

right after this:

 

      tep_db_query("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, date_added) values ('Shipping methods allowed.', 'MODULE_PAYMENT_COD_SHIPPING', '', 'List here the shipping modules that will allow this payment method, separated by semicolons(ex: zones;table). Empty for always allowed.', '6', '', now())"); 

 

in the module.

 

then you will have a new entry field in admin where you can set the value.

you have to remove and re-install the module though.

 

 

and make sure you add COD_LIMIT to the keys for eventual removal.

 

function keys() {

return array('MODULE_PAYMENT_COD_STATUS', 'MODULE_PAYMENT_COD_SHIPPING', 'MODULE_PAYMENT_COD_ZONE', 'MODULE_PAYMENT_COD_ORDER_STATUS_ID', 'MODULE_PAYMENT_COD_SORT_ORDER', 'COD_LIMIT');

}

Treasurer MFC

Link to comment
Share on other sites

Ok.

I changed this:

 

/catalog/includes/configure.php

added:

define('COD_LIMIT', 180);

 

/catalog/includes/application_top.php

added:

define('COD_LIMIT', 180);

 

/catalog/includes/modules/payment/cod.php

added:

 

if ($this->enabled == true) { // if the module is enabled

if ($cart->show_total() <= COD_LIMIT) { // if cart total below or equal to limit

$this->enabled = false; // disable this module

}

}

 

after this string:

$this->enabled = ((MODULE_PAYMENT_COD_STATUS == 'True') ? true : false);

 

 

But when I try to checkout, I display this message:

Fatal error: Call to a member function on a non-object in /xxxxxxxxxxxxxxxx/catalog/includes/modules/payment/cod.php on line 27

 

where "xxxx..." is my server path.

Any suggestion?

Link to comment
Share on other sites

Ok.

I changed this:

 

/catalog/includes/configure.php

added:

define('COD_LIMIT', 180);

 

/catalog/includes/application_top.php

added:

define('COD_LIMIT', 180);

 

/catalog/includes/modules/payment/cod.php

added:

 

if ($this->enabled == true) { // if the module is enabled

if ($cart->show_total() <= COD_LIMIT) { // if cart total below or equal to limit

$this->enabled = false; // disable this module

}

}

 

after this string:

$this->enabled = ((MODULE_PAYMENT_COD_STATUS == 'True') ? true : false);

But when I try to checkout, I display this message:

Fatal error: Call to a member function on a non-object in /xxxxxxxxxxxxxxxx/catalog/includes/modules/payment/cod.php on line 27

 

where "xxxx..." is my server path.

Any suggestion?

 

my mistake, in top of the function in the module :

 

function cod() {

global $order;

 

change it to :

 

function cod() {

global $order, $cart;

Treasurer MFC

Link to comment
Share on other sites

  • 2 months later...
my mistake, in top of the function in the module :

 

function cod() {

global $order;

 

change it to :

 

function cod() {

global $order, $cart;

 

Hi!

 

I tried to put a cod limit using all this, in the website it works just fine, but in the admin area when clicking in modules I display this message: Fatal error: Call to a member function on a non-object in /xxxxxx/public_html/loja/includes/modules/payment/cod.php on line 26

 

How can I fix this?

Link to comment
Share on other sites

Hi!

 

I tried to put a cod limit using all this, in the website it works just fine, but in the admin area when clicking in modules I display this message: Fatal error: Call to a member function on a non-object in /xxxxxx/public_html/loja/includes/modules/payment/cod.php on line 26

 

How can I fix this?

 

Ok... fixed! :thumbsup:

 

Change in the /catalog/includes/modules/payment/cod.php:

 

function cod() {

global $order;

 

and

 

if ($this->enabled == true) {

if ($order->info['total'] >= COD_LIMIT) {

$this->enabled = false;

 

 

 

Works fine now!

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...