1

How to identify order is placed from frontend or rest API ?

when we are trying to area code from any event after order placed

$this->_checkState->getAreaCode()

then we are getting always area code is "webapi_rest"

it must be frontend.

If checkout placed order is using REST API then how to identify order placed is from frontend or rest API or any other medium?

2

1 Answer 1

0

Since Magento checkout page uses rest API thatswhy its giving you result like this.

try getting current layout like this

    public function __construct(
    ...
    \Magento\Framework\App\Request\Http $request
) {
    ...
    $this->_request = $request;
}

public function yourFunctionName()
{
    $handle = $this->_request->getFullActionName();
    ....
}

if it returns something like checkout_index_index then the order is from theme else API

let me know if you face any problem.

2
  • ok checking and let you know Commented Jul 22, 2020 at 11:02
  • when i use this code i am getting this "__" Commented Jul 22, 2020 at 11:40

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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