Zen Cart Logo
Forums / Code Collaboration / Check to see if current customer purchased specific product.

Check to see if current customer purchased specific product.

Views: 1,913

Results 1 to 3 of 3
21 Jan 2016, 5:35 PM
#1
camerondied avatar

camerondied

New Zenner

Join Date:
May 2006
Posts:
15
Plugin Contributions:
0

Check to see if current customer purchased specific product.

Hello.. hopefully someone can help me.. I'm trying to write a code where it's like

if $_SESSION['customer_id'] purchased product ='123' echo 'HTML'

basically I want to display a specific message to customers who have purchase specific products on who they should contact/what they should do next. Thanks in advance!

21 Jan 2016, 5:53 PM
#2
mc12345678 avatar

mc12345678

Totally Zenned

Join Date:
Jul 2012
Posts:
16,908
Plugin Contributions:
2

Re: Check to see if current customer purchased specific product.

camerondied:

Hello.. hopefully someone can help me.. I'm trying to write a code where it's like

if $_SESSION['customer_id'] purchased product ='123' echo 'HTML'

basically I want to display a specific message to customers who have purchase specific products on who they should contact/what they should do next. Thanks in advance!

Tables orders and orders_products are tables you want to reference/use. Orders has the customers_id and an orders_id in it, while orders_products has the matching orders_id and then the products_id(s) associated with the order. So thinking you would want to do a sql query on the set of tables and depending on how many such searches you want to do you could either focus the query or leave it open. Focussed would be to ask the sql server to look for the customer to have purchased the specific product id, a little left open would be to obtain a list of all products_ids that the customer has purchased... Wide open would be to just pull all order history. :)

if you do a specific search, then if there is a response (RecordCount() > 0), and/or not at the End Of File (EOF) then the product was previously purchased and to take an action...

21 Jan 2016, 6:07 PM
#3
camerondied avatar

camerondied

New Zenner

Join Date:
May 2006
Posts:
15
Plugin Contributions:
0

Re: Check to see if current customer purchased specific product.

I just work with CSS.. i'm not a very good programmer.. can you or someone help me writing this code.. I can pay money for your time. Thanks :)