How to know Order is placed from authenticated customer or guest In salesforce commerce cloud?

275 Views Asked by At

Hello I am new to salesforce commerce cloud and I am working on controller version of SFCC that is SGJC version. I wanted to know is there is any method or how will we know whether customer who has placed the order has placed as guest or as autheticated customer. I want to write a if else redirection logic. If placed order is from guest redirect to A.isml else redirect to B.isml. Any method from orderMgr class will be helpful.

2

There are 2 best solutions below

0
On

You can try to use:

var order = OrderMgr.getOrder(orderNo);
var registered = order.getCustomer().isRegistered();

From the docs

There is also a difference between Registered and Authenticated customer. An Authenticated customer is a registered customer that is also logged, with an active authenticated session.

To check if the customer is authenticated you can use isAuthenticated() method instead of isRegistrered()

0
On

You can try the code same as below:

    var order = OrderMgr.getOrder(orderNo);

    if (!empty(order) && empty(order.getCustomerNo()) {
       // Redirect to A.isml
    }

    if (!empty(order) && !empty(order.getCustomerNo()) {
       // Redirect to B.isml
    }

Ref docs.