zen-cart

How can I determine if a Zen Cart customer is logged is as admin in checkout?


I need to find out if a customer (during checkout) is also currently logged in as a Zen Cart administrator. The purpose is for allowing certain actions to be available for an administrator placing an order on behalf of a customer (say, by telephone).

My first idea was to check $_SESSION['admin_id'].

However this does not seem to be set, instead $_SESSION['customer_id'] is.

I think this is because different session names are chosen in the admin and customer areas (zenAdminId vs zenid).

How can I find out if this customer would be logged in as an admin, had they been in the admin area at the same time?

I am working on the checkout step prior to sending off to a hosted payment service provider.

Edit: the merchant is logged in as an admin and is entering the customer's details, which are different to those of the admin account, into the checkout screens. It is a customer-not-present/MOTO setup.


Solution

  • You are correct - $_SESSION['customer_id'] is set. And there's nothing in the customer's table which indicates if this person is an admin. However, if they use the same email address for their customer account and for their admin account, you can look up their email in the customers table with $_SESSION['customer_id'], then match that against the admin_email field in the emails in Use this to look up table "admin."