Magento 2 - How to stop order success email programatically

The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP





.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty margin-bottom:0;







up vote
1
down vote

favorite












I am creating a order programatically in magento 2. What property I need to set on $order object so order success email will not trigger. I have tried below methods with (bool) false, parameter but no succes.



$order->setCanSendNewEmailFlag(false);
$order->setEmailSent(false);
$order->setSendEmail(false);









share|improve this question



















  • 1




    See here magento.stackexchange.com/questions/102992/…
    – Mohamed El Mrabet
    Sep 8 at 10:35
















up vote
1
down vote

favorite












I am creating a order programatically in magento 2. What property I need to set on $order object so order success email will not trigger. I have tried below methods with (bool) false, parameter but no succes.



$order->setCanSendNewEmailFlag(false);
$order->setEmailSent(false);
$order->setSendEmail(false);









share|improve this question



















  • 1




    See here magento.stackexchange.com/questions/102992/…
    – Mohamed El Mrabet
    Sep 8 at 10:35












up vote
1
down vote

favorite









up vote
1
down vote

favorite











I am creating a order programatically in magento 2. What property I need to set on $order object so order success email will not trigger. I have tried below methods with (bool) false, parameter but no succes.



$order->setCanSendNewEmailFlag(false);
$order->setEmailSent(false);
$order->setSendEmail(false);









share|improve this question















I am creating a order programatically in magento 2. What property I need to set on $order object so order success email will not trigger. I have tried below methods with (bool) false, parameter but no succes.



$order->setCanSendNewEmailFlag(false);
$order->setEmailSent(false);
$order->setSendEmail(false);






magento2 order-email






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Sep 8 at 9:31









Teja Bhagavan Kollepara

1




1










asked Sep 8 at 9:29









kapil yadav

10414




10414







  • 1




    See here magento.stackexchange.com/questions/102992/…
    – Mohamed El Mrabet
    Sep 8 at 10:35












  • 1




    See here magento.stackexchange.com/questions/102992/…
    – Mohamed El Mrabet
    Sep 8 at 10:35







1




1




See here magento.stackexchange.com/questions/102992/…
– Mohamed El Mrabet
Sep 8 at 10:35




See here magento.stackexchange.com/questions/102992/…
– Mohamed El Mrabet
Sep 8 at 10:35










2 Answers
2






active

oldest

votes

















up vote
2
down vote













You can do that by overiding the



send(Order $order, $forceSyncMode = false)


In



vendor/magento/module-sales/Model/Order/Email/Sender/OrderSender.php





share|improve this answer





























    up vote
    1
    down vote













    You can see here at below path :




    vendor/magento/module-sales/Model/Order/Email/Sender/OrderSender.php




    You can override this public function send(Order $order, $forceSyncMode = false) function



    Or



    You can set from admin (It's better) to disable it instead of programmatically :



    Admin -> Stores -> Configuration -> Sales -> Sales Email -> Order -> Enabled


    Hope, It will helpful for you.






    share|improve this answer




















    • I need to do that for a specific order that I am creating programatically. It will disable for all orders, that's something not required here.
      – kapil yadav
      Sep 8 at 11:25










    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',
    convertImagesToLinks: false,
    noModals: false,
    showLowRepImageUploadWarning: true,
    reputationToPostImages: null,
    bindNavPrevention: true,
    postfix: "",
    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%2f241412%2fmagento-2-how-to-stop-order-success-email-programatically%23new-answer', 'question_page');

    );

    Post as a guest






























    2 Answers
    2






    active

    oldest

    votes








    2 Answers
    2






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes








    up vote
    2
    down vote













    You can do that by overiding the



    send(Order $order, $forceSyncMode = false)


    In



    vendor/magento/module-sales/Model/Order/Email/Sender/OrderSender.php





    share|improve this answer


























      up vote
      2
      down vote













      You can do that by overiding the



      send(Order $order, $forceSyncMode = false)


      In



      vendor/magento/module-sales/Model/Order/Email/Sender/OrderSender.php





      share|improve this answer
























        up vote
        2
        down vote










        up vote
        2
        down vote









        You can do that by overiding the



        send(Order $order, $forceSyncMode = false)


        In



        vendor/magento/module-sales/Model/Order/Email/Sender/OrderSender.php





        share|improve this answer














        You can do that by overiding the



        send(Order $order, $forceSyncMode = false)


        In



        vendor/magento/module-sales/Model/Order/Email/Sender/OrderSender.php






        share|improve this answer














        share|improve this answer



        share|improve this answer








        edited Sep 8 at 11:23









        Mohamed El Mrabet

        693417




        693417










        answered Sep 8 at 10:35









        Lara Gento

        293




        293






















            up vote
            1
            down vote













            You can see here at below path :




            vendor/magento/module-sales/Model/Order/Email/Sender/OrderSender.php




            You can override this public function send(Order $order, $forceSyncMode = false) function



            Or



            You can set from admin (It's better) to disable it instead of programmatically :



            Admin -> Stores -> Configuration -> Sales -> Sales Email -> Order -> Enabled


            Hope, It will helpful for you.






            share|improve this answer




















            • I need to do that for a specific order that I am creating programatically. It will disable for all orders, that's something not required here.
              – kapil yadav
              Sep 8 at 11:25














            up vote
            1
            down vote













            You can see here at below path :




            vendor/magento/module-sales/Model/Order/Email/Sender/OrderSender.php




            You can override this public function send(Order $order, $forceSyncMode = false) function



            Or



            You can set from admin (It's better) to disable it instead of programmatically :



            Admin -> Stores -> Configuration -> Sales -> Sales Email -> Order -> Enabled


            Hope, It will helpful for you.






            share|improve this answer




















            • I need to do that for a specific order that I am creating programatically. It will disable for all orders, that's something not required here.
              – kapil yadav
              Sep 8 at 11:25












            up vote
            1
            down vote










            up vote
            1
            down vote









            You can see here at below path :




            vendor/magento/module-sales/Model/Order/Email/Sender/OrderSender.php




            You can override this public function send(Order $order, $forceSyncMode = false) function



            Or



            You can set from admin (It's better) to disable it instead of programmatically :



            Admin -> Stores -> Configuration -> Sales -> Sales Email -> Order -> Enabled


            Hope, It will helpful for you.






            share|improve this answer












            You can see here at below path :




            vendor/magento/module-sales/Model/Order/Email/Sender/OrderSender.php




            You can override this public function send(Order $order, $forceSyncMode = false) function



            Or



            You can set from admin (It's better) to disable it instead of programmatically :



            Admin -> Stores -> Configuration -> Sales -> Sales Email -> Order -> Enabled


            Hope, It will helpful for you.







            share|improve this answer












            share|improve this answer



            share|improve this answer










            answered Sep 8 at 10:52









            Rohan Hapani

            3,66821457




            3,66821457











            • I need to do that for a specific order that I am creating programatically. It will disable for all orders, that's something not required here.
              – kapil yadav
              Sep 8 at 11:25
















            • I need to do that for a specific order that I am creating programatically. It will disable for all orders, that's something not required here.
              – kapil yadav
              Sep 8 at 11:25















            I need to do that for a specific order that I am creating programatically. It will disable for all orders, that's something not required here.
            – kapil yadav
            Sep 8 at 11:25




            I need to do that for a specific order that I am creating programatically. It will disable for all orders, that's something not required here.
            – kapil yadav
            Sep 8 at 11:25

















             

            draft saved


            draft discarded















































             


            draft saved


            draft discarded














            StackExchange.ready(
            function ()
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmagento.stackexchange.com%2fquestions%2f241412%2fmagento-2-how-to-stop-order-success-email-programatically%23new-answer', 'question_page');

            );

            Post as a guest













































































            Popular posts from this blog

            How to check contact read email or not when send email to Individual?

            Bahrain

            Postfix configuration issue with fips on centos 7; mailgun relay