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;








2















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
enter image description here










share|improve this question









New contributor



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

























    2















    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
    enter image description here










    share|improve this question









    New contributor



    porras 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








      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
      enter image description here










      share|improve this question









      New contributor



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











      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
      enter image description here







      magento2 sales-order sales-quote






      share|improve this question









      New contributor



      porras 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



      porras 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








      edited Jun 11 at 22:25







      porras













      New contributor



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








      asked Jun 11 at 21:32









      porrasporras

      113




      113




      New contributor



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




      New contributor




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






















          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.









          draft saved

          draft discarded


















          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.









          draft saved

          draft discarded


















          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.




          draft saved


          draft discarded














          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





















































          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

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

          Circuit construction for execution of conditional statements using least significant bitHow are two different registers being used as “control”?How exactly is the stated composite state of the two registers being produced using the $R_zz$ controlled rotations?Efficiently performing controlled rotations in HHLWould this quantum algorithm implementation work?How to prepare a superposed states of odd integers from $1$ to $sqrtN$?Why is this implementation of the order finding algorithm not working?Circuit construction for Hamiltonian simulationHow can I invert the least significant bit of a certain term of a superposed state?Implementing an oracleImplementing a controlled sum operation

          Magento 2 “No Payment Methods” in Admin New OrderHow to integrate Paypal Express Checkout with the Magento APIMagento 1.5 - Sales > Order > edit order and shipping methods disappearAuto Invoice Check/Money Order Payment methodAdd more simple payment methods?Shipping methods not showingWhat should I do to change payment methods if changing the configuration has no effects?1.9 - No Payment Methods showing upMy Payment Methods not Showing for downloadable/virtual product when checkout?Magento2 API to access internal payment methodHow to call an existing payment methods in the registration form?