Zen Cart Logo
Forums / General Questions / Check last order by customer by time

Check last order by customer by time

Views: 602

Results 1 to 2 of 2
27 Sep 2013, 10:07 AM
#1
philip937 avatar

philip937

Totally Zenned

Join Date:
Aug 2009
Location:
Bedford, England
Posts:
968
Plugin Contributions:
0

Check last order by customer by time

I run a script in my order.php file which when an order is confirmed it pushes it through to my supplier to ship.

Once received our supplier will not cancel orders and this becomes a problem if the customer accidently makes two duplicate orders back to back.

As a fail safe I want to add something to my code which will stop it from sending the order through to the supplier if the customer has already placed an order in say the past 5-10 mins.

Can anyone advise what a good php test for this would be?

Phil Rogers
A problem shared is a problem solved.

27 Sep 2013, 4:09 PM
#2
philip937 avatar

philip937

Totally Zenned

Join Date:
Aug 2009
Location:
Bedford, England
Posts:
968
Plugin Contributions:
0

Re: Check last order by customer by time

for those interested here is what ive done
example:

$customid = '123';

$duplicatecheck = mysql_query('SELECT COUNT(orders_id) FROM orders WHERE date_purchased > now() - INTERVAL 5 MINUTE AND customers_id = \''.$customid.'\'');
$dupnum = mysql_fetch_array($duplicatecheck);
echo 'the count is: ' . $dupnum[0] . '</br></br />';

if ($dupnum[0] == 1) {
echo 'OK to send run code';
}

this will stop any orders place within 5 mins of each other being uploaded to my supplier.

Phil Rogers
A problem shared is a problem solved.