Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

Hidden Products and VIP's


jmckeand

Recommended Posts

I have installed the Linda's Hidden Products and Products VIP.

 

They work great.

 

What I would want to do is add a field to the Create Account form that would allow a user to enter a referral code to automatically set their VIP status in the db. Otherwise, the process would be customer creates account, email store owner asking for access to hidden products, store owner going into Admin side to flip the switch. Then email customer that they have access. This could create a delay and loss of sales.

 

Adding the field to the form is not a problem. I don't know where to start with the checking the input and then changing the db to reflect the change.

 

My client want to allow members of a teaching association to enter a secret code to allow them to see special products at a significant discount. The users will get the code from the association's "resource" directory, where my client's site is described.

 

Does any one have a direction to start?

 

James.

James.

 

If you are not having fun, your not doing it right... :wink:

Link to comment
Share on other sites

I guess you need a validation check in create_account_process.php that checks that field against the allowed secret code(s) and then runs a change status to vip.

Reddy to Rumble

 

Thank you osCommerce and all who Contribute to her!

Link to comment
Share on other sites

Thanks Rumble!

 

Here's what I did:

I added to includes/languages/english.php

define('ENTRY_VIP', 'Referral Code:');

define('ENTRY_VIP_TEXT', '');

define('ENTRY_VIP_YES', 'Educator Access Allowed');

define('ENTRY_VIP_NO', '');

define('ENTRY_VIP_ERROR', '');

define('ENTRY_VIP_CODE', 'secret');

I added to includes/modules/account_details.php after newsletter stuff (basically copied newletter stuff)

<tr>

  <td class="main"> <?php echo ENTRY_VIP; ?></td>

  <td class="main"> 

     <?php

        if ($is_read_only == true) {

           if ($account['customers_approved'] == '1') {

              echo ENTRY_VIP_YES;

           } else {

              echo ENTRY_VIP_NO;

           }

        } elseif ($processed == true) {

           if ($account['customers_approved'] == '1') {

              echo ENTRY_VIP_YES;

           } else {

              echo ENTRY_VIP_NO;

           }

           echo tep_draw_hidden_field('vip_access_code');  

        } else {

           echo tep_draw_input_field('vip_access_code', $vip_access_code) . ' ' . ENTRY_VIP_TEXT;

        }

     ?>

  </td>

</tr>

Then I modifed to the $account_query in account.php to include the customers_approved field (c.customers_approved)

 

Then came the check in create_account_process.php

$vip_access_code = tep_db_prepare_input($HTTP_POST_VARS['vip_access_code']);



---snip---



if ($vip_access_code == ENTRY_VIP_CODE) {

  $vip_access = 1;

} else {

  $vip_access = 0;

}



---snip---



(added to $sql_data_array)

'customers_approved' => $vip_access,

 

This seems to work for creation of an account with VIP access.

 

When I explained this to my client. He asked if a user could edit an existing account to add the VIP access.

 

I thought I would be able to make simular changes to account_edit.php ($account_query) and account_edit_process.php. Here is my "current" check (note: I also added "'customers_approved' => $vip_access_edit," to the $sql_data_array):

$vip_access_edit = '';

if ($account['customers_approved'] == 0) {

  if ($vip_access_code == ENTRY_VIP_CODE) {

     $vip_access_edit = 1;

  } elseif ($vip_access_code != ENTRY_VIP_CODE) {

     $vip_access_edit = 0;

  }

} elseif ($account['customers_approved'] == 1) {

  if ($vip_access_code == ENTRY_VIP_CODE) {

     $vip_access_edit = 1;

  } elseif ($vip_access_code != ENTRY_VIP_CODE) {

     $vip_access_edit = 1;

  }

}

This works to add the VIP access, but if the user was already "approved" and they edit their account would be "unapproved".

 

What am I missing I don't want people to loose access because they need to change there address or unsubscribe from the newsletter.

 

I'm at a loss.

 

James.

James.

 

If you are not having fun, your not doing it right... :wink:

Link to comment
Share on other sites

Just thinking out loud...

 

So in account_details.php (which handles drawing the form) I should check to see if customer_approved is 0 (the default state and "no access") then draw the input field? (from the end of my code...)

} else {

  if ($account['customers_approved'] == '0') {

     echo tep_draw_input_field('vip_access_code', $vip_access_code) . ' ' . ENTRY_VIP_TEXT;

  }

}

Then the check in account_edit_process.php would be the same as the check in create_account_process.php...

if ($vip_access_code == ENTRY_VIP_CODE) {

  $vip_access = 1;

} else {

  $vip_access = 0;

}

 

Then later in change status part ($sql_data_array) would also be conditional on the customer_approved state much like the DOB and Gender are conditional on whether or not they are tracked...

James.

 

If you are not having fun, your not doing it right... :wink:

Link to comment
Share on other sites

Here is what seems to work:

 

In account_edit_process.php (using check above) to post to DB :

if ($account['customers_approved'] != '1') $sql_data_array['customers_approved'] = $vip_access;

 

In account_details.php:

if ($account['customers_approved'] != '1') {

 echo tep_draw_input_field('vip_access_code', $vip_access_code) . ' ' .  ENTRY_VIP_TEXT;

}

 

In otherwords only do these things if customer_apporved is 0 or null (not 1)

 

I love when a plan comes together :lol:

James.

 

If you are not having fun, your not doing it right... :wink:

Link to comment
Share on other sites

  • 10 months later...

This seems to be very close to what I want to do - did you get this up and running?

I am trying to build a site for magician and some of the product are for 'inner circle' types that will have to answer a question to gain acces to the real 'good stuff'.

 

Is there anyway I can get this sort of thing up and running on the latest system?

all the best,

Justin

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...