This is a discussion on Using tep_draw_pull_down_menu within the osCommerce 2.2 Modification Help forums, part of the osCommerce 2.2 Forums category; Im trying to write a custom payment mod for my website. When a customer orders a contract phone, they need ...
| |||||||
| Register | FAQ | Members List | Calendar | Mark Forums Read |
|
#1
| |||
| |||
| Im trying to write a custom payment mod for my website. When a customer orders a contract phone, they need to answer a few questions, for example occupation, maritial status etc. Im not an expert php programmer, but im learning. I am trying to create drop down menu boxes from which the user can select certain values, for example for maritial status he can select Married, Widowed, Divorced, Single etc. Here is my code so far, i have modified the credit card payment method and used it as a base for my mod Theres some redundant elements in here which do not affect the code, they are from the cc.php mod and i will be removing them. What i need to be able to do is create an array which i fill in with IDs and Values for the boxes and then write them to the database later on (Firstly i want them to actually display) Here is the code, please advise <?php class dd { var $code, $title, $description, $enabled; // class constructor function dd() { global $order; $this->code = 'dd'; $this->title = MODULE_PAYMENT_DD_TEXT_TITLE; $this->description = MODULE_PAYMENT_DD_TEXT_DESCRIPTION; $this->sort_order = MODULE_PAYMENT_DD_SORT_ORDER; $this->enabled = ((MODULE_PAYMENT_DD_STATUS == 'True') ? true : false); if ((int)MODULE_PAYMENT_DD_ORDER_STATUS_ID > 0) { $this->order_status = MODULE_PAYMENT_DD_ORDER_STATUS_ID; } if (is_object($order)) $this->update_status(); $this->email_footer = MODULE_PAYMENT_DD_TEXT_EMAIL_FOOTER; } // class methods function update_status() { global $order; if ( ($this->enabled == true) && ((int)MODULE_PAYMENT_DD_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_DD_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 selection() { global $order; //$time_address_array = array (1 => 'Less than one year' , 'One Year' , 'Two Years' , 'Three Years' , 'Four Years' , 'Five Years' , 'Six Years' , 'Seven Years' , 'Eight Years' , 'Nine Years' , 'Over 10 years'); $time_address_array[] = array('id' => '1', 'text' => '1 year' , 'id' => '2', 'text' => '2 years' ); $maritial_status_array = array ( 'Single' => 'Single', 'Married' => 'Married', 'Divorced' => 'Divorced', 'Seperated' => 'Seperated', 'Widowed' => 'Widowed'); for ($i=1; $i<13; $i++) { $expires_month[] = array('id' => sprintf('%02d', $i), 'text' => strftime('%B',mktime(0,0,0,$i,1,2000))); } $today = getdate(); for ($i=$today['year']; $i < $today['year']+10; $i++) { $expires_year[] = array('id' => strftime('%y',mktime(0,0,0,1,1,$i)), 'text' => strftime('%Y',mktime(0,0,0,1,1,$i))); } $selection = array('id' => $this->code, 'module' => $this->title, 'fields' => array(array('title' => "Time at current address" , 'field' => tep_draw_pull_down_menu('time_address', $time_address_array)), array('title' => "Maritial Status", 'field' => ''), array('title' => "Occupational Status", 'field' => ''), array('title' => "Occupation/Profession", 'field' => ''), array('title' => "Time in occupation", 'field' => ''), array('title' => "Residential Status", 'field' => '') )); return $selection; } function pre_confirmation_check() { return false; } function confirmation() { return array('title' => MODULE_PAYMENT_DD_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_DD_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 Direct Debit Payment Method', 'MODULE_PAYMENT_DD_STATUS', 'True', 'Do you want to enable DD 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 ('Sort order of display.', 'MODULE_PAYMENT_DD_SORT_ORDER', '0', 'Sort order of display. Lowest is displayed first.', '6', '0', now())"); } function remove() { tep_db_query("delete from " . TABLE_CONFIGURATION . " where configuration_key in ('" . implode("', '", $this->keys()) . "')"); } function keys() { return array('MODULE_PAYMENT_DD_STATUS', 'MODULE_PAYMENT_DD_SORT_ORDER'); } } ?> |
| Thread Tools | |
| |