danicasati Posted August 26, 2005 Share Posted August 26, 2005 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? Quote Link to comment Share on other sites More sharing options...
boxtel Posted August 26, 2005 Share Posted August 26, 2005 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? <{POST_SNAPBACK}> 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; } } Quote Treasurer MFC Link to comment Share on other sites More sharing options...
danicasati Posted August 26, 2005 Author Share Posted August 26, 2005 define('COD_LIMIT', 180); if ($this->enabled == true) { if ($cart->show_total() <= COD_LIMIT) { $this->enabled = false; } } <{POST_SNAPBACK}> Thank you, boxtel, for your answer. But, where can I place exactly this code? Quote Link to comment Share on other sites More sharing options...
boxtel Posted August 26, 2005 Share Posted August 26, 2005 Thank you, boxtel, for your answer.But, where can I place exactly this code? <{POST_SNAPBACK}> 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. Quote Treasurer MFC Link to comment Share on other sites More sharing options...
danicasati Posted August 26, 2005 Author Share Posted August 26, 2005 the define statement you can also later make an admin definition or put it in application top. <{POST_SNAPBACK}> Right. Which file I need to modify in order to add the "define" statement? Quote Link to comment Share on other sites More sharing options...
boxtel Posted August 26, 2005 Share Posted August 26, 2005 Right.Which file I need to modify in order to add the "define" statement? <{POST_SNAPBACK}> 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. Quote Treasurer MFC Link to comment Share on other sites More sharing options...
boxtel Posted August 26, 2005 Share Posted August 26, 2005 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. <{POST_SNAPBACK}> 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. Quote Treasurer MFC Link to comment Share on other sites More sharing options...
boxtel Posted August 26, 2005 Share Posted August 26, 2005 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. <{POST_SNAPBACK}> 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'); } Quote Treasurer MFC Link to comment Share on other sites More sharing options...
danicasati Posted August 26, 2005 Author Share Posted August 26, 2005 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? Quote Link to comment Share on other sites More sharing options...
boxtel Posted August 26, 2005 Share Posted August 26, 2005 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? <{POST_SNAPBACK}> my mistake, in top of the function in the module : function cod() { global $order; change it to : function cod() { global $order, $cart; Quote Treasurer MFC Link to comment Share on other sites More sharing options...
ognarom Posted November 21, 2005 Share Posted November 21, 2005 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? Quote Link to comment Share on other sites More sharing options...
ognarom Posted November 21, 2005 Share Posted November 21, 2005 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! Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.