AverageJoe Posted July 7, 2005 Share Posted July 7, 2005 Hey All, I needed to implement an easy net 30 payment module, but the only one I could find had some bugs and some pretty lousy documentation. I fixed the code and revamped the documentation. Very easy mod to install and use if anyone's interested: Net Terms v1.01 Quote Link to comment Share on other sites More sharing options...
AWWWW.WAHWAH Posted July 7, 2005 Share Posted July 7, 2005 I've installed this and it works fine. The only problem is that when I created a credit limit for a customer and I go back to edit that customer informatiion, I cannot adjust his credit information because all i see is: Credit Line and that's it, nothing else underneath it. Quote Link to comment Share on other sites More sharing options...
AWWWW.WAHWAH Posted July 7, 2005 Share Posted July 7, 2005 Ok, one other thing, when I went to purchase with this test account with a limit of 3K, I tried a purchase and it said I did not have a credit limit set. Quote Link to comment Share on other sites More sharing options...
AverageJoe Posted July 7, 2005 Author Share Posted July 7, 2005 (edited) Make sure that you set both the credit line and the credit remaining to 3000 at the beginning. When you checkout it checks the "credit remaining" field to see if there's enough. If you don't initially set the credit remaining, it'll see $0.00. I forgot to add that to the readme :blush: I probably should have made the credit remaining field to a credits used field, and make the program check (credits - credits used) instead, but it was 2am and I needed to get this working for someone. For your first post, could you upload a little screenshot so I can see what's going on? I'm using the code on my site and the customer's page seems to be working fine. *EDIT* I used the credit's remaining field because it was setup in the first version of this. After work I'm going to try changing it around to what I said above, which would be a lot more intuitive. I might make a version 1.02 if it works well, so let me know about your customer error in case I have to make any revisions. Edited July 7, 2005 by AverageJoe Quote Link to comment Share on other sites More sharing options...
AWWWW.WAHWAH Posted July 7, 2005 Share Posted July 7, 2005 (edited) Edited July 7, 2005 by Young Tae Byun Quote Link to comment Share on other sites More sharing options...
AverageJoe Posted July 8, 2005 Author Share Posted July 8, 2005 (edited) Well, I found a missing </tr> in the code, but it would affect the layout regardless of if you enabled the credit or not. Since you put the credit above the gender near the top, you might have put it in the same row as the gender, which could account for missing info. I've tested out v1.02, which changes the "credit amount left" to "credit amount used", so you don't have to set it at the beginning. I also added the missing </tr>. I'll upload it shortly. *EDIT* Oh, forgot to mention. To upgrade from v1.01 to v1.02, use phpmyadmin to change the table "customers_credit_left" to "customer_credit_used", then update the customers.php, checkout_confirmation.php, and checkout_process.php files. The net terms payment module doesn't change. Edited July 8, 2005 by AverageJoe Quote Link to comment Share on other sites More sharing options...
AWWWW.WAHWAH Posted July 8, 2005 Share Posted July 8, 2005 Can you please post the corrections here? So I won't have to go through the entire hack again and double checking my code? Basically just post the corrections. :D Quote Link to comment Share on other sites More sharing options...
AverageJoe Posted July 8, 2005 Author Share Posted July 8, 2005 sure, give me a few minutes to package the new version, then I'll post the changes. Quote Link to comment Share on other sites More sharing options...
AverageJoe Posted July 8, 2005 Author Share Posted July 8, 2005 (edited) Ok, here we go: 1. Change customers_credit_left to customer_credit_used in the Customers table in phpmyadmin. 2. In admin/customers.php change (line 30): // BOF - Net Terms ? ? ? ?$customers_credit_amount = tep_db_prepare_input($HTTP_POST_VARS['customers_credit_amount'] + $HTTP_POST_VARS['increase_credit']); ? ? ? ?$customers_credit_left = tep_db_prepare_input($HTTP_POST_VARS['customers_credit_left'] + $HTTP_POST_VARS['increase_credit']); ? ? ? ?$customers_credit_status = tep_db_prepare_input($HTTP_POST_VARS['customer_credit']); // EOF - Net Terms to ? ? ? ?// BOF - Net Terms ? ? ? ?$customers_credit_amount = tep_db_prepare_input($HTTP_POST_VARS['customers_credit_amount']); ? ? ? ?$customers_credit_left = tep_db_prepare_input($HTTP_POST_VARS['customers_credit_used']); ? ? ? ?$customers_credit_status = tep_db_prepare_input($HTTP_POST_VARS['customer_credit']); ? ? ? ?// EOF - Net Terms Change (line 166): ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?'customers_credit_left' => $customers_credit_left, to ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?'customers_credit_left' => $customers_credit_used, Change (line 234): ? ? ? ?$customers_query = tep_db_query("select c.customers_id, c.customers_gender, c.customers_credit_left, c.customers_firstname, c.customers_lastname, c.customers_dob, c.customers_credit_amount, c.customers_credit_status, c.customers_email_address, a.entry_company, a.entry_street_address, a.entry_suburb, a.entry_postcode, a.entry_city, a.entry_state, a.entry_zone_id, a.entry_country_id, c.customers_telephone, c.customers_fax, c.customers_newsletter, c.customers_default_address_id from " . TABLE_CUSTOMERS . " c left join " . TABLE_ADDRESS_BOOK . " a on c.customers_default_address_id = a.address_book_id where a.customers_id = c.customers_id and c.customers_id = '" . (int)$HTTP_GET_VARS['cID'] . "'"); to ? ? ? ?$customers_query = tep_db_query("select c.customers_id, c.customers_gender, c.customers_credit_used, c.customers_firstname, c.customers_lastname, c.customers_dob, c.customers_credit_amount, c.customers_credit_status, c.customers_email_address, a.entry_company, a.entry_street_address, a.entry_suburb, a.entry_postcode, a.entry_city, a.entry_state, a.entry_zone_id, a.entry_country_id, c.customers_telephone, c.customers_fax, c.customers_newsletter, c.customers_default_address_id from " . TABLE_CUSTOMERS . " c left join " . TABLE_ADDRESS_BOOK . " a on c.customers_default_address_id = a.address_book_id where a.customers_id = c.customers_id and c.customers_id = '" . (int)$HTTP_GET_VARS['cID'] . "'"); Change (line 696): <!-- BOF - Net Terms --> ? ? ? <tr> ? ? ? ?<td><?php echo tep_draw_separator('pixel_trans.gif', '1', '10'); ?></td> ? ? ?</tr> ? ? ?<tr> ? ? ? ?<td class="formAreaTitle">Credit Line</td> ? ? ?</tr> ? ? ?<tr> ? ? ? ?<td class="formArea"><table border="0" cellspacing="2" cellpadding="2"> <?php if ($cInfo->customers_credit_status == 'enabled'){ ?> ? ?<tr> ? ?<td class="main" align="right">Total Credit Available:</td> ? ?<td><?php echo tep_draw_input_field('customers_credit_amount', $cInfo->customers_credit_amount, 'maxlength="9"');?></td> ? ?<td><?php echo tep_draw_radio_field('customer_credit', 'enabled', 'CHECKED');?>Enable Customer's Credit</td> ? ?</tr> ? ?<tr> ? ?<td class="main" align="right">Credit Amount Left:</td> ? ?<td><?php echo tep_draw_input_field('customers_credit_left', $cInfo->customers_credit_left, 'maxlength="9"');?></td> ? ?<td><?php echo tep_draw_radio_field('customer_credit', 'suspended');?>Suspend Customer's Credit</td> ? ?</tr> ? ?<tr> ? ?<td class="main" align="right">Increase Credit Line:</td> ? ?<td><?php echo tep_draw_input_field('increase_credit', '', 'maxlength="9"');?></td> ? ?<td><?php echo tep_draw_radio_field('customer_credit', 'disabled');?>Disable Customer's Credit</td> ? ?</tr> <?php } if ($cInfo->customers_credit_status == 'suspended'){ ?> ? ? ? ? ?<tr> ? ?<td class="main" align="right">Total Credit Available:</td> ? ?<td><?php echo tep_draw_input_field('customers_credit_amount', $cInfo->customers_credit_amount, 'maxlength="9"');?></td> ? ?<td><?php echo tep_draw_radio_field('customer_credit', 'enabled');?>Enable Customer's Credit</td> ? ?</tr> ? ?<tr> ? ?<td class="main" align="right">Credit Amount Left:</td> ? ?<td><?php echo tep_draw_input_field('customers_credit_left', $cInfo->customers_credit_left, 'maxlength="9"');?></td> ? ?<td><?php echo tep_draw_radio_field('customer_credit', 'suspended', 'CHECKED');?>Suspend Customer's Credit</td> ? ?</tr> ? ?<tr> ? ?<td class="main" align="right">Increase Credit Line:</td> ? ?<td><?php echo tep_draw_input_field('increase_credit', '', 'maxlength="9"');?></td> ? ?<td><?php echo tep_draw_radio_field('customer_credit', 'disabled');?>Disable Customer's Credit</td> ? ?</tr> <?php } if ($cInfo->customers_credit_status == 'disabled'){ ?> ? ? ? ? ?<tr> ? ?<td class="main" align="right">Total Credit Available:</td> ? ?<td><?php echo tep_draw_input_field('customers_credit_amount', $cInfo->customers_credit_amount, 'maxlength="9"');?></td> ? ?<td><?php echo tep_draw_radio_field('customer_credit', 'enabled');?>Enable Customer's Credit</td> ? ?</tr> ? ?<tr> ? ?<td class="main" align="right">Credit Amount Left:</td> ? ?<td><?php echo tep_draw_input_field('customers_credit_left', $cInfo->customers_credit_left, 'maxlength="9"');?></td> ? ?<td><?php echo tep_draw_radio_field('customer_credit', 'suspended');?>Suspend Customer's Credit</td> ? ?</tr> ? ?<tr> ? ?<td class="main" align="right">Increase Credit Line:</td> ? ?<td><?php echo tep_draw_input_field('increase_credit', '', 'maxlength="9"');?></td> ? ?<td><?php echo tep_draw_radio_field('customer_credit', 'disabled', 'CHECKED');?>Disable Customer's Credit</td> ? ?</tr> <?php } ?> ? ? ? ?</table></td></tr> <!-- EOF - Net Terms --> to <!-- Net Terms BOF --> ? <tr> ? ? ? ?<td><?php echo tep_draw_separator('pixel_trans.gif', '1', '10'); ?></td> ? ? ?</tr> ? ? ?<tr> ? ? ? ?<td class="formAreaTitle">Credit Line</td> ? ? ?</tr> ? ? ?<tr> ? ? ? ?<td class="formArea"><table border="0" cellspacing="2" cellpadding="2"> <?php if ($cInfo->customers_credit_status == 'enabled'){ ?> ? ? ?<tr> ? ? ? ?<td class="main" align="right">Total Credit Available:</td> ? ? ? ?<td><?php echo tep_draw_input_field('customers_credit_amount', $cInfo->customers_credit_amount, 'maxlength="9"');?></td> ? ? ? ?<td><?php echo tep_draw_radio_field('customer_credit', 'enabled', 'CHECKED');?>Enable Customer's Credit</td> ? ? ?</tr> ? ? ?<tr> ? ? ? ?<td class="main" align="right">Credit Amount Used:</td> ? ? ? ?<td><?php echo tep_draw_input_field('customers_credit_used', $cInfo->customers_credit_used, 'maxlength="9"');?></td> ? ? ? ?<td><?php echo tep_draw_radio_field('customer_credit', 'suspended');?>Suspend Customer's Credit</td> ? ? ?</tr> ? ? ?<tr> ? ? ? ?<td></td> ? ? ? ?<td></td> ? ? ? ?<td><?php echo tep_draw_radio_field('customer_credit', 'disabled');?>Disable Customer's Credit</td> ? ? ?</tr> <?php } if ($cInfo->customers_credit_status == 'suspended'){ ?> ? ? ?<tr> ? ? ? ?<td class="main" align="right">Total Credit Available:</td> ? ? ? ?<td><?php echo tep_draw_input_field('customers_credit_amount', $cInfo->customers_credit_amount, 'maxlength="9"');?></td> ? ? ? ?<td><?php echo tep_draw_radio_field('customer_credit', 'enabled');?>Enable Customer's Credit</td> ? ? ?</tr> ? ? ?<tr> ? ? ? ?<td class="main" align="right">Credit Amount Used:</td> ? ? ? ?<td><?php echo tep_draw_input_field('customers_credit_used', $cInfo->customers_credit_used, 'maxlength="9"');?></td> ? ? ? ?<td><?php echo tep_draw_radio_field('customer_credit', 'suspended', 'CHECKED');?>Suspend Customer's Credit</td> ? ? ?</tr> ? ? ?<tr> ? ? ? ?<td></td> ? ? ? ?<td></td> ? ? ? ?<td><?php echo tep_draw_radio_field('customer_credit', 'disabled');?>Disable Customer's Credit</td> ? ? ?</tr> <?php } if ($cInfo->customers_credit_status == 'disabled'){ ?> ? ? ?<tr> ? ? ? ?<td class="main" align="right">Total Credit Available:</td> ? ? ? ?<td><?php echo tep_draw_input_field('customers_credit_amount', $cInfo->customers_credit_amount, 'maxlength="9"');?></td> ? ? ? ?<td><?php echo tep_draw_radio_field('customer_credit', 'enabled');?>Enable Customer's Credit</td> ? ? ?</tr> ? ? ?<tr> ? ? ? ?<td class="main" align="right">Credit Amount Used:</td> ? ? ? ?<td><?php echo tep_draw_input_field('customers_credit_used', $cInfo->customers_credit_used, 'maxlength="9"');?></td> ? ? ? ?<td><?php echo tep_draw_radio_field('customer_credit', 'suspended');?>Suspend Customer's Credit</td> ? ? ?</tr> ? ? ?<tr> ? ? ? ?<td></td> ? ? ? ?<td></td> ? ? ? ?<td><?php echo tep_draw_radio_field('customer_credit', 'disabled', 'CHECKED');?>Disable Customer's Credit</td> ? ? ?</tr> <?php } ?> ? ? ?</table></td></tr> <!-- Net Terms EOF --> 3. In checkout_confirmation.php change (line 87): ? ?$check_credit = tep_db_query("select customers_credit_status, customers_credit_left from " . TABLE_CUSTOMERS . " where customers_id ='" . $customer_id . "'"); to ? ?$check_credit = tep_db_query("select customers_credit_status, customers_credit_used, customers_credit_amount from " . TABLE_CUSTOMERS . " where customers_id ='" . $customer_id . "'"); Change (line 99): ? if ($order->info['total'] > $credit['customers_credit_left']){ to ? if ($order->info['total'] > ($credit['customers_credit_amount'] - $credit['customers_credit_used'])){ 4. In checkout_process.php change (line 222): // BEF - Net Terms ?if ($order->info['payment_method'] == 'Terms, Net 30'){ ? ?$check_credit = tep_db_query("select customers_credit_left from " . TABLE_CUSTOMERS . " where customers_id ='" . $customer_id . "'"); ? ?$credit = tep_db_fetch_array($check_credit); ? ?$subamt = $credit['customers_credit_left'] - $order->info['total']; ? ?tep_db_query("update " . TABLE_CUSTOMERS . " set customers_credit_left ='" . $subamt . "' where customers_id = '" . $customer_id . "'"); ?} // EOF - Net Terms to //BOF - NetTerms if ($order->info['payment_method'] == 'Terms, Net 30'){ $check_credit = tep_db_query("select customers_credit_used from " . TABLE_CUSTOMERS . " where customers_id ='" . $customer_id . "'"); $credit = tep_db_fetch_array($check_credit); $addamt = $credit['customers_credit_used'] + $order->info['total']; tep_db_query("update " . TABLE_CUSTOMERS . " set customers_credit_used ='" . $addamt . "' where customers_id = '" . $customer_id . "'"); } //EOF - Net Terms Haha... it probably would have been easier just to compare the new files :rolleyes: Edited July 8, 2005 by AverageJoe Quote Link to comment Share on other sites More sharing options...
AWWWW.WAHWAH Posted July 8, 2005 Share Posted July 8, 2005 I get this error and I have double checked everything. 1054 - Unknown column 'c.customers_credit_used' in 'field list' select c.customers_id, c.customers_gender, c.customers_credit_used, c.customers_firstname, c.customers_lastname, c.customers_dob, c.customers_credit_amount, c.customers_credit_status, c.customers_email_address, a.entry_company, a.entry_street_address, a.entry_suburb, a.entry_postcode, a.entry_city, a.entry_state, a.entry_zone_id, a.entry_country_id, c.customers_telephone, c.customers_fax, c.customers_newsletter, c.customers_default_address_id from customers c left join address_book a on c.customers_default_address_id = a.address_book_id where a.customers_id = c.customers_id and c.customers_id = '2' Quote Link to comment Share on other sites More sharing options...
AWWWW.WAHWAH Posted July 8, 2005 Share Posted July 8, 2005 Nevermind, I skipped step one in the myPHP instructions, but I still get the same image as above. Quote Link to comment Share on other sites More sharing options...
AWWWW.WAHWAH Posted July 8, 2005 Share Posted July 8, 2005 (edited) Ok to solve this. What I did is I went into the customer account that I initially had the problem with and under MyPHP, I went ahead and changed the status to 'disable' so I could get back into the account to give it a credit. Well it worked. I went into the account and entered 3000 for the credit limit and hit update and got this: 1054 - Unknown column 'customers_credit_left' in 'field list' update customers set customers_firstname = 'first name', customers_lastname = 'last name', customers_email_address = '[email protected]', customers_telephone = '300-000-0000', customers_fax = '000-000-0000', customers_newsletter = '1', customers_credit_left = '0.00', customers_credit_status = 'enabled', customers_credit_amount = '3000', customers_gender = 'm', customers_dob = '00000000' where customers_id = '2' Edited July 8, 2005 by Young Tae Byun Quote Link to comment Share on other sites More sharing options...
AverageJoe Posted July 8, 2005 Author Share Posted July 8, 2005 (edited) Ah crap... I have a very modified version of oscommerce, so what I'm doing is getting it to work on mine, then redoing everything on a vanilla version of oscommerce. It seems that on transferring it to the vanilla version, I missed fixing the beginning of two lines :blush: In your customers.php file change (line 32): ? ? ? ?$customers_credit_left = tep_db_prepare_input($HTTP_POST_VARS['customers_credit_used']); to ? ? ? ?$customers_credit_used = tep_db_prepare_input($HTTP_POST_VARS['customers_credit_used']); Change (line 165): ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?'customers_credit_left' => $customers_credit_used, to ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?'customers_credit_used' => $customers_credit_used, I checked the other files and they seem to be fine. Again, sorry about that. Let me know if you have any problems before I upload the fix to the fix to the contributions. Edited July 8, 2005 by AverageJoe Quote Link to comment Share on other sites More sharing options...
AWWWW.WAHWAH Posted July 8, 2005 Share Posted July 8, 2005 Works like a charm now. So version 1.03 is out now, right? Now time for version 2.00. Customers with NET TERMS, all customers, should be able to go into their account to see if their net account is disabled or enabled. also for customers with enabled account should be able to go into their account history and see howmuch credit they have and howmuch they have used and how much they have left. I know, I know, hate me later. :D But this is a damn good contribution. Quote Link to comment Share on other sites More sharing options...
AverageJoe Posted July 8, 2005 Author Share Posted July 8, 2005 (edited) If you still have the problems with the table in the customers.php getting messed up when you enable an account, I'd suggest following the readme and putting it after the newsletter. You could post your customers.php file as well and I can check to see if something seems wrong. *EDIT* Well, missed your post above. Glad it worked out. I was actually thinking of allowing the customer to see how much credit they have left... maybe when I have some time on my hands after unvieling my new site I'll screw around with it :) Edited July 8, 2005 by AverageJoe Quote Link to comment Share on other sites More sharing options...
wintecs Posted July 8, 2005 Share Posted July 8, 2005 Thanks Mate...Just wanted to say the contribution worked great for me first time. But Ill update to the new version anyway. Thanks again Quote Link to comment Share on other sites More sharing options...
technophobe Posted July 12, 2005 Share Posted July 12, 2005 Thanks, after playing arround with it for a while, i have got this working well on my site, this is just what i was looking for. Thanks again. Quote zappautomation Link to comment Share on other sites More sharing options...
patrick77550 Posted July 19, 2005 Share Posted July 19, 2005 Joe, Thanks for fixing this contribution. I could only sort of make the original work. (Hey my first coding was on PUNCH CARDS.) Quote Link to comment Share on other sites More sharing options...
zschutz Posted February 9, 2007 Share Posted February 9, 2007 This looks like a great contribution, and could be exactly what I need for my website. However, I went to install it and I noticed that in a lot of the places where you changed files I have code from the Separate Pricing Per Customer (SPPC) contribution. Before I start messing with the files I was wondering if you knew whether these two contributions will work together. Thanks for all your help, and great work. ~Zach Quote Link to comment Share on other sites More sharing options...
Fidler Posted March 15, 2007 Share Posted March 15, 2007 Is there a way to implement the credit check when a customer places a product in their basket ? Or better yet, I am using the contribution "WishList" and I also like to check the available credit when customers place items in their wishlist. Quote Link to comment Share on other sites More sharing options...
psynaptic Posted April 6, 2007 Share Posted April 6, 2007 We need the ability to check a customer for a large amount so we can issue them with for instance a £1000 credit account. I've so far been unable to find anything useful. If anyone has any ideas please PM me, there might be a reward in it for you. :) Quote My Profile | Contribs I like most: 'On The Fly' Auto Thumbnailer, Active Countries, Header Tags Controller, Ultimate SEO URLs, UK Based osC, UK Postcode Validation, Open Featured Sets, UK Postcode Based Carrier Shipping 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.