Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

Restricting payment method based on customer


bobsi18

Recommended Posts

Hi there all... I've just installed a 'pay by 30 day account' module and would like to restrict it so that it is only available for customers that I set it for. I found a post from someone saying to create a tick box in admin and an extra field in the customer table - if that box is ticked, then the payment method is allowed, if not, it isn't shown. Now, the tick box is a little too advanced for me, but I've created an extra field in the table using phpmyadmin. I'm happy to change the status for specific customers through phpmyadmin. So now I'm trying to edit my payment file ('includes/modules/payment/net30.php')... This is what I'm fooling around with:

 

function update_status() {
     global $order;

     if ( ($this->enabled == true) ) {
       $check_flag = true;
       $check_query = tep_db_query("select 30account_status from " . TABLE_CUSTOMERS . " where customers_id = '" . (int)$customer_id . "'");
       while ($check = tep_db_fetch_array($check_query)) {
         if ($check['30account_status'] == 0) {
           $check_flag = false;
           break;
         } 
                 }

       if ($check_flag == true) {
         $this->enabled = true;
       }  elseif ($check_flag == false) {
         $this->enabled = false;
       }
     }

where 30account_status is my new field - '1' means the customer can use this module to pay, '0' means the customer cannot use it. However, I can't get it workin - wondering if anyone can see anything obviosuly wrong???

 

Thanks,

~bobsi18~

Link to comment
Share on other sites

Hi there all... I've just installed a 'pay by 30 day account' module and would like to restrict it so that it is only available for customers that I set it for. I found a post from someone saying to create a tick box in admin and an extra field in the customer table - if that box is ticked, then the payment method is allowed, if not, it isn't shown. Now, the tick box is a little too advanced for me, but I've created an extra field in the table using phpmyadmin. I'm happy to change the status for specific customers through phpmyadmin. So now I'm trying to edit my payment file ('includes/modules/payment/net30.php')... This is what I'm fooling around with:

 

function update_status() {
     global $order;

     if ( ($this->enabled == true) ) {
       $check_flag = true;
       $check_query = tep_db_query("select 30account_status from " . TABLE_CUSTOMERS . " where customers_id = '" . (int)$customer_id . "'");
       while ($check = tep_db_fetch_array($check_query)) {
         if ($check['30account_status'] == 0) {
           $check_flag = false;
           break;
         } 
                 }

       if ($check_flag == true) {
         $this->enabled = true;
       }  elseif ($check_flag == false) {
         $this->enabled = false;
       }
     }

where 30account_status is my new field - '1' means the customer can use this module to pay, '0' means the customer cannot use it. However, I can't get it workin - wondering if anyone can see anything obviosuly wrong???

 

Thanks,

~bobsi18~

 

 

make sure you declare $customer_id as global in the function or the function cannot see it:

 

global $order, $customer_id;

Treasurer MFC

Link to comment
Share on other sites

Also this is the payment module constructor you posted so make sure it has the same name as the class definition. "update_status" does not look right.

Link to comment
Share on other sites

make sure you declare $customer_id as global in the function or the function cannot see it:

 

global $order, $customer_id;

THANKYOU! - that was it - all working now - I am just a novice 'hacker', so this is all still very much new to me.

 

I'm sorry, enigma1, I didn't understand what you meant by

this is the payment module constructor you posted so make sure it has the same name as the class definition

- I really am inexperienced at this, all I did was take the NET30 contribution and smudge the zone details - so instead of allowing for a certain zone, it is allowing for a particular customer (that has '30account_status' set to 1).

 

~bobsi18~

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...