Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

Limit customer YTD spending to $1,000


brokenjago

Recommended Posts

Hey guys.

 

I was wondering if there was an easy way to limit a customer's spending to $1,000 per year?

 

I know, I know: "Why in the heck would you want to limit people from spending money?!"

 

I'm doing a site right now and it's for employees of a company, who get significant discounts off their products, but are limited to $1,000 per year.

 

Seems like something that would be easy enough to implement, and I was just wondering if someone could help or point me in the right direction.

 

Thanks!!

Link to comment
Share on other sites

You should be able to tweak osCom ... first you'd need a unique reference, e.g. staff number so employees can't set up multiple accounts with different email addresses. There'd need be a check when setting up accounts that this unique identifier has not been used yet.

 

And then you'd need to create a new script / table which totals the orders .. maybe counting downwards from a thousand. This could be done as part of checkout_process.php.

 

Then on checkout (maybe checkout_payment.php) you'd check what's left for that employee in the pot & only allow to proceed if there's enough money left.

 

Actually sounds like a neat little script to write - hope you get on well with the site! Terra

My code for combining PayPal IPN with ** QTPro 4.25 ** osC Affiliate ** CCGV(trad)

and how to solve the invoice already paid error

General info: Allow customer to delete order comment ** FTP Programs & Text Editors ** Amending order email **

Link to comment
Share on other sites

mmh - bit more tricky. Easiest way would be to write a scipt which wipes the table which tracks "the pot"... as it's only once a year, the site admin would just need to make sure to hit the button once a year. Or do it via a cron job but for a yearly script that seems a bit overkill. Or you could just go into PHPMyAdmin once a year & clear the table. Terra

NB: I'm assuming that all employees conform to the same year, regardless of start date.

My code for combining PayPal IPN with ** QTPro 4.25 ** osC Affiliate ** CCGV(trad)

and how to solve the invoice already paid error

General info: Allow customer to delete order comment ** FTP Programs & Text Editors ** Amending order email **

Link to comment
Share on other sites

There are about 4 or 5 good workable Credit or Account Balance mods in the contributions section.

 

Just do a search for Credit and Account balance. Here is one that is a good base to start with and you can modify it easily.

 

 

anyway this contribution allows the set up of credit accounts, the person will have to contact you for you to set it up because there isn't a sign-up made for this yet, just the possibility for you to allow them to have credit, i will create a sign up later, there are still ideas floating in my head about that. anyway just add the code go to the admin section and enable the payment module, the go to the customers area and at the bottom there should be the options to allow customer credit, the rest is pretty self explanitory. have fun with this one!

 

into sql database

ALTER TABLE customers

ADD customers_credit_status varchar(9) NOT NULL default 'disabled',

ADD customers_credit_amount decimal(9,2) NOT NULL default '0000.00',

ADD customers_credit_left decimal(9,2) NOT NULL default '0.00';

 

 

around line 76 in checkout_confirmation.php

// Check If Customer Has Credit (If That Option Is Chosen)

$customer_credit = false;

$check_credit = tep_db_query("select customers_credit_status, customers_credit_left from " . TABLE_CUSTOMERS . " where customers_id ='" . $customer_id . "'");

$credit = tep_db_fetch_array($check_credit);

if ($credit['customers_credit_status'] == "enabled" || $credit['customers_credit_status'] == "suspended"){

$credit_allowed = 'true';

} else {

$credit_allowed = 'false';

}

if ($credit_allowed == 'false'){

echo '<script>alert("We\'re Sorry You Don\'t Seem To Have An Account With Us, Please Choose A Different Payment Method.");</script>';

echo '<script>history.go(-1);</script>';

}

if ($credit_allowed == 'true') {

if ($order->info['total'] > $credit['customers_credit_left']){

echo '<script>alert("Not Enough Store Credit In Your Account");</script>';

echo '<script>history.go(-1);</script>';

}

if ($credit['customers_credit_status'] == "suspended"){

echo '<script>alert("Sorry Your Account Seems To Be Suspended Please Contact Us To Straighten Out This Matter.");</script>';

echo '<script>history.go(-1);</script>';

}

}

 

around line 23 in admin/customers.php

$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']);

 

around line 36 in admin/customers.php

'customers_credit_left' => $customers_credit_left,

'customers_credit_status' => $customers_credit_status,

'customers_credit_amount' => $customers_credit_amount,

 

around line 257 in admin/customers.php replace original with this

$customers_query = tep_db_query("select 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 = '" . $HTTP_GET_VARS['cID'] . "'");

 

 

 

around line 415 in admin/customers.php

<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');?>Enabled</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" READONLY');?></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"><?php echo ENTRY_CREDIT; ?></td>

<td class="main"><?php echo tep_draw_input_field('customers_credit_amount', $cInfo->customers_credit_amount, 'maxlength="9" READONLY');?><br><?php echo tep_draw_input_field('customers_credit_left', $cInfo->customers_credit_left, 'maxlength="9" READONLY');?></td>

<td class="main"><?php echo tep_draw_radio_field('customer_credit', 'enabled');?>ReEnable Customers Credit<br><?php echo tep_draw_radio_field('customer_credit', 'suspended', 'CHECKED');?>Customers Credit Is Suspended<br><?php echo tep_draw_radio_field('customer_credit', 'disabled');?>Completly Disable Customer's Credit?</td>

</tr>

<?php

}

if ($cInfo->customers_credit_status == 'disabled'){

?>

<tr>

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

<td class="main"><?php echo tep_draw_radio_field('customer_credit', 'disabled', 'CHECKED');?>Customers Credit Is Disabled<br><?php echo tep_draw_radio_field('customer_credit', 'enabled');?>Enable Customer's Credit?</td>

</tr>

<?php

}

?>

</table></td>

 

 

around line 101 in checkout_process.php

//Subtract The Total From Customer Credit (If Applicable)

if ($order->info['payment_method'] == 'net30/net60'){

$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 . "'");

}

 

Hope that gets you goin.

Link to comment
Share on other sites

Archived

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

×
×
  • Create New...