Magento2 Order Created by Admin or Customer The Next CEO of Stack OverflowHow to add custom customer attribute in custom tab in customer edit page of admin in magento2Magento2: How to add quick order optionMagento2: What is the trigger after order created in AdminGuest checkout, returning customer information from orderOrder from customer or admin?Magento 2: Add custom tab to order details page in customer accountSend email to admin after order cancellation by customer in front end magento2REST API Steps for creating order as created by Magento AdminMagento2: How to stop sending customer welcome email when order created using magento rest api?Add additional Fee on Order page

Purpose of level-shifter with same in and out voltages

Players Circumventing the limitations of Wish

Are the names of these months realistic?

Why am I getting "Static method cannot be referenced from a non static context: String String.valueOf(Object)"?

Defamation due to breach of confidentiality

Which Pokemon have a special animation when running with them out of their pokeball?

Can I calculate next year's exemptions based on this year's refund/amount owed?

Vector calculus integration identity problem

Is it correct to say moon starry nights?

What difference does it make using sed with/without whitespaces?

Computationally populating tables with probability data

Why don't programming languages automatically manage the synchronous/asynchronous problem?

Is it OK to decorate a log book cover?

Physiological effects of huge anime eyes

how one can write a nice vector parser, something that does pgfvecparseA=B-C; D=E x F;

Do I need to write [sic] when including a quotation with a number less than 10 that isn't written out?

Help understanding this unsettling image of Titan, Epimetheus, and Saturn's rings?

Spaces in which all closed sets are regular closed

Raspberry pi 3 B with Ubuntu 18.04 server arm64: what chip

Is dried pee considered dirt?

It is correct to match light sources with the same color temperature?

From jafe to El-Guest

What happened in Rome, when the western empire "fell"?

Is there a difference between "Fahrstuhl" and "Aufzug"?



Magento2 Order Created by Admin or Customer



The Next CEO of Stack OverflowHow to add custom customer attribute in custom tab in customer edit page of admin in magento2Magento2: How to add quick order optionMagento2: What is the trigger after order created in AdminGuest checkout, returning customer information from orderOrder from customer or admin?Magento 2: Add custom tab to order details page in customer accountSend email to admin after order cancellation by customer in front end magento2REST API Steps for creating order as created by Magento AdminMagento2: How to stop sending customer welcome email when order created using magento rest api?Add additional Fee on Order page










3















I want to check whether an order is created by an Admin or by the customer.










share|improve this question
























  • specify your requirement into detail, what you are looking?

    – Dhiren Vasoya
    Mar 1 at 10:59















3















I want to check whether an order is created by an Admin or by the customer.










share|improve this question
























  • specify your requirement into detail, what you are looking?

    – Dhiren Vasoya
    Mar 1 at 10:59













3












3








3








I want to check whether an order is created by an Admin or by the customer.










share|improve this question
















I want to check whether an order is created by an Admin or by the customer.







magento2 magento-2.1 sales-order magento2.3






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited 2 days ago









Rakesh Donga

2,258316




2,258316










asked Mar 1 at 10:57









Avesh NaikAvesh Naik

390112




390112












  • specify your requirement into detail, what you are looking?

    – Dhiren Vasoya
    Mar 1 at 10:59

















  • specify your requirement into detail, what you are looking?

    – Dhiren Vasoya
    Mar 1 at 10:59
















specify your requirement into detail, what you are looking?

– Dhiren Vasoya
Mar 1 at 10:59





specify your requirement into detail, what you are looking?

– Dhiren Vasoya
Mar 1 at 10:59










3 Answers
3






active

oldest

votes


















3














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



if(!empty($order->getRemoteIp())
//place customer

else
// place by admin






share|improve this answer

























  • I will try this and let you know if it works.

    – Avesh Naik
    Mar 1 at 11:08











  • Thank you for the solution.

    – Avesh Naik
    Mar 1 at 12:03











  • my pleasure:)..

    – Rakesh Donga
    Mar 1 at 12:04


















1














Try this,



<?php 
namespace VendorModuleControllerOrders;
class ReadOrders extends MagentoFrameworkAppActionAction

public function __construct(
MagentoFrameworkAppActionContext $context,
MagentoSalesApiOrderRepositoryInterface $orderRepo
)
$this->orderRepo = $orderRepo;
parent::__construct($context);


public function execute()

$orderPlaced = '';
$entity_id = '12';
$order = $this->orderRepo->get($entity_id);
$orderPlaced = $order->getRemoteIp();
if ($orderPlaced)
echo "Placed by Customer";
else
echo "Placed by Admin";




Hope this helps :)






share|improve this answer
































    0














    You can log this with observers. Just use the sales_order_place_after event within the etc/adminhtml directory inside the events.xml to log that an order has been created by an admin. You can do this for every area.
    More about areas Here.



    Example of the events.xml



    <?xml version="1.0"?>
    <config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Event/etc/events.xsd">
    <event name="sales_order_place_after">
    <observer name="My_observer_name" instance="VendorNameSpaceObserverLogOrderAdmin"/>
    </event>
    </config>


    I suggest you create an extra order field via a InstallSchema where you can log this to.






    share|improve this answer























    • I will try both ans.

      – Avesh Naik
      Mar 1 at 11:15











    Your Answer








    StackExchange.ready(function()
    var channelOptions =
    tags: "".split(" "),
    id: "479"
    ;
    initTagRenderer("".split(" "), "".split(" "), channelOptions);

    StackExchange.using("externalEditor", function()
    // Have to fire editor after snippets, if snippets enabled
    if (StackExchange.settings.snippets.snippetsEnabled)
    StackExchange.using("snippets", function()
    createEditor();
    );

    else
    createEditor();

    );

    function createEditor()
    StackExchange.prepareEditor(
    heartbeatType: 'answer',
    autoActivateHeartbeat: false,
    convertImagesToLinks: false,
    noModals: true,
    showLowRepImageUploadWarning: true,
    reputationToPostImages: null,
    bindNavPrevention: true,
    postfix: "",
    imageUploader:
    brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
    contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
    allowUrls: true
    ,
    onDemand: true,
    discardSelector: ".discard-answer"
    ,immediatelyShowMarkdownHelp:true
    );



    );













    draft saved

    draft discarded


















    StackExchange.ready(
    function ()
    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmagento.stackexchange.com%2fquestions%2f264038%2fmagento2-order-created-by-admin-or-customer%23new-answer', 'question_page');

    );

    Post as a guest















    Required, but never shown

























    3 Answers
    3






    active

    oldest

    votes








    3 Answers
    3






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes









    3














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



    if(!empty($order->getRemoteIp())
    //place customer

    else
    // place by admin






    share|improve this answer

























    • I will try this and let you know if it works.

      – Avesh Naik
      Mar 1 at 11:08











    • Thank you for the solution.

      – Avesh Naik
      Mar 1 at 12:03











    • my pleasure:)..

      – Rakesh Donga
      Mar 1 at 12:04















    3














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



    if(!empty($order->getRemoteIp())
    //place customer

    else
    // place by admin






    share|improve this answer

























    • I will try this and let you know if it works.

      – Avesh Naik
      Mar 1 at 11:08











    • Thank you for the solution.

      – Avesh Naik
      Mar 1 at 12:03











    • my pleasure:)..

      – Rakesh Donga
      Mar 1 at 12:04













    3












    3








    3







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



    if(!empty($order->getRemoteIp())
    //place customer

    else
    // place by admin






    share|improve this answer















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



    if(!empty($order->getRemoteIp())
    //place customer

    else
    // place by admin







    share|improve this answer














    share|improve this answer



    share|improve this answer








    edited Mar 27 at 8:28

























    answered Mar 1 at 11:07









    Rakesh DongaRakesh Donga

    2,258316




    2,258316












    • I will try this and let you know if it works.

      – Avesh Naik
      Mar 1 at 11:08











    • Thank you for the solution.

      – Avesh Naik
      Mar 1 at 12:03











    • my pleasure:)..

      – Rakesh Donga
      Mar 1 at 12:04

















    • I will try this and let you know if it works.

      – Avesh Naik
      Mar 1 at 11:08











    • Thank you for the solution.

      – Avesh Naik
      Mar 1 at 12:03











    • my pleasure:)..

      – Rakesh Donga
      Mar 1 at 12:04
















    I will try this and let you know if it works.

    – Avesh Naik
    Mar 1 at 11:08





    I will try this and let you know if it works.

    – Avesh Naik
    Mar 1 at 11:08













    Thank you for the solution.

    – Avesh Naik
    Mar 1 at 12:03





    Thank you for the solution.

    – Avesh Naik
    Mar 1 at 12:03













    my pleasure:)..

    – Rakesh Donga
    Mar 1 at 12:04





    my pleasure:)..

    – Rakesh Donga
    Mar 1 at 12:04













    1














    Try this,



    <?php 
    namespace VendorModuleControllerOrders;
    class ReadOrders extends MagentoFrameworkAppActionAction

    public function __construct(
    MagentoFrameworkAppActionContext $context,
    MagentoSalesApiOrderRepositoryInterface $orderRepo
    )
    $this->orderRepo = $orderRepo;
    parent::__construct($context);


    public function execute()

    $orderPlaced = '';
    $entity_id = '12';
    $order = $this->orderRepo->get($entity_id);
    $orderPlaced = $order->getRemoteIp();
    if ($orderPlaced)
    echo "Placed by Customer";
    else
    echo "Placed by Admin";




    Hope this helps :)






    share|improve this answer





























      1














      Try this,



      <?php 
      namespace VendorModuleControllerOrders;
      class ReadOrders extends MagentoFrameworkAppActionAction

      public function __construct(
      MagentoFrameworkAppActionContext $context,
      MagentoSalesApiOrderRepositoryInterface $orderRepo
      )
      $this->orderRepo = $orderRepo;
      parent::__construct($context);


      public function execute()

      $orderPlaced = '';
      $entity_id = '12';
      $order = $this->orderRepo->get($entity_id);
      $orderPlaced = $order->getRemoteIp();
      if ($orderPlaced)
      echo "Placed by Customer";
      else
      echo "Placed by Admin";




      Hope this helps :)






      share|improve this answer



























        1












        1








        1







        Try this,



        <?php 
        namespace VendorModuleControllerOrders;
        class ReadOrders extends MagentoFrameworkAppActionAction

        public function __construct(
        MagentoFrameworkAppActionContext $context,
        MagentoSalesApiOrderRepositoryInterface $orderRepo
        )
        $this->orderRepo = $orderRepo;
        parent::__construct($context);


        public function execute()

        $orderPlaced = '';
        $entity_id = '12';
        $order = $this->orderRepo->get($entity_id);
        $orderPlaced = $order->getRemoteIp();
        if ($orderPlaced)
        echo "Placed by Customer";
        else
        echo "Placed by Admin";




        Hope this helps :)






        share|improve this answer















        Try this,



        <?php 
        namespace VendorModuleControllerOrders;
        class ReadOrders extends MagentoFrameworkAppActionAction

        public function __construct(
        MagentoFrameworkAppActionContext $context,
        MagentoSalesApiOrderRepositoryInterface $orderRepo
        )
        $this->orderRepo = $orderRepo;
        parent::__construct($context);


        public function execute()

        $orderPlaced = '';
        $entity_id = '12';
        $order = $this->orderRepo->get($entity_id);
        $orderPlaced = $order->getRemoteIp();
        if ($orderPlaced)
        echo "Placed by Customer";
        else
        echo "Placed by Admin";




        Hope this helps :)







        share|improve this answer














        share|improve this answer



        share|improve this answer








        edited Mar 2 at 3:44

























        answered Mar 1 at 11:19









        Prathap GunasekaranPrathap Gunasekaran

        1,5761618




        1,5761618





















            0














            You can log this with observers. Just use the sales_order_place_after event within the etc/adminhtml directory inside the events.xml to log that an order has been created by an admin. You can do this for every area.
            More about areas Here.



            Example of the events.xml



            <?xml version="1.0"?>
            <config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Event/etc/events.xsd">
            <event name="sales_order_place_after">
            <observer name="My_observer_name" instance="VendorNameSpaceObserverLogOrderAdmin"/>
            </event>
            </config>


            I suggest you create an extra order field via a InstallSchema where you can log this to.






            share|improve this answer























            • I will try both ans.

              – Avesh Naik
              Mar 1 at 11:15















            0














            You can log this with observers. Just use the sales_order_place_after event within the etc/adminhtml directory inside the events.xml to log that an order has been created by an admin. You can do this for every area.
            More about areas Here.



            Example of the events.xml



            <?xml version="1.0"?>
            <config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Event/etc/events.xsd">
            <event name="sales_order_place_after">
            <observer name="My_observer_name" instance="VendorNameSpaceObserverLogOrderAdmin"/>
            </event>
            </config>


            I suggest you create an extra order field via a InstallSchema where you can log this to.






            share|improve this answer























            • I will try both ans.

              – Avesh Naik
              Mar 1 at 11:15













            0












            0








            0







            You can log this with observers. Just use the sales_order_place_after event within the etc/adminhtml directory inside the events.xml to log that an order has been created by an admin. You can do this for every area.
            More about areas Here.



            Example of the events.xml



            <?xml version="1.0"?>
            <config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Event/etc/events.xsd">
            <event name="sales_order_place_after">
            <observer name="My_observer_name" instance="VendorNameSpaceObserverLogOrderAdmin"/>
            </event>
            </config>


            I suggest you create an extra order field via a InstallSchema where you can log this to.






            share|improve this answer













            You can log this with observers. Just use the sales_order_place_after event within the etc/adminhtml directory inside the events.xml to log that an order has been created by an admin. You can do this for every area.
            More about areas Here.



            Example of the events.xml



            <?xml version="1.0"?>
            <config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Event/etc/events.xsd">
            <event name="sales_order_place_after">
            <observer name="My_observer_name" instance="VendorNameSpaceObserverLogOrderAdmin"/>
            </event>
            </config>


            I suggest you create an extra order field via a InstallSchema where you can log this to.







            share|improve this answer












            share|improve this answer



            share|improve this answer










            answered Mar 1 at 11:09









            CompactCodeCompactCode

            1,582625




            1,582625












            • I will try both ans.

              – Avesh Naik
              Mar 1 at 11:15

















            • I will try both ans.

              – Avesh Naik
              Mar 1 at 11:15
















            I will try both ans.

            – Avesh Naik
            Mar 1 at 11:15





            I will try both ans.

            – Avesh Naik
            Mar 1 at 11:15

















            draft saved

            draft discarded
















































            Thanks for contributing an answer to Magento Stack Exchange!


            • Please be sure to answer the question. Provide details and share your research!

            But avoid


            • Asking for help, clarification, or responding to other answers.

            • Making statements based on opinion; back them up with references or personal experience.

            To learn more, see our tips on writing great answers.




            draft saved


            draft discarded














            StackExchange.ready(
            function ()
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmagento.stackexchange.com%2fquestions%2f264038%2fmagento2-order-created-by-admin-or-customer%23new-answer', 'question_page');

            );

            Post as a guest















            Required, but never shown





















































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown

































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown







            Popular posts from this blog

            Sum ergo cogito? 1 nng

            三茅街道4182Guuntc Dn precexpngmageondP