Change Row Total for Quote Item whithout changing the PriceMagento - How to calculate Price by WeightWhat is the event after total calculation of cart item in Magento 2 using PluginMagento 2 - custom price can not add to subtotal and grand total after add to cartMagento 2 collect total quote after remove itemMagento2 - duplicate quote item to new row and new priceCustom price is not getting calculated on cart magento 2How to change row subtotal with custom price in cart?Set Custom Price to Quote item magento2 from controllerGift Wrapping for Items not calculating correct total including taxMagento 2: How to set item Row total?

How to know if blackberries are safe to eat?

Why didn't Thanos kill all the Dwarves on Nidavellir?

LED glows slightly during soldering

Terry Pratchett book with a lawyer dragon and sheep

Why is the air gap between the stator and rotor on a motor kept as small as it is?

Why isn't pressure filtration popular compared to vacuum filtration?

Do I have a right to cancel a purchase of foreign currency in the UK?

Can you cast a blanket Invisibility and let the targets see each other?

How to deal with moral/legal subjects in writing?

Should disabled buttons give feedback when clicked?

When I press the space bar it deletes the letters after it

Shortest hex dumping program

What happens to unproductive professors?

Astronaut distance from Earth?

Some interesting calculation puzzle that I made

Why did Harry Potter get a bedroom?

Why does 電池 take the を particle

Has anyone in space seen or photographed a simple laser pointer from Earth?

Graduate student with abysmal English writing skills, how to help

If your plane is out-of-control, why does military training instruct releasing the joystick to neutralize controls?

How quality assurance engineers test calculations?

Why is the ladder of the LM always in the dark side of the LM?

Does Lufthansa weigh your carry on luggage?

Are there any sports for which the world's best player is female?



Change Row Total for Quote Item whithout changing the Price


Magento - How to calculate Price by WeightWhat is the event after total calculation of cart item in Magento 2 using PluginMagento 2 - custom price can not add to subtotal and grand total after add to cartMagento 2 collect total quote after remove itemMagento2 - duplicate quote item to new row and new priceCustom price is not getting calculated on cart magento 2How to change row subtotal with custom price in cart?Set Custom Price to Quote item magento2 from controllerGift Wrapping for Items not calculating correct total including taxMagento 2: How to set item Row total?






.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty margin-bottom:0;








0















I have tried to set custom price for this purpose but its getting multiplied by quantity. All i need to add an extra ammount(like 50$) to each quote item after its added too the cart.
So it will be like this if have 2 products in cart..
First product Price 5.00$ qty is 10.
Second Product Price 3.50$ qty is 20.



I want the calculation be like : (5.00 * 10 + 50) + (3.50 * 20 + 50)
item 1 subtotal = 100.
item 2 subtotal = 120.
Total = 220.



For Magento 1 it was implemented in Sales_Quote_Item model
in CalcRowTotal().
like this..
$baseTotal = $this->getBaseRowTotal() + $additionalCharges;



 $baseTotal = $this->getBaseRowTotal() + $additionalCharges; //$additionalCharges is the custom value that i want to add.
$total = $this->getStore()->convertPrice($baseTotal);
$this->setRowTotal($this->getStore()->roundPrice($total));
$this->setBaseRowTotal($this->getStore()->roundPrice($baseTotal));


But in Magento 2 this is not working . Can anyone Help ??










share|improve this question




























    0















    I have tried to set custom price for this purpose but its getting multiplied by quantity. All i need to add an extra ammount(like 50$) to each quote item after its added too the cart.
    So it will be like this if have 2 products in cart..
    First product Price 5.00$ qty is 10.
    Second Product Price 3.50$ qty is 20.



    I want the calculation be like : (5.00 * 10 + 50) + (3.50 * 20 + 50)
    item 1 subtotal = 100.
    item 2 subtotal = 120.
    Total = 220.



    For Magento 1 it was implemented in Sales_Quote_Item model
    in CalcRowTotal().
    like this..
    $baseTotal = $this->getBaseRowTotal() + $additionalCharges;



     $baseTotal = $this->getBaseRowTotal() + $additionalCharges; //$additionalCharges is the custom value that i want to add.
    $total = $this->getStore()->convertPrice($baseTotal);
    $this->setRowTotal($this->getStore()->roundPrice($total));
    $this->setBaseRowTotal($this->getStore()->roundPrice($baseTotal));


    But in Magento 2 this is not working . Can anyone Help ??










    share|improve this question
























      0












      0








      0








      I have tried to set custom price for this purpose but its getting multiplied by quantity. All i need to add an extra ammount(like 50$) to each quote item after its added too the cart.
      So it will be like this if have 2 products in cart..
      First product Price 5.00$ qty is 10.
      Second Product Price 3.50$ qty is 20.



      I want the calculation be like : (5.00 * 10 + 50) + (3.50 * 20 + 50)
      item 1 subtotal = 100.
      item 2 subtotal = 120.
      Total = 220.



      For Magento 1 it was implemented in Sales_Quote_Item model
      in CalcRowTotal().
      like this..
      $baseTotal = $this->getBaseRowTotal() + $additionalCharges;



       $baseTotal = $this->getBaseRowTotal() + $additionalCharges; //$additionalCharges is the custom value that i want to add.
      $total = $this->getStore()->convertPrice($baseTotal);
      $this->setRowTotal($this->getStore()->roundPrice($total));
      $this->setBaseRowTotal($this->getStore()->roundPrice($baseTotal));


      But in Magento 2 this is not working . Can anyone Help ??










      share|improve this question














      I have tried to set custom price for this purpose but its getting multiplied by quantity. All i need to add an extra ammount(like 50$) to each quote item after its added too the cart.
      So it will be like this if have 2 products in cart..
      First product Price 5.00$ qty is 10.
      Second Product Price 3.50$ qty is 20.



      I want the calculation be like : (5.00 * 10 + 50) + (3.50 * 20 + 50)
      item 1 subtotal = 100.
      item 2 subtotal = 120.
      Total = 220.



      For Magento 1 it was implemented in Sales_Quote_Item model
      in CalcRowTotal().
      like this..
      $baseTotal = $this->getBaseRowTotal() + $additionalCharges;



       $baseTotal = $this->getBaseRowTotal() + $additionalCharges; //$additionalCharges is the custom value that i want to add.
      $total = $this->getStore()->convertPrice($baseTotal);
      $this->setRowTotal($this->getStore()->roundPrice($total));
      $this->setBaseRowTotal($this->getStore()->roundPrice($baseTotal));


      But in Magento 2 this is not working . Can anyone Help ??







      magento2 cart price






      share|improve this question













      share|improve this question











      share|improve this question




      share|improve this question










      asked Jul 2 at 10:50









      user81381user81381

      1




      1




















          1 Answer
          1






          active

          oldest

          votes


















          0














          You can achieve this by using registry and observer, check below code



          You have to override cart/add controller




          MagentoCheckoutControllerCartAdd




          You can pass your formatted price in observer like below,



          $baseTotal = $this->getBaseRowTotal() + $additionalCharges;

          $this->_registry->register('price_values', $baseTotal);


          Above is my code, you have to set your logic there.



          And now we will use this registry in observer like below,



          public function execute(MagentoFrameworkEventObserver $observer)

          $items=$observer->getItems();
          if($items)
          foreach($items as $item)
          if($customPrice=$this->registry->registry('price_values'))
          $item->setCustomPrice($customPrice);
          $item->setOriginalCustomPrice($customPrice);
          $item->setPrice(null);
          $item->setBasePrice(null);
          $this->registry->unregister('price_value');






          Please check with above technique.






          share|improve this answer



























            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
            );



            );













            draft saved

            draft discarded


















            StackExchange.ready(
            function ()
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmagento.stackexchange.com%2fquestions%2f280442%2fchange-row-total-for-quote-item-whithout-changing-the-price%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









            0














            You can achieve this by using registry and observer, check below code



            You have to override cart/add controller




            MagentoCheckoutControllerCartAdd




            You can pass your formatted price in observer like below,



            $baseTotal = $this->getBaseRowTotal() + $additionalCharges;

            $this->_registry->register('price_values', $baseTotal);


            Above is my code, you have to set your logic there.



            And now we will use this registry in observer like below,



            public function execute(MagentoFrameworkEventObserver $observer)

            $items=$observer->getItems();
            if($items)
            foreach($items as $item)
            if($customPrice=$this->registry->registry('price_values'))
            $item->setCustomPrice($customPrice);
            $item->setOriginalCustomPrice($customPrice);
            $item->setPrice(null);
            $item->setBasePrice(null);
            $this->registry->unregister('price_value');






            Please check with above technique.






            share|improve this answer





























              0














              You can achieve this by using registry and observer, check below code



              You have to override cart/add controller




              MagentoCheckoutControllerCartAdd




              You can pass your formatted price in observer like below,



              $baseTotal = $this->getBaseRowTotal() + $additionalCharges;

              $this->_registry->register('price_values', $baseTotal);


              Above is my code, you have to set your logic there.



              And now we will use this registry in observer like below,



              public function execute(MagentoFrameworkEventObserver $observer)

              $items=$observer->getItems();
              if($items)
              foreach($items as $item)
              if($customPrice=$this->registry->registry('price_values'))
              $item->setCustomPrice($customPrice);
              $item->setOriginalCustomPrice($customPrice);
              $item->setPrice(null);
              $item->setBasePrice(null);
              $this->registry->unregister('price_value');






              Please check with above technique.






              share|improve this answer



























                0












                0








                0







                You can achieve this by using registry and observer, check below code



                You have to override cart/add controller




                MagentoCheckoutControllerCartAdd




                You can pass your formatted price in observer like below,



                $baseTotal = $this->getBaseRowTotal() + $additionalCharges;

                $this->_registry->register('price_values', $baseTotal);


                Above is my code, you have to set your logic there.



                And now we will use this registry in observer like below,



                public function execute(MagentoFrameworkEventObserver $observer)

                $items=$observer->getItems();
                if($items)
                foreach($items as $item)
                if($customPrice=$this->registry->registry('price_values'))
                $item->setCustomPrice($customPrice);
                $item->setOriginalCustomPrice($customPrice);
                $item->setPrice(null);
                $item->setBasePrice(null);
                $this->registry->unregister('price_value');






                Please check with above technique.






                share|improve this answer















                You can achieve this by using registry and observer, check below code



                You have to override cart/add controller




                MagentoCheckoutControllerCartAdd




                You can pass your formatted price in observer like below,



                $baseTotal = $this->getBaseRowTotal() + $additionalCharges;

                $this->_registry->register('price_values', $baseTotal);


                Above is my code, you have to set your logic there.



                And now we will use this registry in observer like below,



                public function execute(MagentoFrameworkEventObserver $observer)

                $items=$observer->getItems();
                if($items)
                foreach($items as $item)
                if($customPrice=$this->registry->registry('price_values'))
                $item->setCustomPrice($customPrice);
                $item->setOriginalCustomPrice($customPrice);
                $item->setPrice(null);
                $item->setBasePrice(null);
                $this->registry->unregister('price_value');






                Please check with above technique.







                share|improve this answer














                share|improve this answer



                share|improve this answer








                edited Jul 2 at 11:42

























                answered Jul 2 at 11:28









                Ravi SoniRavi Soni

                1,0415 silver badges18 bronze badges




                1,0415 silver badges18 bronze badges



























                    draft saved

                    draft discarded
















































                    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%2f280442%2fchange-row-total-for-quote-item-whithout-changing-the-price%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?