How to correctly add an extra charge to a Magento 2 order's total amount?Magento 2 - Add Custom Discount to Order Totals on Cart pageMagento 2.1: How to handle custom payment grand total mismatch upon return to the merchant ?siteMagento2 add custom address attributeProduct price and cart totals per tax class or customer groupHow to programmatically add discount to order total on magento 2Magento 2: How to make custom fee taxableMagento 2: how to programatically set free shipping from an observer?How to Refresh/reload Magento 2 Quote Object in checkout session/pageMagento 2: How can I update tax and total programmatically on checkout?get grand total with shipping & shipping (incl. tax) in custom controller
What triggered jesuits' ban on infinitesimals in 1632?
Too early in the morning to have SODA?
What is "industrial ethernet"?
Greeting with "Ho"
Explain why a line can never intersect a plane in exactly two points.
Non-misogynistic way to say “asshole”?
Can the pre-order traversal of two different trees be the same even though they are different?
Very tricky nonogram - where to go next?
What does it cost to buy a tavern?
A word for delight at someone else's failure?
How did the Vostok ejection seat safely eject an astronaut from a sealed space capsule?
What is the oldest commercial MS-DOS program that can run on modern versions of Windows without third-party software?
Dmesg full of I/O errors, smart ok, four disks affected
Did the CIA blow up a Siberian pipeline in 1982?
How to mark the seams of UV maps to edit textures in external programs?
Why don't countries like Japan just print more money?
Why is oilcloth made with linseed oil?
Is there a term for the belief that "if it's legal, it's moral"?
I just entered the USA without passport control at Atlanta airport
What is the highest voltage from the power supply a Raspberry Pi 3 B can handle without getting damaged?
Print one file per line using echo
Can I enter the UK for 24 hours from a Schengen area, holding an Indian passport?
Are there any "normal" words with the syllable кы?
How much steel armor can you wear and still be able to swim?
How to correctly add an extra charge to a Magento 2 order's total amount?
Magento 2 - Add Custom Discount to Order Totals on Cart pageMagento 2.1: How to handle custom payment grand total mismatch upon return to the merchant ?siteMagento2 add custom address attributeProduct price and cart totals per tax class or customer groupHow to programmatically add discount to order total on magento 2Magento 2: How to make custom fee taxableMagento 2: how to programatically set free shipping from an observer?How to Refresh/reload Magento 2 Quote Object in checkout session/pageMagento 2: How can I update tax and total programmatically on checkout?get grand total with shipping & shipping (incl. tax) in custom controller
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty margin-bottom:0;
We're using a custom module to calculate an amount we need to include in the grand total of the order, i.e. the customer will be charged for the product PLUS this custom amount.
The result is our custom amount goes as Total Due
and Stripe only charges the customer for the original value of the product and its shipping without our custom calculation.
Custom module code is as follows:
class CustomAmount extends MagentoQuoteModelQuoteAddressTotalAbstractTotal
public function collect(
MagentoQuoteModelQuote $quote,
MagentoQuoteApiDataShippingAssignmentInterface $shippingAssignment,
MagentoQuoteModelQuoteAddressTotal $total
)
parent::collect($quote, $shippingAssignment, $total);
$amount = 187; // fixed amount as example, but this will change
$total->setTotalAmount('installation', $amount);
$total->setBaseTotalAmount('installation', $amount);
$total->setCustomAmount($amount);
$total->setBaseCustomAmount($amount);
$total->addTotalAmount($this->getCode(), $amount);
$total->addBaseTotalAmount($this->getCode(), $amount);
return $this;
and we're seeing this on admin panel
magento2 sales-order sales-quote
New contributor
add a comment |
We're using a custom module to calculate an amount we need to include in the grand total of the order, i.e. the customer will be charged for the product PLUS this custom amount.
The result is our custom amount goes as Total Due
and Stripe only charges the customer for the original value of the product and its shipping without our custom calculation.
Custom module code is as follows:
class CustomAmount extends MagentoQuoteModelQuoteAddressTotalAbstractTotal
public function collect(
MagentoQuoteModelQuote $quote,
MagentoQuoteApiDataShippingAssignmentInterface $shippingAssignment,
MagentoQuoteModelQuoteAddressTotal $total
)
parent::collect($quote, $shippingAssignment, $total);
$amount = 187; // fixed amount as example, but this will change
$total->setTotalAmount('installation', $amount);
$total->setBaseTotalAmount('installation', $amount);
$total->setCustomAmount($amount);
$total->setBaseCustomAmount($amount);
$total->addTotalAmount($this->getCode(), $amount);
$total->addBaseTotalAmount($this->getCode(), $amount);
return $this;
and we're seeing this on admin panel
magento2 sales-order sales-quote
New contributor
add a comment |
We're using a custom module to calculate an amount we need to include in the grand total of the order, i.e. the customer will be charged for the product PLUS this custom amount.
The result is our custom amount goes as Total Due
and Stripe only charges the customer for the original value of the product and its shipping without our custom calculation.
Custom module code is as follows:
class CustomAmount extends MagentoQuoteModelQuoteAddressTotalAbstractTotal
public function collect(
MagentoQuoteModelQuote $quote,
MagentoQuoteApiDataShippingAssignmentInterface $shippingAssignment,
MagentoQuoteModelQuoteAddressTotal $total
)
parent::collect($quote, $shippingAssignment, $total);
$amount = 187; // fixed amount as example, but this will change
$total->setTotalAmount('installation', $amount);
$total->setBaseTotalAmount('installation', $amount);
$total->setCustomAmount($amount);
$total->setBaseCustomAmount($amount);
$total->addTotalAmount($this->getCode(), $amount);
$total->addBaseTotalAmount($this->getCode(), $amount);
return $this;
and we're seeing this on admin panel
magento2 sales-order sales-quote
New contributor
We're using a custom module to calculate an amount we need to include in the grand total of the order, i.e. the customer will be charged for the product PLUS this custom amount.
The result is our custom amount goes as Total Due
and Stripe only charges the customer for the original value of the product and its shipping without our custom calculation.
Custom module code is as follows:
class CustomAmount extends MagentoQuoteModelQuoteAddressTotalAbstractTotal
public function collect(
MagentoQuoteModelQuote $quote,
MagentoQuoteApiDataShippingAssignmentInterface $shippingAssignment,
MagentoQuoteModelQuoteAddressTotal $total
)
parent::collect($quote, $shippingAssignment, $total);
$amount = 187; // fixed amount as example, but this will change
$total->setTotalAmount('installation', $amount);
$total->setBaseTotalAmount('installation', $amount);
$total->setCustomAmount($amount);
$total->setBaseCustomAmount($amount);
$total->addTotalAmount($this->getCode(), $amount);
$total->addBaseTotalAmount($this->getCode(), $amount);
return $this;
and we're seeing this on admin panel
magento2 sales-order sales-quote
magento2 sales-order sales-quote
New contributor
New contributor
edited Jun 11 at 22:25
porras
New contributor
asked Jun 11 at 21:32
porrasporras
113
113
New contributor
New contributor
add a comment |
add a comment |
0
active
oldest
votes
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
);
);
porras 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%2f278013%2fhow-to-correctly-add-an-extra-charge-to-a-magento-2-orders-total-amount%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
0
active
oldest
votes
0
active
oldest
votes
active
oldest
votes
active
oldest
votes
porras is a new contributor. Be nice, and check out our Code of Conduct.
porras is a new contributor. Be nice, and check out our Code of Conduct.
porras is a new contributor. Be nice, and check out our Code of Conduct.
porras 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%2f278013%2fhow-to-correctly-add-an-extra-charge-to-a-magento-2-orders-total-amount%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