spannerman Posted February 3, 2008 Posted February 3, 2008 Hi folks, Having no luck with a bit of coding, if anyone can help. Installed OSC_Affiliates 2.8 and all seems to be well with that, but I now have another requirement. Added a field to the Create Account page, which calls a drop down list from the Affiliates table of another custom field. The drop down is showing the correct data from the Affiliates table, but not submitting it to the Customers table when the account is created. Code snippet as follows: <td class="main"><?php echo ENTRY_CLUB; ?></td> <td class="main"> <?php // if ($process == true) { $clubs_array = array(); $clubs_query = tep_db_query("select affiliate_club, affiliate_club_keyword from " . TABLE_AFFILIATE . " order by affiliate_club"); while ($clubs_values = tep_db_fetch_array($clubs_query)) { $clubs_array[] = array('id' => $clubs_values['affiliate_club'], 'text' => $clubs_values['affiliate_club']); } echo tep_draw_pull_down_menu('affiliate_club', $clubs_array); } //else { //echo tep_draw_input_field('clubname'); //} //} else { // echo tep_draw_input_field('clubname'); // } if (tep_not_null(ENTRY_CLUBNAME_TEXT)) echo ' <span class="inputRequirement">' . ENTRY_CLUBNAME_TEXT; // } ?> I took the code from the Zones and Countries areas of the Create Account page, since this allows the customer to select from a dropdown and inserts the choice into the Address Book etc. If I uncomment the "If process == true" line and subsequent else statements, all I get is a text field. Tearing hair out stage, so all help much appreciated! Regards, Simon
user99999999 Posted February 3, 2008 Posted February 3, 2008 I think you need to register the variable in the session vars like so, then you will be able to use it. if (!tep_session_is_registered('affiliate_club')) tep_session_register('affiliate_club'); if (isset($HTTP_POST_VARS['affiliate_club']) && tep_not_null($HTTP_POST_VARS['affiliate_club'])) { $affiliate_club = (int)$HTTP_POST_VARS['affiliate_club']; }
spannerman Posted February 3, 2008 Author Posted February 3, 2008 Thanks for the input Dave, I've still not got it right though! Just for clarification I already had $affiliate_club = tep_db_prepare_input($HTTP_POST_VARS['$affiliate_club']); $club_keyword = tep_db_prepare_input($HTTP_POST_VARS['$club_keyword']); up near the top of the file, in with all the other tep_db_prepare_input lines that are there. I also have: if ($error == false) { $sql_data_array = array('customers_firstname' => $firstname, 'customers_lastname' => $lastname, 'customers_email_address' => $email_address, 'customers_telephone' => $telephone, 'customers_fax' => $fax, 'customers_newsletter' => $newsletter, 'customers_password' => tep_encrypt_password($password) ); if (ACCOUNT_CLUB == 'true') $sql_data_array['affiliate_club'] = $affiliate_club; if (ACCOUNT_GENDER == 'true') $sql_data_array['customers_gender'] = $gender; if (ACCOUNT_DOB == 'true') $sql_data_array['customers_dob'] = tep_date_raw($dob); which is up before the tep_db_perform(TABLE_CUSTOMERS, $sql_data_array); line which actually inserts the new account into the database. On your comment it did get me thinking, so I've now added to this: $customer_first_name = $firstname; $customer_default_address_id = $address_id; $customer_country_id = $country; $customer_zone_id = $zone_id; tep_session_register('customer_id'); tep_session_register('customer_first_name'); tep_session_register('customer_default_address_id'); tep_session_register('customer_country_id'); tep_session_register('customer_zone_id'); tep_session_register('affiliate_club'); tep_session_register('club_keyword'); but with no success. It is trying to enter something, since the field in the database is set to blank, when the default is set to the word "none" - it's just not getting the right info from that drop down field. The first 2 rows in the dropdown are empty since the first two test affiliate accounts I've entered didn't have any values in that field. I don't know if that has anything to do with it. Just in case anyone reading this needs to know, I'm on version 2.2 rc1 with PHP5, but thought I'd be able to get this working using the built in functions! Regards, Simon
user99999999 Posted February 3, 2008 Posted February 3, 2008 These lines are incorrect $affiliate_club = tep_db_prepare_input($HTTP_POST_VARS['$affiliate_club']); $club_keyword = tep_db_prepare_input($HTTP_POST_VARS['$club_keyword']); Should be $affiliate_club = tep_db_prepare_input($HTTP_POST_VARS['affiliate_club']); $club_keyword = tep_db_prepare_input($HTTP_POST_VARS['club_keyword']); This should have a third parameter of currently selected item. echo tep_draw_pull_down_menu('affiliate_club', $clubs_array, $affiliate_club);
spannerman Posted February 3, 2008 Author Posted February 3, 2008 Many thanks Dave! That sorted it. Simple things that get me so annoyed because I know they should work but I can't get it to do what I want! As you may tell, I'm no programmer! Thanks again, Regards, Simon
spannerman Posted February 3, 2008 Author Posted February 3, 2008 One more question - I'm now editing the Edit Account area of the site so that my existing customers can choose their club and add the info to their account. How do I get the drop down to hold the current database setting if they already have chosen a club from the list? I assume it's adding another parameter to the "echo tep_draw_pull_down_menu('affiliate_club', $clubs_array, $affiliate_club);" line, but what? Once again, much help appreciated. Regards, Simon
Guest Posted November 14, 2008 Posted November 14, 2008 Spannerman: I am having the same problem with dropdowns not selecting existing value, did you manage to solve this?
Recommended Posts
Archived
This topic is now archived and is closed to further replies.