Remove subtotal line from cart and checkout pages in Woocommerce










0














I want to remove the Subtotals from Cart, Checkout, Order Received, Order Details and the emails. I don't want to use CSS, as it won't remove the reference from the order details page and emails. I have tried this code:



add_filter( 'woocommerce_get_order_item_totals', 'adjust_woocommerce_get_order_item_totals' );

function adjust_woocommerce_get_order_item_totals( $totals )
unset($totals['cart_subtotal'] );
return $totals;



It isn't working, the Subtotal is visible on the Cart and Checkout pages.



Is there any other function or do I have to create a separate woocommerce folder under my active theme and delete any reference of "Subtotal" from the templates.










share|improve this question




























    0














    I want to remove the Subtotals from Cart, Checkout, Order Received, Order Details and the emails. I don't want to use CSS, as it won't remove the reference from the order details page and emails. I have tried this code:



    add_filter( 'woocommerce_get_order_item_totals', 'adjust_woocommerce_get_order_item_totals' );

    function adjust_woocommerce_get_order_item_totals( $totals )
    unset($totals['cart_subtotal'] );
    return $totals;



    It isn't working, the Subtotal is visible on the Cart and Checkout pages.



    Is there any other function or do I have to create a separate woocommerce folder under my active theme and delete any reference of "Subtotal" from the templates.










    share|improve this question


























      0












      0








      0







      I want to remove the Subtotals from Cart, Checkout, Order Received, Order Details and the emails. I don't want to use CSS, as it won't remove the reference from the order details page and emails. I have tried this code:



      add_filter( 'woocommerce_get_order_item_totals', 'adjust_woocommerce_get_order_item_totals' );

      function adjust_woocommerce_get_order_item_totals( $totals )
      unset($totals['cart_subtotal'] );
      return $totals;



      It isn't working, the Subtotal is visible on the Cart and Checkout pages.



      Is there any other function or do I have to create a separate woocommerce folder under my active theme and delete any reference of "Subtotal" from the templates.










      share|improve this question















      I want to remove the Subtotals from Cart, Checkout, Order Received, Order Details and the emails. I don't want to use CSS, as it won't remove the reference from the order details page and emails. I have tried this code:



      add_filter( 'woocommerce_get_order_item_totals', 'adjust_woocommerce_get_order_item_totals' );

      function adjust_woocommerce_get_order_item_totals( $totals )
      unset($totals['cart_subtotal'] );
      return $totals;



      It isn't working, the Subtotal is visible on the Cart and Checkout pages.



      Is there any other function or do I have to create a separate woocommerce folder under my active theme and delete any reference of "Subtotal" from the templates.







      php templates woocommerce cart checkout






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited Nov 14 '18 at 2:17









      LoicTheAztec

      85.4k136095




      85.4k136095










      asked Nov 13 '18 at 9:35









      mesumosumesumosu

      509




      509






















          1 Answer
          1






          active

          oldest

          votes


















          1














          1) For All orders pages and email notifications (Order received, Order pay, Order view and emails)



          Your code works and remove the subtotal line from totals lines:



          add_filter( 'woocommerce_get_order_item_totals', 'remove_subtotal_from_orders_total_lines', 100, 1 );
          function remove_subtotal_from_orders_total_lines( $totals )
          unset($totals['cart_subtotal'] );
          return $totals;



          Code goes in function.php file of your active child theme (active theme). Tested and works.



          enter image description here



          2) For cart and checkout pages:



          You need to create a separate "woocommerce" folder under your active theme for the following templates:



          For cart - cart/cart-totals.php | remove the code block from line 32 to 35:



          <tr class="cart-subtotal">
          <th><?php _e( 'Subtotal', 'woocommerce' ); ?></th>
          <td data-title="<?php esc_attr_e( 'Subtotal', 'woocommerce' ); ?>"><?php wc_cart_totals_subtotal_html(); ?></td>
          </tr>


          For checkout - checkout/review-order.php | remove the code block from line 58 to 61:



          <tr class="cart-subtotal">
          <th><?php _e( 'Subtotal', 'woocommerce' ); ?></th>
          <td><?php wc_cart_totals_subtotal_html(); ?></td>
          </tr>


          Save both templates… You are done.






          share|improve this answer






















            Your Answer






            StackExchange.ifUsing("editor", function ()
            StackExchange.using("externalEditor", function ()
            StackExchange.using("snippets", function ()
            StackExchange.snippets.init();
            );
            );
            , "code-snippets");

            StackExchange.ready(function()
            var channelOptions =
            tags: "".split(" "),
            id: "1"
            ;
            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: true,
            noModals: true,
            showLowRepImageUploadWarning: true,
            reputationToPostImages: 10,
            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%2fstackoverflow.com%2fquestions%2f53277895%2fremove-subtotal-line-from-cart-and-checkout-pages-in-woocommerce%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









            1














            1) For All orders pages and email notifications (Order received, Order pay, Order view and emails)



            Your code works and remove the subtotal line from totals lines:



            add_filter( 'woocommerce_get_order_item_totals', 'remove_subtotal_from_orders_total_lines', 100, 1 );
            function remove_subtotal_from_orders_total_lines( $totals )
            unset($totals['cart_subtotal'] );
            return $totals;



            Code goes in function.php file of your active child theme (active theme). Tested and works.



            enter image description here



            2) For cart and checkout pages:



            You need to create a separate "woocommerce" folder under your active theme for the following templates:



            For cart - cart/cart-totals.php | remove the code block from line 32 to 35:



            <tr class="cart-subtotal">
            <th><?php _e( 'Subtotal', 'woocommerce' ); ?></th>
            <td data-title="<?php esc_attr_e( 'Subtotal', 'woocommerce' ); ?>"><?php wc_cart_totals_subtotal_html(); ?></td>
            </tr>


            For checkout - checkout/review-order.php | remove the code block from line 58 to 61:



            <tr class="cart-subtotal">
            <th><?php _e( 'Subtotal', 'woocommerce' ); ?></th>
            <td><?php wc_cart_totals_subtotal_html(); ?></td>
            </tr>


            Save both templates… You are done.






            share|improve this answer



























              1














              1) For All orders pages and email notifications (Order received, Order pay, Order view and emails)



              Your code works and remove the subtotal line from totals lines:



              add_filter( 'woocommerce_get_order_item_totals', 'remove_subtotal_from_orders_total_lines', 100, 1 );
              function remove_subtotal_from_orders_total_lines( $totals )
              unset($totals['cart_subtotal'] );
              return $totals;



              Code goes in function.php file of your active child theme (active theme). Tested and works.



              enter image description here



              2) For cart and checkout pages:



              You need to create a separate "woocommerce" folder under your active theme for the following templates:



              For cart - cart/cart-totals.php | remove the code block from line 32 to 35:



              <tr class="cart-subtotal">
              <th><?php _e( 'Subtotal', 'woocommerce' ); ?></th>
              <td data-title="<?php esc_attr_e( 'Subtotal', 'woocommerce' ); ?>"><?php wc_cart_totals_subtotal_html(); ?></td>
              </tr>


              For checkout - checkout/review-order.php | remove the code block from line 58 to 61:



              <tr class="cart-subtotal">
              <th><?php _e( 'Subtotal', 'woocommerce' ); ?></th>
              <td><?php wc_cart_totals_subtotal_html(); ?></td>
              </tr>


              Save both templates… You are done.






              share|improve this answer

























                1












                1








                1






                1) For All orders pages and email notifications (Order received, Order pay, Order view and emails)



                Your code works and remove the subtotal line from totals lines:



                add_filter( 'woocommerce_get_order_item_totals', 'remove_subtotal_from_orders_total_lines', 100, 1 );
                function remove_subtotal_from_orders_total_lines( $totals )
                unset($totals['cart_subtotal'] );
                return $totals;



                Code goes in function.php file of your active child theme (active theme). Tested and works.



                enter image description here



                2) For cart and checkout pages:



                You need to create a separate "woocommerce" folder under your active theme for the following templates:



                For cart - cart/cart-totals.php | remove the code block from line 32 to 35:



                <tr class="cart-subtotal">
                <th><?php _e( 'Subtotal', 'woocommerce' ); ?></th>
                <td data-title="<?php esc_attr_e( 'Subtotal', 'woocommerce' ); ?>"><?php wc_cart_totals_subtotal_html(); ?></td>
                </tr>


                For checkout - checkout/review-order.php | remove the code block from line 58 to 61:



                <tr class="cart-subtotal">
                <th><?php _e( 'Subtotal', 'woocommerce' ); ?></th>
                <td><?php wc_cart_totals_subtotal_html(); ?></td>
                </tr>


                Save both templates… You are done.






                share|improve this answer














                1) For All orders pages and email notifications (Order received, Order pay, Order view and emails)



                Your code works and remove the subtotal line from totals lines:



                add_filter( 'woocommerce_get_order_item_totals', 'remove_subtotal_from_orders_total_lines', 100, 1 );
                function remove_subtotal_from_orders_total_lines( $totals )
                unset($totals['cart_subtotal'] );
                return $totals;



                Code goes in function.php file of your active child theme (active theme). Tested and works.



                enter image description here



                2) For cart and checkout pages:



                You need to create a separate "woocommerce" folder under your active theme for the following templates:



                For cart - cart/cart-totals.php | remove the code block from line 32 to 35:



                <tr class="cart-subtotal">
                <th><?php _e( 'Subtotal', 'woocommerce' ); ?></th>
                <td data-title="<?php esc_attr_e( 'Subtotal', 'woocommerce' ); ?>"><?php wc_cart_totals_subtotal_html(); ?></td>
                </tr>


                For checkout - checkout/review-order.php | remove the code block from line 58 to 61:



                <tr class="cart-subtotal">
                <th><?php _e( 'Subtotal', 'woocommerce' ); ?></th>
                <td><?php wc_cart_totals_subtotal_html(); ?></td>
                </tr>


                Save both templates… You are done.







                share|improve this answer














                share|improve this answer



                share|improve this answer








                edited Nov 14 '18 at 2:31

























                answered Nov 14 '18 at 2:16









                LoicTheAztecLoicTheAztec

                85.4k136095




                85.4k136095



























                    draft saved

                    draft discarded
















































                    Thanks for contributing an answer to Stack Overflow!


                    • 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%2fstackoverflow.com%2fquestions%2f53277895%2fremove-subtotal-line-from-cart-and-checkout-pages-in-woocommerce%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

                    Top Tejano songwriter Luis Silva dead of heart attack at 64

                    政党

                    天津地下鉄3号線