I want to accept customer who purchases can fill on review form. If a customer doesn't buy it, it'll show a notification that you must buy it before writing review. Can you help me how to work? Thanks.


I can give you a brief idea.

You would need to put condition in the review form.

Put below conditions before code:

  • Whether a customer is logged in or not
  • If customer is logged in, then check whether customer has ordered the same product SKU or not.

Please let me know if you have any query.

Update: To check whether customer is logged in or not, try below code:

$objectManager = \Magento\Framework\App\ObjectManager::getInstance();
$customerSession = $objectManager->get('Magento\Customer\Model\Session');
if($customerSession->isLoggedIn()) {
   // customer login action

For getting order from customer id, please follow below link:

How to get order from customer Magento 2?

  • Can you tell me, how to work it. I have a form, but I don't know to check customer. If you have any sample code, that's great. Thanks – Marine Jul 14 '17 at 4:46

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.