ivagarfitt Posted May 4, 2007 Share Posted May 4, 2007 hi i installed bank transfer contribution and deposit contribution. What i need is when the product is out of stock in payment methods to be just deposit option, and when the product is in stock , just bank transfer option. thanks :blush: Link to comment Share on other sites More sharing options...
oschellas Posted May 4, 2007 Share Posted May 4, 2007 In shopping_cart.php just under the line: if ($any_out_of_stock == 1) { add: tep_session_register('any_out_of_stock'); $_SESSION['any_out_of_stock'] = 1; in your includes/modules/payment/banktransfer.php code edit the line that looks like this: if ( ($this->enabled == true) && ((int)MODULE_PAYMENT_BANKTRANSFER_ZONE > 0) ) { and add the session statement as follows: if ( ($this->enabled == true) && ((int)MODULE_PAYMENT_BANKTRANSFER_ZONE > 0) && ($_SESSION['any_out_of_stock'] != 1)) { in your includes/modules/payment/deposit.php code do something similar but adjust the added statement to: && ($_SESSION['any_out_of_stock'] == 1) Link to comment Share on other sites More sharing options...
ivagarfitt Posted May 4, 2007 Author Share Posted May 4, 2007 i done all this but it still showing both payment options on the checkout_payment.php page. stock of this test product is 0. Link to comment Share on other sites More sharing options...
oschellas Posted May 4, 2007 Share Posted May 4, 2007 Did you enable the stock check in admin - configuration - stock - Check stock level ? Link to comment Share on other sites More sharing options...
ivagarfitt Posted May 5, 2007 Author Share Posted May 5, 2007 Did you enable the stock check in admin - configuration - stock - Check stock level ? hi, sorry for the late responce.....yes that is set to true same as subtract and allow checkout. i still think something should be set in checkout_payment.php Link to comment Share on other sites More sharing options...
oschellas Posted May 7, 2007 Share Posted May 7, 2007 Forget the code for banktransfer.php and deposit.php that I posted previously. Look for this code in the files mentioned above: // disable the module if the order only contains virtual products if ($this->enabled == true) { if ($order->content_type == 'virtual') { $this->enabled = false; } } In banktransfer.php add the elseif statement as follows: // disable the module if the order only contains virtual products if ($this->enabled == true) { if ($order->content_type == 'virtual') { $this->enabled = false; } elseif ($_SESSION['any_out_of_stock'] == 1) { $this->enabled = false; } } In deposit.php add the elseif statement as follows: // disable the module if the order only contains virtual products if ($this->enabled == true) { if ($order->content_type == 'virtual') { $this->enabled = false; } elseif ($_SESSION['any_out_of_stock'] != 1) { $this->enabled = false; } } I tested it, only deposit available if product(s) out of stock, only banktransfer if product(s) in stock. Link to comment Share on other sites More sharing options...
ivagarfitt Posted May 10, 2007 Author Share Posted May 10, 2007 i dont have this code in either of this two // disable the module if the order only contains virtual products if ($this->enabled == true) { if ($order->content_type == 'virtual') { $this->enabled = false; } } here are my two files: deposit50.php <?php/* $Id: deposit50.php,v 1.10 2003/01/29 19:57:14 hpdl Exp $ amended by Edwin Martinez osCommerce, Open Source E-Commerce Solutions http://www.oscommerce.com Copyright © 2003 osCommerce Released under the GNU General Public License */ class deposit50 { var $code, $title, $description, $enabled; // class constructor function deposit50() { global $HTTP_POST_VARS, $order, $currencies, $cart; $this->code = 'deposit50'; $this->title = MODULE_PAYMENT_DEPOSIT50_TEXT_TITLE; $this->description = MODULE_PAYMENT_DEPOSIT_TEXT_DESCRIPTION; $this->sort_order = MODULE_PAYMENT_DEPOSIT50_SORT_ORDER; $this->enabled = ((MODULE_PAYMENT_DEPOSIT50_STATUS == 'True') ? true : false); if ((int)MODULE_PAYMENT_DEPOSIT50_ORDER_STATUS_ID > 0) { $this->order_status = MODULE_PAYMENT_DEPOSIT50_ORDER_STATUS_ID; } $this->email_footer = MODULE_PAYMENT_DEPOSIT50_TEXT_EMAIL_FOOTER; if (is_object($order)) $this->update_status(); } // class methods function update_status() { global $order; if ( ($this->enabled == true) && ((int)MODULE_PAYMENT_DEPOSIT50_ZONE > 0) ) { $check_flag = false; $check_query = tep_db_query("select zone_id from " . TABLE_ZONES_TO_GEO_ZONES . " where geo_zone_id = '" . MODULE_PAYMENT_DEPOSIT50_ZONE . "' and zone_country_id = '" . $order->billing['country']['id'] . "' order by zone_id"); while ($check = tep_db_fetch_array($check_query)) { if ($check['zone_id'] < 1) { $check_flag = true; break; } elseif ($check['zone_id'] == $order->billing['zone_id']) { $check_flag = true; break; } } if ($check_flag == false) { $this->enabled = false; } } } function javascript_validation() { return false; } function selection() { return array('id' => $this->code, 'module' => $this->title); } function pre_confirmation_check() { return false; } function confirmation() { global $HTTP_POST_VARS, $order, $currencies; define('TOTAL_PAYMENT_INT12', microtime()); $down_payment= $currencies->price() * 0.50; $monthly_payment= ($currencies->price() - $down_payment) * 1.0; $salary = ($monthly_payment / 0.2); $deposit5012= 'Please note: <br><b> 50% deposit Payable immediatley: <font color="red"> ' . number_format($down_payment, 2). '</font color><br> with the remainder payable 1 month before your stay: <font color="red">' . number_format($monthly_payment, 2). ' </b></font color>'.'</b> <br>'; return array('title' => $deposit5012 . MODULE_PAYMENT_DEPOSIT50_TEXT_DESCRIPTION); } function process_button() { global $HTTP_POST_VARS, $order, $currencies; $process_button_string = tep_draw_hidden_field('payment', $currencies->price()); return $process_button_string; } function before_process() { return false; } function after_process() { return false; } function get_error() { return false; } function check() { if (!isset($this->_check)) { $check_query = tep_db_query("select configuration_value from " . TABLE_CONFIGURATION . " where configuration_key = 'MODULE_PAYMENT_DEPOSIT50_STATUS'"); $this->_check = tep_db_num_rows($check_query); } return $this->_check; } function install() { tep_db_query("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, set_function, date_added) values ('Enable Check/Money Order Module', 'MODULE_PAYMENT_DEPOSIT50_STATUS', 'True', 'Do you want to accept Check/Money Order payments?', '6', '1', 'tep_cfg_select_option(array(\'True\', \'False\'), ', now());"); tep_db_query("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, date_added) values ('Make Payable to:', 'MODULE_PAYMENT_DEPOSIT50_PAYTO', '', 'Who should payments be made payable to?', '6', '1', now());"); tep_db_query("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, date_added) values ('Sort order of display.', 'MODULE_PAYMENT_DEPOSIT50_SORT_ORDER', '0', 'Sort order of display. Lowest is displayed first.', '6', '0', now())"); tep_db_query("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, use_function, set_function, date_added) values ('Payment Zone', 'MODULE_PAYMENT_DEPOSIT50_ZONE', '0', 'If a zone is selected, only enable this payment method for that zone.', '6', '2', 'tep_get_zone_class_title', 'tep_cfg_pull_down_zone_classes(', now())"); tep_db_query("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, set_function, use_function, date_added) values ('Set Order Status', 'MODULE_PAYMENT_DEPOSIT50_ORDER_STATUS_ID', '0', 'Set the status of orders made with this payment module to this value', '6', '0', 'tep_cfg_pull_down_order_statuses(', 'tep_get_order_status_name', now())"); } function remove() { tep_db_query("delete from " . TABLE_CONFIGURATION . " where configuration_key in ('" . implode("', '", $this->keys()) . "')"); } function keys() { return array('MODULE_PAYMENT_DEPOSIT50_STATUS', 'MODULE_PAYMENT_DEPOSIT50_ZONE', 'MODULE_PAYMENT_DEPOSIT50_ORDER_STATUS_ID', 'MODULE_PAYMENT_DEPOSIT50_SORT_ORDER', 'MODULE_PAYMENT_DEPOSIT50_PAYTO'); } } ?> and transfer.php <?php/* $Id: TRANSFER.php,v 1.10 2003/01/29 19:57:14 hpdl Exp $ osCommerce, Open Source E-Commerce Solutions http://www.oscommerce.com Copyright © 2003 osCommerce Released under the GNU General Public License */ class transfer{ var $code, $title, $description, $enabled; // class constructor function transfer() { global $order; $this->code = 'transfer'; $this->title = MODULE_PAYMENT_TRANSFER_TEXT_TITLE; $this->description = MODULE_PAYMENT_TRANSFER_TEXT_DESCRIPTION; $this->sort_order = MODULE_PAYMENT_TRANSFER_SORT_ORDER; $this->enabled = ((MODULE_PAYMENT_TRANSFER_STATUS == 'True') ? true : false); if ((int)MODULE_PAYMENT_TRANSFER_ORDER_STATUS_ID > 0) { $this->order_status = MODULE_PAYMENT_TRANSFER_ORDER_STATUS_ID; } if (is_object($order)) $this->update_status(); $this->email_footer = MODULE_PAYMENT_TRANSFER_TEXT_EMAIL_FOOTER; } // class methods function update_status() { global $order; if ( ($this->enabled == true) && ((int)MODULE_PAYMENT_TRANSFER_ZONE > 0) ) { $check_flag = false; $check_query = tep_db_query("select zone_id from " . TABLE_ZONES_TO_GEO_ZONES . " where geo_zone_id = '" . MODULE_PAYMENT_TRANSFER_ZONE . "' and zone_country_id = '" . $order->billing['country']['id'] . "' order by zone_id"); while ($check = tep_db_fetch_array($check_query)) { if ($check['zone_id'] < 1) { $check_flag = true; break; } elseif ($check['zone_id'] == $order->billing['zone_id']) { $check_flag = true; break; } } if ($check_flag == false) { $this->enabled = false; } } } function javascript_validation() { return false; } function selection() { return array('id' => $this->code, 'module' => $this->title); } function pre_confirmation_check() { return false; } function confirmation() { return array('title' => MODULE_PAYMENT_TRANSFER_TEXT_DESCRIPTION); } function process_button() { return false; } function before_process() { return false; } function after_process() { return false; } function get_error() { return false; } function check() { if (!isset($this->_check)) { $check_query = tep_db_query("select configuration_value from " . TABLE_CONFIGURATION . " where configuration_key = 'MODULE_PAYMENT_TRANSFER_STATUS'"); $this->_check = tep_db_num_rows($check_query); } return $this->_check; } function install() { tep_db_query("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, set_function, date_added) values ('Enable Bank Transfer Module', 'MODULE_PAYMENT_TRANSFER_STATUS', 'True', 'Do you want to accept Bank Transfer or Deposits?', '6', '1', 'tep_cfg_select_option(array(\'True\', \'False\'), ', now());"); tep_db_query("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, date_added) values ('Payable to:', 'MODULE_PAYMENT_TRANSFER_PAYTO', '', 'Who is the bank account owner?', '6', '1', now());"); tep_db_query("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, date_added) values ('Account #:', 'MODULE_PAYMENT_TRANSFER_ACCOUNT', '', 'What is the account number to deposit to?', '6', '1', now());"); tep_db_query("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, date_added) values ('Bank:', 'MODULE_PAYMENT_TRANSFER_BANK', '', 'Name of the bank', '6', '1', now());"); tep_db_query("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, date_added) values ('Sort order of display.', 'MODULE_PAYMENT_TRANSFER_SORT_ORDER', '0', 'Sort order of display. Lowest is displayed first.', '6', '0', now())"); tep_db_query("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, use_function, set_function, date_added) values ('Payment Zone', 'MODULE_PAYMENT_TRANSFER_ZONE', '0', 'If a zone is selected, only enable this payment method for that zone.', '6', '2', 'tep_get_zone_class_title', 'tep_cfg_pull_down_zone_classes(', now())"); tep_db_query("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, set_function, use_function, date_added) values ('Set Order Status', 'MODULE_PAYMENT_TRANSFER_ORDER_STATUS_ID', '0', 'Set the status of orders made with this payment module to this value', '6', '0', 'tep_cfg_pull_down_order_statuses(', 'tep_get_order_status_name', now())"); } function remove() { tep_db_query("delete from " . TABLE_CONFIGURATION . " where configuration_key in ('" . implode("', '", $this->keys()) . "')"); } function keys() { return array('MODULE_PAYMENT_TRANSFER_PAYTO', 'MODULE_PAYMENT_TRANSFER_ACCOUNT', 'MODULE_PAYMENT_TRANSFER_BANK', 'MODULE_PAYMENT_TRANSFER_STATUS', 'MODULE_PAYMENT_TRANSFER_ZONE', 'MODULE_PAYMENT_TRANSFER_ORDER_STATUS_ID', 'MODULE_PAYMENT_TRANSFER_SORT_ORDER'); } } ?> Link to comment Share on other sites More sharing options...
charmdiva Posted July 12, 2007 Share Posted July 12, 2007 Hello, Did you ever get this working? I need to accomplish the same thing. Thanks Forget the code for banktransfer.php and deposit.php that I posted previously. Look for this code in the files mentioned above: // disable the module if the order only contains virtual products if ($this->enabled == true) { if ($order->content_type == 'virtual') { $this->enabled = false; } } In banktransfer.php add the elseif statement as follows: // disable the module if the order only contains virtual products if ($this->enabled == true) { if ($order->content_type == 'virtual') { $this->enabled = false; } elseif ($_SESSION['any_out_of_stock'] == 1) { $this->enabled = false; } } In deposit.php add the elseif statement as follows: // disable the module if the order only contains virtual products if ($this->enabled == true) { if ($order->content_type == 'virtual') { $this->enabled = false; } elseif ($_SESSION['any_out_of_stock'] != 1) { $this->enabled = false; } } I tested it, only deposit available if product(s) out of stock, only banktransfer if product(s) in stock. Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.