Jump to content

Display a status image according to the time an order has been placed


lpfernandes

Recommended Posts

Hi

I'm trying to create a new page where customer can enter their order id and see at what stage their order is. The page needs to have a little script that reads the time the order was placed from the database and compare that to the current time.
According to difference of the time that has passed a different image will be displayed.
I have used the code from a previous post to retrieve the database query

$result = Db::getInstance()->executeS('SELECT * FROM `'._DB_PREFIX_.'table'); 
$smarty->assign('table', $result); 



What need help is how to create the little script on the .tpl file that compares the order time to the current time.

Thanks

Link to comment
Share on other sites

PrestaShop's order history page already lists a customer's orders by ID and lets you see the status of the order. Can't you just compare the dates on that page and add an image there? For example, in the foreach loop in history.tpl, you could use the following to get the number of seconds since the order was made:

{math assign=timediff equation='a - b' a=$smarty.now b=$order.date_add|strtotime}



You could use {$timediff} to determine which image is displayed.

Link to comment
Share on other sites

I would really would like to have a spearate page where the customer can go an type the order number and get a status image according to how long was the order placed. The reason for this is the shop is a food take away restaurant and that way customers can see how long is going to take to get their food.

Thanks

Link to comment
Share on other sites

Doing that would require writing a custom PHP file that displays a text field, processes the input, then performs an SQL query on the ps_orders table to get the date_add, then calculates the difference and displays an image. It's too big for me to do and post here.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...