Answer the question
In order to leave comments, you need to log in
How to display the last viewed products in the online store?
Tell me the algorithm or describe the procedure for displaying the last viewed products.
I implemented it in the following way:
1) when the user gets to the product-view page (product description page). I write to the product id array and save it in a cookie . Then I check if the number of array elements does not exceed a given number (for example: show only the last 20 products), if more, I delete the last element.
2) I form a string for the SQL query where product.id in (id1, id2...) from the id array , which is stored in the cookie . And the last step is displaying the last item.
In my implementation, the order in which the product is viewed is not preserved. That is, where id (3, 2, 5) will return 2, 3, 5 at the beginning
Answer the question
In order to leave comments, you need to log in
when the user lands on the product-view page (product description page). I write to the product id array and save it in a cookie.
The move is correct.
Save the viewing date as well. Date('H:i:s'). And then sort by it.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question