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;
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
New contributor
add a comment |
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
New contributor
add a comment |
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
New contributor
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
magento2 plugin coupon-codes before-plugin
New contributor
New contributor
New contributor
asked Jun 20 at 10:42
vDrewsvDrews
322 bronze badges
322 bronze badges
New contributor
New contributor
add a comment |
add a comment |
1 Answer
1
active
oldest
votes
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);
thanks a lot! It works!
– vDrews
Jun 20 at 11:37
add a comment |
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.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
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
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);
thanks a lot! It works!
– vDrews
Jun 20 at 11:37
add a comment |
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);
thanks a lot! It works!
– vDrews
Jun 20 at 11:37
add a comment |
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);
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);
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 Bera♦Amit 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
add a comment |
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
add a comment |
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.
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.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
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
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
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