Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

Please help!- one per customer


pabloron

Recommended Posts

:blink:

I have been trying (unsuccessfully so far) to limit the number of products that a customer can purchase - a one-per-customer coupon. Does anyone know of an existing contribution that can be modified to do this or how to accomplish this?

 

Thanks a million!

Paul

Link to comment
Share on other sites

you could edit checkout process

add something like

 

----BEGIN EXAMPLE CODE

 

<?

$query = "SELECT orders_id FROM orders WHERE customers_id = '$customer_id'";

$result = mysql_query($query);

while ($row = mysql_fetch_array($result)) {

$bought = $row['orders_id'];

}

 

if($bought) {

?>

<html>

<head>

<META HTTP-EQUIV="Refresh" CONTENT="0;URL=http://www.yourwebsite.com/already_bought.php">

</head>

<body>

</body>

</html>

<?

} else { // RUN USUAL CODE

?>

 

 

-----END EXAMPLE CODE

 

this would check your orders table and if they have placed an order before then it would redirect them to already_bought.php which you could create to display any message you wanted to. The order would only be processed if $bought was non existent which would happen when they had not ordered before.

 

One problem would be that they could sign up as a new member and order again and it would not pick up on it. Maybe you could build in IP tracking also to go someway to preventing this?

always here to offer some useless advice....

Link to comment
Share on other sites

Thanks for your response Gareth. I finally broke down and installed the 99 files in the gift voucher/ coupon contribution, which is quite good and accomplishes the one per customer thing.

 

Best regards - Paul

Link to comment
Share on other sites

  • 7 years later...

Thank you sooooo much Gareth. I just installed this.........nothing could be sweeter. Although, I just pasted it (excluding the..else) at the bottom of my products description in admin. That way, the client is redirected before even putting the item in his cart and I can quickly use it for whatever product i want to limit purchases of.

Link to comment
Share on other sites

OOPs I spoke too soon. This does not work. Of course if I put it in checkout process, then all the products get bumped. I just have a few that can't be purchased more than once. On the product description it bumps the client even if the product has never been purchased.

Any ideas? What do I need to do. This is sooooooo easy and quick and flexible, I hope there is a way to make it work. If I have to I suppose I could put it in checkout, but then ALL products get bumped not just the ones I need to restrict.

 

 

HELP PLEASE.......

Link to comment
Share on other sites

I have come across a few max errors on my website using the OS-Commerce Online Merchant v2.3.1.

I have had users notifing me that they were unable to get on to the website because of this error.

It would usually take the night to correct/reset the problem. (I am assuming that it is the 8 hour default).

The errors refer to a max queries over 75,000/hr.

I have contacted my webhost provider and recieved a few replies:

**************

Reply 1:

a) We have noticed that the MySQL query limits for your account have been exceeded. Hence, you have received intermittent errors with the working of your website.

 

To know more about the MySQL query limits; we would request you to please refer the articles mentioned below:

MySQL connections and query limits

A query limit is the maximum number of database actions performed in one hour by a specific user. Note that a user can have multiple concurrent MySQL connections, in which case the sum of all database actions for all connections cannot exceed the given limit.

•The maximum number of concurrent MySQL connections per user is 10.

•The maximum number of database queries per user is 75,000/hr.

 

B) We would further like you to know that we support a maximum number of database queries per user as 75,000/hr; however, as the MySQL database has exceeded the relevant limits; you have received errors.

 

We would request you to please optimize the database as well as the scripts from your end and then re-check the website functionality.

**************

Reply 2

Currently your website is loading with following error:

 

Warning: mysql_connect() [function.mysql-connect]: User dbname already has more than 'max_user_connections' active connections in database.php on line 19. Unable to connect to database server!

On our platform the maximum concurrent MySQL connections per DB user is 10. If you exceed the limit, you will not be able to connect the database. Too Many Connections can be caused by either a lot of simultaneous connections or by old connections not being released soon enough. There are some simple changes you can make to your PHP code and your MySQL settings to prevent both.

You can refer the URL:

http://www.thoughtlabs.com/2008/02/18/dealing-with-mysql-too-many-connections-error/ .

***************

 

I found the following function in the Database.php:

 

function tep_db_connect($server = DB_SERVER, $username = DB_SERVER_USERNAME, $password = DB_SERVER_PASSWORD, $database = DB_DATABASE, $link = 'db_link') {

global $$link;

if (USE_PCONNECT == 'true') {

$$link = mysql_pconnect($server, $username, $password);

} else {

$$link = mysql_connect($server, $username, $password);

}

if ($$link) mysql_select_db($database);

return $$link;

}

 

I am concern about just going in and changing code I know little or nothing about.

Could someone please help me fix this problem?

Link to comment
Share on other sites

Archived

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

×
×
  • Create New...