Manipulate package weight before shipping rates calculationProgrammatically increase package weightFedex Weight CalculationUSPS Maximum Package Weight Not Restricting WeightShipping price in one page checkout - order review return zeroPhp file weight calculationWhy does the Shipping total set the row_weight of the sales quote items to 0 if free shipping is in effect?Shipping Table rates Weight vs Destination RangesCreating Quote Address the right wayIs Possible Magento Allows Change Shipping Cost calculate by Individual Product Weight instead of Package Weight?CollectRates in custom carrier is not called when weight is over zero. Magento2
Should I have shared a document with a former employee?
How do you name this compound using IUPAC system (including steps)?
Is "repository" pronounced /rɪˈpɒzɪt(ə)ri/ or ri-ˈpä-zə-ˌtȯr-ē or /rəˈpäzəˌtôrē/?
How did Jayne know when to shoot?
Somebody hacked my clock
Locked-up DOS computer beeped on keypress. What mechanism caused that?
What is a Kravchuk transform and how is it related to Fourier transforms?
How important are the Author's mood and feelings for writing a story?
Do higher dimensions have axes?
"This used to be my phone number"
Why would word of Princess Leia's capture generate sympathy for the Rebellion in the Senate?
Who or what determines if a curse is valid or not?
Why is carrying a heavy object more taxing on the body than pushing the same object on wheels?
What's the physical meaning of the statement that "photons don't have positions"?
Inscriptio Labyrinthica
Get Chord Name From a Given Set of Notes
Align the contents of a numerical matrix when you have minus signs
How electronics on board of JWST can survive the low operating temperature while it's difficult to survive lunar night?
How was Luke's prosthetic hand in Episode V filmed?
When will the last unambiguous evidence of mankind disappear?
"Je suis petite, moi?", purpose of the "moi"?
Discontinuous Tube visualization
Why should fork() have been designed to return a file descriptor?
When we are talking about black hole evaporation - what exactly happens?
Manipulate package weight before shipping rates calculation
Programmatically increase package weightFedex Weight CalculationUSPS Maximum Package Weight Not Restricting WeightShipping price in one page checkout - order review return zeroPhp file weight calculationWhy does the Shipping total set the row_weight of the sales quote items to 0 if free shipping is in effect?Shipping Table rates Weight vs Destination RangesCreating Quote Address the right wayIs Possible Magento Allows Change Shipping Cost calculate by Individual Product Weight instead of Package Weight?CollectRates in custom carrier is not called when weight is over zero. Magento2
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty margin-bottom:0;
I need to add some logic to weight package calculation before shipping rates are calculated. So I created a custom module with an observer on sales_quote_address_collect_totals_after
event.
The observer looks like this
use MagentoFrameworkEventObserverInterface;
class AfterCollectTotals implements ObserverInterface
public function execute(MagentoFrameworkEventObserver $observer)
foreach ($items as $item)
// My custom logic here to get the correct weight in $weight
$observer->getQuote()->getShippingAddress()->setWeight($weight);
Weight appears to be set correctly, but when the Shipping Rates are calculated this value is ignored.
In the carrier model, $request->getPackageWeight()
returns the package weight before my manipulation.
Where am I wrong?
Thank you
shipping magento2.2.2
add a comment |
I need to add some logic to weight package calculation before shipping rates are calculated. So I created a custom module with an observer on sales_quote_address_collect_totals_after
event.
The observer looks like this
use MagentoFrameworkEventObserverInterface;
class AfterCollectTotals implements ObserverInterface
public function execute(MagentoFrameworkEventObserver $observer)
foreach ($items as $item)
// My custom logic here to get the correct weight in $weight
$observer->getQuote()->getShippingAddress()->setWeight($weight);
Weight appears to be set correctly, but when the Shipping Rates are calculated this value is ignored.
In the carrier model, $request->getPackageWeight()
returns the package weight before my manipulation.
Where am I wrong?
Thank you
shipping magento2.2.2
Have you triedsales_quote_address_collect_totals_before
instead..._after
?
– sv3n
May 18 '18 at 10:15
Yes, but this event is dispatched too late as well
– Daniele Rovatti
May 18 '18 at 11:13
add a comment |
I need to add some logic to weight package calculation before shipping rates are calculated. So I created a custom module with an observer on sales_quote_address_collect_totals_after
event.
The observer looks like this
use MagentoFrameworkEventObserverInterface;
class AfterCollectTotals implements ObserverInterface
public function execute(MagentoFrameworkEventObserver $observer)
foreach ($items as $item)
// My custom logic here to get the correct weight in $weight
$observer->getQuote()->getShippingAddress()->setWeight($weight);
Weight appears to be set correctly, but when the Shipping Rates are calculated this value is ignored.
In the carrier model, $request->getPackageWeight()
returns the package weight before my manipulation.
Where am I wrong?
Thank you
shipping magento2.2.2
I need to add some logic to weight package calculation before shipping rates are calculated. So I created a custom module with an observer on sales_quote_address_collect_totals_after
event.
The observer looks like this
use MagentoFrameworkEventObserverInterface;
class AfterCollectTotals implements ObserverInterface
public function execute(MagentoFrameworkEventObserver $observer)
foreach ($items as $item)
// My custom logic here to get the correct weight in $weight
$observer->getQuote()->getShippingAddress()->setWeight($weight);
Weight appears to be set correctly, but when the Shipping Rates are calculated this value is ignored.
In the carrier model, $request->getPackageWeight()
returns the package weight before my manipulation.
Where am I wrong?
Thank you
shipping magento2.2.2
shipping magento2.2.2
asked May 18 '18 at 8:21
Daniele RovattiDaniele Rovatti
11911 bronze badges
11911 bronze badges
Have you triedsales_quote_address_collect_totals_before
instead..._after
?
– sv3n
May 18 '18 at 10:15
Yes, but this event is dispatched too late as well
– Daniele Rovatti
May 18 '18 at 11:13
add a comment |
Have you triedsales_quote_address_collect_totals_before
instead..._after
?
– sv3n
May 18 '18 at 10:15
Yes, but this event is dispatched too late as well
– Daniele Rovatti
May 18 '18 at 11:13
Have you tried
sales_quote_address_collect_totals_before
instead ..._after
?– sv3n
May 18 '18 at 10:15
Have you tried
sales_quote_address_collect_totals_before
instead ..._after
?– sv3n
May 18 '18 at 10:15
Yes, but this event is dispatched too late as well
– Daniele Rovatti
May 18 '18 at 11:13
Yes, but this event is dispatched too late as well
– Daniele Rovatti
May 18 '18 at 11:13
add a comment |
2 Answers
2
active
oldest
votes
I've find the solution.
I didn't have to use the observer but the right way is to override
class Shipping in MagentoQuoteModelQuoteAddressTotal
I added my custom logic to public function collect
and my custom weight is used to calculate the shipping rates
The reason is that the event sales_quote_address_collect_totals_after is dispatched after that the shipping methods collect quote totals to calculate rates
– Daniele Rovatti
May 18 '18 at 10:13
add a comment |
Same problem.
Im setting new weight on checkout_cart_product_add_after Event.
Weight is set, but the shipping costs are wrong.
How to recalculate the shipping costs?
Has anyone some code snippes please?
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%2f226544%2fmanipulate-package-weight-before-shipping-rates-calculation%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
2 Answers
2
active
oldest
votes
2 Answers
2
active
oldest
votes
active
oldest
votes
active
oldest
votes
I've find the solution.
I didn't have to use the observer but the right way is to override
class Shipping in MagentoQuoteModelQuoteAddressTotal
I added my custom logic to public function collect
and my custom weight is used to calculate the shipping rates
The reason is that the event sales_quote_address_collect_totals_after is dispatched after that the shipping methods collect quote totals to calculate rates
– Daniele Rovatti
May 18 '18 at 10:13
add a comment |
I've find the solution.
I didn't have to use the observer but the right way is to override
class Shipping in MagentoQuoteModelQuoteAddressTotal
I added my custom logic to public function collect
and my custom weight is used to calculate the shipping rates
The reason is that the event sales_quote_address_collect_totals_after is dispatched after that the shipping methods collect quote totals to calculate rates
– Daniele Rovatti
May 18 '18 at 10:13
add a comment |
I've find the solution.
I didn't have to use the observer but the right way is to override
class Shipping in MagentoQuoteModelQuoteAddressTotal
I added my custom logic to public function collect
and my custom weight is used to calculate the shipping rates
I've find the solution.
I didn't have to use the observer but the right way is to override
class Shipping in MagentoQuoteModelQuoteAddressTotal
I added my custom logic to public function collect
and my custom weight is used to calculate the shipping rates
answered May 18 '18 at 10:09
Daniele RovattiDaniele Rovatti
11911 bronze badges
11911 bronze badges
The reason is that the event sales_quote_address_collect_totals_after is dispatched after that the shipping methods collect quote totals to calculate rates
– Daniele Rovatti
May 18 '18 at 10:13
add a comment |
The reason is that the event sales_quote_address_collect_totals_after is dispatched after that the shipping methods collect quote totals to calculate rates
– Daniele Rovatti
May 18 '18 at 10:13
The reason is that the event sales_quote_address_collect_totals_after is dispatched after that the shipping methods collect quote totals to calculate rates
– Daniele Rovatti
May 18 '18 at 10:13
The reason is that the event sales_quote_address_collect_totals_after is dispatched after that the shipping methods collect quote totals to calculate rates
– Daniele Rovatti
May 18 '18 at 10:13
add a comment |
Same problem.
Im setting new weight on checkout_cart_product_add_after Event.
Weight is set, but the shipping costs are wrong.
How to recalculate the shipping costs?
Has anyone some code snippes please?
add a comment |
Same problem.
Im setting new weight on checkout_cart_product_add_after Event.
Weight is set, but the shipping costs are wrong.
How to recalculate the shipping costs?
Has anyone some code snippes please?
add a comment |
Same problem.
Im setting new weight on checkout_cart_product_add_after Event.
Weight is set, but the shipping costs are wrong.
How to recalculate the shipping costs?
Has anyone some code snippes please?
Same problem.
Im setting new weight on checkout_cart_product_add_after Event.
Weight is set, but the shipping costs are wrong.
How to recalculate the shipping costs?
Has anyone some code snippes please?
answered Jul 11 at 12:38
MarcelMarcel
365 bronze badges
365 bronze badges
add a comment |
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%2f226544%2fmanipulate-package-weight-before-shipping-rates-calculation%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
Have you tried
sales_quote_address_collect_totals_before
instead..._after
?– sv3n
May 18 '18 at 10:15
Yes, but this event is dispatched too late as well
– Daniele Rovatti
May 18 '18 at 11:13