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

                    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