bobsi18 Posted August 4, 2006 Share Posted August 4, 2006 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~ Quote Link to comment Share on other sites More sharing options...
boxtel Posted August 4, 2006 Share Posted August 4, 2006 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; Quote Treasurer MFC Link to comment Share on other sites More sharing options...
Guest Posted August 4, 2006 Share Posted August 4, 2006 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. Quote Link to comment Share on other sites More sharing options...
bobsi18 Posted August 5, 2006 Author Share Posted August 5, 2006 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~ Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.