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

          Get product attribute by attribute group code in magento 2get product attribute by product attribute group in magento 2Magento 2 Log Bundle Product Data in List Page?How to get all product attribute of a attribute group of Default attribute set?Magento 2.1 Create a filter in the product grid by new attributeMagento 2 : Get Product Attribute values By GroupMagento 2 How to get all existing values for one attributeMagento 2 get custom attribute of a single product inside a pluginMagento 2.3 How to get all the Multi Source Inventory (MSI) locations collection in custom module?Magento2: how to develop rest API to get new productsGet product attribute by attribute group code ( [attribute_group_code] ) in magento 2

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

          Magento 2.3: How do i solve this, Not registered handle, on custom form?How can i rewrite TierPrice Block in Magento2magento 2 captcha not rendering if I override layout xmlmain.CRITICAL: Plugin class doesn't existMagento 2 : Problem while adding custom button order view page?Magento 2.2.5: Overriding Admin Controller sales/orderMagento 2.2.5: Add, Update and Delete existing products Custom OptionsMagento 2.3 : File Upload issue in UI Component FormMagento2 Not registered handleHow to configured Form Builder Js in my custom magento 2.3.0 module?Magento 2.3. How to create image upload field in an admin form