apply custom discount in cart magento2 via observerapply more then one Shopping Cart Price Rule to one itemObservers are not triggering in REST APIMagento 2 - How to add custom discount in cart programmatically?Magento2 - Getting the selected custom option value for a productIn Magento 2, how to create promo rule for buy one get one in backend for specific custom attribute?Apply discount from checkout second page/tabUpdate total using 'sales_quote_save_after' event in magento 2?Magento 2 : specific product remove from quoteItem Price being Ignored in Cart Price RulesMagento 2 programmatically update coupon condition
How to trick the reader into thinking they're following a redshirt instead of the protagonist?
Wooden cooking layout
Extreme flexible working hours: how to get to know people and activities?
How to safely destroy (a large quantity of) valid checks?
Are there any important biographies of nobodies?
Is it possible to fly backward if you have REALLY STRONG headwind?
Active low-pass filters --- good to what frequencies?
Fixing obscure 8080 emulator bug?
Second (easy access) account in case my bank screws up
Is it expected that a reader will skip parts of what you write?
Does the Long March-11 increase its thrust after clearing the launch tower?
Can the concepts of abstract algebra be visualized as in analysis?
What to do when surprise and a high initiative roll conflict with the narrative?
Why does Sin[b-a] simplify to -Sin[a-b]?
Who are the Missing Members of this Noble Family?
How come the nude protesters were not arrested?
Why can I traceroute to this IP address, but not ping?
How did old MS-DOS games utilize various graphic cards?
LuaLaTex - how to use number, computed later in the document
How to communicate to my GM that not being allowed to use stealth isn't fun for me?
Why does the Mishnah use the terms poor person and homeowner when discussing carrying on Shabbat?
Traversing Oceania: A Cryptic Journey
Someone whose aspirations exceed abilities or means
Print lines between start & end pattern, but if end pattern does not exist, don't print
apply custom discount in cart magento2 via observer
apply more then one Shopping Cart Price Rule to one itemObservers are not triggering in REST APIMagento 2 - How to add custom discount in cart programmatically?Magento2 - Getting the selected custom option value for a productIn Magento 2, how to create promo rule for buy one get one in backend for specific custom attribute?Apply discount from checkout second page/tabUpdate total using 'sales_quote_save_after' event in magento 2?Magento 2 : specific product remove from quoteItem Price being Ignored in Cart Price RulesMagento 2 programmatically update coupon condition
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty margin-bottom:0;
I have created a custom promotion in magento2. To get that working I needed to do some customization in cart which I am trying to do with salesrule_validator_process event.
I needed the rulename and discount values to be modified before applying in cart.
Now In Magento1 we used to update values as below:
$result = $observer['result'];
$result->setDiscountAmount($DiscountAmount);
$result->setBaseDiscountAmount($BaseDiscountAmount);
How we can achieve the same in Magento2?
Any thoughts/suggestions are welcome.
magento2 shopping-cart-price-rules sales promotions
add a comment |
I have created a custom promotion in magento2. To get that working I needed to do some customization in cart which I am trying to do with salesrule_validator_process event.
I needed the rulename and discount values to be modified before applying in cart.
Now In Magento1 we used to update values as below:
$result = $observer['result'];
$result->setDiscountAmount($DiscountAmount);
$result->setBaseDiscountAmount($BaseDiscountAmount);
How we can achieve the same in Magento2?
Any thoughts/suggestions are welcome.
magento2 shopping-cart-price-rules sales promotions
Did you get any solution..
– Lead Developer
Nov 23 '18 at 13:56
add a comment |
I have created a custom promotion in magento2. To get that working I needed to do some customization in cart which I am trying to do with salesrule_validator_process event.
I needed the rulename and discount values to be modified before applying in cart.
Now In Magento1 we used to update values as below:
$result = $observer['result'];
$result->setDiscountAmount($DiscountAmount);
$result->setBaseDiscountAmount($BaseDiscountAmount);
How we can achieve the same in Magento2?
Any thoughts/suggestions are welcome.
magento2 shopping-cart-price-rules sales promotions
I have created a custom promotion in magento2. To get that working I needed to do some customization in cart which I am trying to do with salesrule_validator_process event.
I needed the rulename and discount values to be modified before applying in cart.
Now In Magento1 we used to update values as below:
$result = $observer['result'];
$result->setDiscountAmount($DiscountAmount);
$result->setBaseDiscountAmount($BaseDiscountAmount);
How we can achieve the same in Magento2?
Any thoughts/suggestions are welcome.
magento2 shopping-cart-price-rules sales promotions
magento2 shopping-cart-price-rules sales promotions
edited Jul 19 '16 at 6:49
Amit Bera♦
60.9k1682181
60.9k1682181
asked Jul 19 '16 at 6:38
PallaviPallavi
30918
30918
Did you get any solution..
– Lead Developer
Nov 23 '18 at 13:56
add a comment |
Did you get any solution..
– Lead Developer
Nov 23 '18 at 13:56
Did you get any solution..
– Lead Developer
Nov 23 '18 at 13:56
Did you get any solution..
– Lead Developer
Nov 23 '18 at 13:56
add a comment |
1 Answer
1
active
oldest
votes
You can apply discount amount in magento2 by same event just write below code in your observer file:
$result = $observer->getEvent()->getResult();
$result->setAmount($DiscountAmoun);
$result->setBaseAmount($DiscountAmoun);
It is not working. I already tried.
– Pallavi
Jul 19 '16 at 10:44
This event dispatch from vendor/magento/module-sales-rule/Model/RulesApplier.php eventFix() and it will call when anybody apply coupon code from cart page
– Yogesh Karodiya
Jul 19 '16 at 11:05
Yes I know that. How i can use this info for setting new dicsount? Can you please explain a little bit more?
– Pallavi
Jul 19 '16 at 11:16
from where you want get access your discount? you can get any model factory or collection factory by just pass it from construct function and put your logic before apply set amount.
– Yogesh Karodiya
Jul 19 '16 at 11:24
I tried this. $result = $observer->getEvent()->getResult(); $result->setAmount(10); $result->setBaseAmount(10); but this is not working.
– Pallavi
Jul 19 '16 at 11:42
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
);
);
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%2f126306%2fapply-custom-discount-in-cart-magento2-via-observer%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 can apply discount amount in magento2 by same event just write below code in your observer file:
$result = $observer->getEvent()->getResult();
$result->setAmount($DiscountAmoun);
$result->setBaseAmount($DiscountAmoun);
It is not working. I already tried.
– Pallavi
Jul 19 '16 at 10:44
This event dispatch from vendor/magento/module-sales-rule/Model/RulesApplier.php eventFix() and it will call when anybody apply coupon code from cart page
– Yogesh Karodiya
Jul 19 '16 at 11:05
Yes I know that. How i can use this info for setting new dicsount? Can you please explain a little bit more?
– Pallavi
Jul 19 '16 at 11:16
from where you want get access your discount? you can get any model factory or collection factory by just pass it from construct function and put your logic before apply set amount.
– Yogesh Karodiya
Jul 19 '16 at 11:24
I tried this. $result = $observer->getEvent()->getResult(); $result->setAmount(10); $result->setBaseAmount(10); but this is not working.
– Pallavi
Jul 19 '16 at 11:42
add a comment |
You can apply discount amount in magento2 by same event just write below code in your observer file:
$result = $observer->getEvent()->getResult();
$result->setAmount($DiscountAmoun);
$result->setBaseAmount($DiscountAmoun);
It is not working. I already tried.
– Pallavi
Jul 19 '16 at 10:44
This event dispatch from vendor/magento/module-sales-rule/Model/RulesApplier.php eventFix() and it will call when anybody apply coupon code from cart page
– Yogesh Karodiya
Jul 19 '16 at 11:05
Yes I know that. How i can use this info for setting new dicsount? Can you please explain a little bit more?
– Pallavi
Jul 19 '16 at 11:16
from where you want get access your discount? you can get any model factory or collection factory by just pass it from construct function and put your logic before apply set amount.
– Yogesh Karodiya
Jul 19 '16 at 11:24
I tried this. $result = $observer->getEvent()->getResult(); $result->setAmount(10); $result->setBaseAmount(10); but this is not working.
– Pallavi
Jul 19 '16 at 11:42
add a comment |
You can apply discount amount in magento2 by same event just write below code in your observer file:
$result = $observer->getEvent()->getResult();
$result->setAmount($DiscountAmoun);
$result->setBaseAmount($DiscountAmoun);
You can apply discount amount in magento2 by same event just write below code in your observer file:
$result = $observer->getEvent()->getResult();
$result->setAmount($DiscountAmoun);
$result->setBaseAmount($DiscountAmoun);
answered Jul 19 '16 at 10:04
Yogesh KarodiyaYogesh Karodiya
1,97321335
1,97321335
It is not working. I already tried.
– Pallavi
Jul 19 '16 at 10:44
This event dispatch from vendor/magento/module-sales-rule/Model/RulesApplier.php eventFix() and it will call when anybody apply coupon code from cart page
– Yogesh Karodiya
Jul 19 '16 at 11:05
Yes I know that. How i can use this info for setting new dicsount? Can you please explain a little bit more?
– Pallavi
Jul 19 '16 at 11:16
from where you want get access your discount? you can get any model factory or collection factory by just pass it from construct function and put your logic before apply set amount.
– Yogesh Karodiya
Jul 19 '16 at 11:24
I tried this. $result = $observer->getEvent()->getResult(); $result->setAmount(10); $result->setBaseAmount(10); but this is not working.
– Pallavi
Jul 19 '16 at 11:42
add a comment |
It is not working. I already tried.
– Pallavi
Jul 19 '16 at 10:44
This event dispatch from vendor/magento/module-sales-rule/Model/RulesApplier.php eventFix() and it will call when anybody apply coupon code from cart page
– Yogesh Karodiya
Jul 19 '16 at 11:05
Yes I know that. How i can use this info for setting new dicsount? Can you please explain a little bit more?
– Pallavi
Jul 19 '16 at 11:16
from where you want get access your discount? you can get any model factory or collection factory by just pass it from construct function and put your logic before apply set amount.
– Yogesh Karodiya
Jul 19 '16 at 11:24
I tried this. $result = $observer->getEvent()->getResult(); $result->setAmount(10); $result->setBaseAmount(10); but this is not working.
– Pallavi
Jul 19 '16 at 11:42
It is not working. I already tried.
– Pallavi
Jul 19 '16 at 10:44
It is not working. I already tried.
– Pallavi
Jul 19 '16 at 10:44
This event dispatch from vendor/magento/module-sales-rule/Model/RulesApplier.php eventFix() and it will call when anybody apply coupon code from cart page
– Yogesh Karodiya
Jul 19 '16 at 11:05
This event dispatch from vendor/magento/module-sales-rule/Model/RulesApplier.php eventFix() and it will call when anybody apply coupon code from cart page
– Yogesh Karodiya
Jul 19 '16 at 11:05
Yes I know that. How i can use this info for setting new dicsount? Can you please explain a little bit more?
– Pallavi
Jul 19 '16 at 11:16
Yes I know that. How i can use this info for setting new dicsount? Can you please explain a little bit more?
– Pallavi
Jul 19 '16 at 11:16
from where you want get access your discount? you can get any model factory or collection factory by just pass it from construct function and put your logic before apply set amount.
– Yogesh Karodiya
Jul 19 '16 at 11:24
from where you want get access your discount? you can get any model factory or collection factory by just pass it from construct function and put your logic before apply set amount.
– Yogesh Karodiya
Jul 19 '16 at 11:24
I tried this. $result = $observer->getEvent()->getResult(); $result->setAmount(10); $result->setBaseAmount(10); but this is not working.
– Pallavi
Jul 19 '16 at 11:42
I tried this. $result = $observer->getEvent()->getResult(); $result->setAmount(10); $result->setBaseAmount(10); but this is not working.
– Pallavi
Jul 19 '16 at 11:42
add a comment |
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%2f126306%2fapply-custom-discount-in-cart-magento2-via-observer%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
Did you get any solution..
– Lead Developer
Nov 23 '18 at 13:56