How can i get current user purchase history in opencart 2.0.3.1?
I want the reviews to be given only by the users who has purchased the product, i could not find any free extension for it so would like to write the code manually.
Thank you.
If you know a little PHP/MySQL, you can easily do this with querying "order" table. The algorithm is simple: take current customer's ID (CUSTOMER_ID) and look for it in "order" table, when customer browses product with certain PRODUCT_ID (visits its page):
SELECT COUNT(order_id) as total FROM order WHERE customer_id = CUSTOMER_ID AND product_id = PRODUCT_ID
If "total" is more than zero, display review form. Otherwise, hide it.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.