get Coupon Code in beforePlaceOrderGet sales by coupon codemain.CRITICAL: Plugin class doesn't existWhy Getting categories and names on product view page Magento 2 fails?After rewrite MagentoCustomerModelAccountManagement giving me fatal errorMonolog Error After 2.2 UpgradeMagento 2 get custom attribute of a single product inside a pluginMagento 2 plugin change price of products that have a custom attribute withOn what basis we need to pass the plugin parameters?how we know what should be pass?what's logic behind it?Error Database Magento 2.3 migration from localhost to serverHow implement form in payment method

How did they film the Invisible Man being invisible, in 1933?

How can a valley surrounded by mountains be fertile and rainy?

Who voices the character "Finger" in The Fifth Element?

"sort -nu" on uuids

Do home values typically rise and fall at a consistent percent?

Converting Geographic Coordinates into Lambert2008 coordinates

Should 私の be omitted?

Does a return economy-class seat between London and San Francisco release 5.28 tonnes of CO2 equivalents?

I hit a pipe with a mower and now it won't turn

How can I tell what kind of genitals people have without gender?

Why did NASA wet the road in front of the Space Shuttle crawler?

How does the Divination wizard's Expert Divination feature work when you upcast a divination spell?

The warming up game

Why is Japan trying to have a better relationship with Iran?

Reusable spacecraft: why still have fairings detach, instead of open/close?

Can European countries bypass the EU and make their own individual trade deal with the U.S.?

What verb for taking advantage fits in "I don't want to ________ on the friendship"?

Can a nowhere continuous function have a connected graph?

How could a satellite follow earth around the sun while staying outside of earth's orbit?

Thin wall to block LED light from hitting photodiode?

Movie with Zoltar in a trailer park named Paradise and a boy playing a video game then being recruited by aliens to fight in space

I need help with pasta

How did Lefschetz do mathematics without hands?

Could this problem be tackled using Mathematica?



get Coupon Code in beforePlaceOrder


Get sales by coupon codemain.CRITICAL: Plugin class doesn't existWhy Getting categories and names on product view page Magento 2 fails?After rewrite MagentoCustomerModelAccountManagement giving me fatal errorMonolog Error After 2.2 UpgradeMagento 2 get custom attribute of a single product inside a pluginMagento 2 plugin change price of products that have a custom attribute withOn what basis we need to pass the plugin parameters?how we know what should be pass?what's logic behind it?Error Database Magento 2.3 migration from localhost to serverHow implement form in payment method






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








2















Hello I want to get the coupon code in a plugin. My code is:



 private $logger;
private $checkoutSession;

public function __construct(
PsrLogLoggerInterface $logger,
MagentoCheckoutModelSession $checkoutSession
)
$this->logger = $logger;
$this->checkoutSession = $checkoutSession;

public function beforePlaceOrder(MagentoQuoteModelQuoteManagement $subject, $cartId, ?MagentoQuoteApiDataPaymentInterface $paymentMethod = null)
$this->logger->debug("Before Place Order");
$order = $this->checkoutSession->getLastRealOrder();
$orderId=$order->getEntityId();
$couponCode = $order->getCouponCode();
$this->logger->debug($couponCode);



But $couponCode is empty.



Can someone help me?



thank you in advance










share|improve this question







New contributor



vDrews is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.

























    2















    Hello I want to get the coupon code in a plugin. My code is:



     private $logger;
    private $checkoutSession;

    public function __construct(
    PsrLogLoggerInterface $logger,
    MagentoCheckoutModelSession $checkoutSession
    )
    $this->logger = $logger;
    $this->checkoutSession = $checkoutSession;

    public function beforePlaceOrder(MagentoQuoteModelQuoteManagement $subject, $cartId, ?MagentoQuoteApiDataPaymentInterface $paymentMethod = null)
    $this->logger->debug("Before Place Order");
    $order = $this->checkoutSession->getLastRealOrder();
    $orderId=$order->getEntityId();
    $couponCode = $order->getCouponCode();
    $this->logger->debug($couponCode);



    But $couponCode is empty.



    Can someone help me?



    thank you in advance










    share|improve this question







    New contributor



    vDrews is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
    Check out our Code of Conduct.





















      2












      2








      2


      1






      Hello I want to get the coupon code in a plugin. My code is:



       private $logger;
      private $checkoutSession;

      public function __construct(
      PsrLogLoggerInterface $logger,
      MagentoCheckoutModelSession $checkoutSession
      )
      $this->logger = $logger;
      $this->checkoutSession = $checkoutSession;

      public function beforePlaceOrder(MagentoQuoteModelQuoteManagement $subject, $cartId, ?MagentoQuoteApiDataPaymentInterface $paymentMethod = null)
      $this->logger->debug("Before Place Order");
      $order = $this->checkoutSession->getLastRealOrder();
      $orderId=$order->getEntityId();
      $couponCode = $order->getCouponCode();
      $this->logger->debug($couponCode);



      But $couponCode is empty.



      Can someone help me?



      thank you in advance










      share|improve this question







      New contributor



      vDrews is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.











      Hello I want to get the coupon code in a plugin. My code is:



       private $logger;
      private $checkoutSession;

      public function __construct(
      PsrLogLoggerInterface $logger,
      MagentoCheckoutModelSession $checkoutSession
      )
      $this->logger = $logger;
      $this->checkoutSession = $checkoutSession;

      public function beforePlaceOrder(MagentoQuoteModelQuoteManagement $subject, $cartId, ?MagentoQuoteApiDataPaymentInterface $paymentMethod = null)
      $this->logger->debug("Before Place Order");
      $order = $this->checkoutSession->getLastRealOrder();
      $orderId=$order->getEntityId();
      $couponCode = $order->getCouponCode();
      $this->logger->debug($couponCode);



      But $couponCode is empty.



      Can someone help me?



      thank you in advance







      magento2 plugin coupon-codes before-plugin






      share|improve this question







      New contributor



      vDrews is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.










      share|improve this question







      New contributor



      vDrews is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.








      share|improve this question




      share|improve this question






      New contributor



      vDrews is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.








      asked Jun 20 at 10:42









      vDrewsvDrews

      322 bronze badges




      322 bronze badges




      New contributor



      vDrews is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.




      New contributor




      vDrews is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.






















          1 Answer
          1






          active

          oldest

          votes


















          1














          You don't need use checkout session MagentoCheckoutModelSession.



          From MagentoQuoteModelQuoteManagement and MagentoQuoteApiCartRepositoryInterface can get coupon code .



           private $logger;
          private $quoteRepository;

          public function __construct(
          PsrLogLoggerInterface $logger,
          MagentoQuoteApiCartRepositoryInterface $quoteRepository
          )
          $this->logger = $logger;
          $this->quoteRepository = $quoteRepository;

          public function beforePlaceOrder(
          MagentoQuoteModelQuoteManagement $subject,
          $cartId,
          MagentoQuoteApiDataPaymentInterface $paymentMethod = null
          )
          $this->logger->debug("Before Place Order");
          $quote = $this->quoteRepository->getActive($cartId);

          if($quote->getId())
          $couponCode = $quote->getCouponCode();
          $this->logger->debug($couponCode);








          share|improve this answer

























          • thanks a lot! It works!

            – vDrews
            Jun 20 at 11:37













          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
          );



          );






          vDrews is a new contributor. Be nice, and check out our Code of Conduct.









          draft saved

          draft discarded


















          StackExchange.ready(
          function ()
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmagento.stackexchange.com%2fquestions%2f279011%2fget-coupon-code-in-beforeplaceorder%23new-answer', 'question_page');

          );

          Post as a guest















          Required, but never shown

























          1 Answer
          1






          active

          oldest

          votes








          1 Answer
          1






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes









          1














          You don't need use checkout session MagentoCheckoutModelSession.



          From MagentoQuoteModelQuoteManagement and MagentoQuoteApiCartRepositoryInterface can get coupon code .



           private $logger;
          private $quoteRepository;

          public function __construct(
          PsrLogLoggerInterface $logger,
          MagentoQuoteApiCartRepositoryInterface $quoteRepository
          )
          $this->logger = $logger;
          $this->quoteRepository = $quoteRepository;

          public function beforePlaceOrder(
          MagentoQuoteModelQuoteManagement $subject,
          $cartId,
          MagentoQuoteApiDataPaymentInterface $paymentMethod = null
          )
          $this->logger->debug("Before Place Order");
          $quote = $this->quoteRepository->getActive($cartId);

          if($quote->getId())
          $couponCode = $quote->getCouponCode();
          $this->logger->debug($couponCode);








          share|improve this answer

























          • thanks a lot! It works!

            – vDrews
            Jun 20 at 11:37















          1














          You don't need use checkout session MagentoCheckoutModelSession.



          From MagentoQuoteModelQuoteManagement and MagentoQuoteApiCartRepositoryInterface can get coupon code .



           private $logger;
          private $quoteRepository;

          public function __construct(
          PsrLogLoggerInterface $logger,
          MagentoQuoteApiCartRepositoryInterface $quoteRepository
          )
          $this->logger = $logger;
          $this->quoteRepository = $quoteRepository;

          public function beforePlaceOrder(
          MagentoQuoteModelQuoteManagement $subject,
          $cartId,
          MagentoQuoteApiDataPaymentInterface $paymentMethod = null
          )
          $this->logger->debug("Before Place Order");
          $quote = $this->quoteRepository->getActive($cartId);

          if($quote->getId())
          $couponCode = $quote->getCouponCode();
          $this->logger->debug($couponCode);








          share|improve this answer

























          • thanks a lot! It works!

            – vDrews
            Jun 20 at 11:37













          1












          1








          1







          You don't need use checkout session MagentoCheckoutModelSession.



          From MagentoQuoteModelQuoteManagement and MagentoQuoteApiCartRepositoryInterface can get coupon code .



           private $logger;
          private $quoteRepository;

          public function __construct(
          PsrLogLoggerInterface $logger,
          MagentoQuoteApiCartRepositoryInterface $quoteRepository
          )
          $this->logger = $logger;
          $this->quoteRepository = $quoteRepository;

          public function beforePlaceOrder(
          MagentoQuoteModelQuoteManagement $subject,
          $cartId,
          MagentoQuoteApiDataPaymentInterface $paymentMethod = null
          )
          $this->logger->debug("Before Place Order");
          $quote = $this->quoteRepository->getActive($cartId);

          if($quote->getId())
          $couponCode = $quote->getCouponCode();
          $this->logger->debug($couponCode);








          share|improve this answer















          You don't need use checkout session MagentoCheckoutModelSession.



          From MagentoQuoteModelQuoteManagement and MagentoQuoteApiCartRepositoryInterface can get coupon code .



           private $logger;
          private $quoteRepository;

          public function __construct(
          PsrLogLoggerInterface $logger,
          MagentoQuoteApiCartRepositoryInterface $quoteRepository
          )
          $this->logger = $logger;
          $this->quoteRepository = $quoteRepository;

          public function beforePlaceOrder(
          MagentoQuoteModelQuoteManagement $subject,
          $cartId,
          MagentoQuoteApiDataPaymentInterface $paymentMethod = null
          )
          $this->logger->debug("Before Place Order");
          $quote = $this->quoteRepository->getActive($cartId);

          if($quote->getId())
          $couponCode = $quote->getCouponCode();
          $this->logger->debug($couponCode);









          share|improve this answer














          share|improve this answer



          share|improve this answer








          edited Jun 20 at 11:21









          Rakesh Donga

          2,9456 silver badges21 bronze badges




          2,9456 silver badges21 bronze badges










          answered Jun 20 at 11:01









          Amit BeraAmit Bera

          61.6k16 gold badges84 silver badges183 bronze badges




          61.6k16 gold badges84 silver badges183 bronze badges












          • thanks a lot! It works!

            – vDrews
            Jun 20 at 11:37

















          • thanks a lot! It works!

            – vDrews
            Jun 20 at 11:37
















          thanks a lot! It works!

          – vDrews
          Jun 20 at 11:37





          thanks a lot! It works!

          – vDrews
          Jun 20 at 11:37










          vDrews is a new contributor. Be nice, and check out our Code of Conduct.









          draft saved

          draft discarded


















          vDrews is a new contributor. Be nice, and check out our Code of Conduct.












          vDrews is a new contributor. Be nice, and check out our Code of Conduct.











          vDrews is a new contributor. Be nice, and check out our Code of Conduct.














          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%2f279011%2fget-coupon-code-in-beforeplaceorder%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

          Get product attribute by attribute group code in magento 2get product attribute by product attribute group in magento 2Magento 2 Log Bundle Product Data in List Page?How to get all product attribute of a attribute group of Default attribute set?Magento 2.1 Create a filter in the product grid by new attributeMagento 2 : Get Product Attribute values By GroupMagento 2 How to get all existing values for one attributeMagento 2 get custom attribute of a single product inside a pluginMagento 2.3 How to get all the Multi Source Inventory (MSI) locations collection in custom module?Magento2: how to develop rest API to get new productsGet product attribute by attribute group code ( [attribute_group_code] ) in magento 2

          Category:9 (number) SubcategoriesMedia in category "9 (number)"Navigation menuUpload mediaGND ID: 4485639-8Library of Congress authority ID: sh85091979ReasonatorScholiaStatistics

          Get RecordId in LWC From Community PageLWC Community recordId undefinedhow to get Personal Access Token from my integrated application LWC. I am using js onlylwc quick action from Opportunity page(aura:component) and not getting @api recordIdLWC Community recordId undefinedLWC - How to get label name of buttonsLWC: Add a region in custom community themeVisual force page redirection from lightning communityLWC NavigationMixin does not work in CommunityInvoking LWC component from a plain URL - Read URL Parameter inside LWCLWC download PDF fileLWC Get Pick-list Field Values