Differentiating Backend vs. Frontend Purchases in Magento

前端 未结 3 2023
清酒与你
清酒与你 2021-01-05 06:43

Is there a way to tell if an order was placed through the frontend of the web site or entered through the administrative panel?

相关标签:
3条回答
  • 2021-01-05 06:57

    By default, Magento only stores the remote_ip in table sales_flat_order for an order that is place by customer (while admin order is set to null).

    So try this:

    if(!empty($order->getRemoteIp()){
      //place online
    }
    else{
      // place by admin
    }
    

    See Programmatically differentiate between admin & customer-placed orders

    0 讨论(0)
  • 2021-01-05 07:03

    You can check the is_super_mode value (I have only check on the quote : $quote->getIsSuperMode())

    0 讨论(0)
  • 2021-01-05 07:09

    Every order has a store_id, when entered through administraction it will either be 0 (for 'admin' store) or null.

    if ($order->getStoreId()) {
        // was placed via frontend
    }
    

    Don't use getStore() as that won't always return the admin store object reliably.

    Does not work with latest versions of Magento. (see comment)

    0 讨论(0)
提交回复
热议问题