Move stock availability location in Woocommerce single product page





.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty{ height:90px;width:728px;box-sizing:border-box;
}







0















Can someone maybe help me to find a way to get the stock availability directly under the price?



I dont think there is a hook for it.



I have also tried to display stock status in price.php and remove the original. But no success so far:



Single product page



Help would be very much appreciated.










share|improve this question































    0















    Can someone maybe help me to find a way to get the stock availability directly under the price?



    I dont think there is a hook for it.



    I have also tried to display stock status in price.php and remove the original. But no success so far:



    Single product page



    Help would be very much appreciated.










    share|improve this question



























      0












      0








      0








      Can someone maybe help me to find a way to get the stock availability directly under the price?



      I dont think there is a hook for it.



      I have also tried to display stock status in price.php and remove the original. But no success so far:



      Single product page



      Help would be very much appreciated.










      share|improve this question
















      Can someone maybe help me to find a way to get the stock availability directly under the price?



      I dont think there is a hook for it.



      I have also tried to display stock status in price.php and remove the original. But no success so far:



      Single product page



      Help would be very much appreciated.







      php wordpress woocommerce stock price






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited Nov 25 '18 at 13:22









      LoicTheAztec

      97.9k1472114




      97.9k1472114










      asked Nov 24 '18 at 7:19









      Henk DuursmaHenk Duursma

      6




      6
























          1 Answer
          1






          active

          oldest

          votes


















          0















          1. Create single.php file in your active child theme (or active theme) in:
            woocommerce/single-product/add-to-cart/single.php



          2. Change the code to:



            <?php
            /**
            * Simple product add to cart
            *
            * This template can be overridden by copying it to yourtheme/woocommerce/single-product/add-to-cart/simple.php.
            *
            * HOWEVER, on occasion WooCommerce will need to update template files and you
            * (the theme developer) will need to copy the new files to your theme to
            * maintain compatibility. We try to do this as little as possible, but it does
            * happen. When this occurs the version of the template file will be bumped and
            * the readme will list any important changes.
            *
            * @see https://docs.woocommerce.com/document/template-structure/
            * @package WooCommerce/Templates
            * @version 3.4.0
            */

            defined( 'ABSPATH' ) || exit;

            global $post;

            $short_description = apply_filters( 'woocommerce_short_description', $post->post_excerpt );

            if ( ! $short_description ) {
            return;
            }

            global $product;

            if ( ! $product->is_purchasable() ) {
            return;
            }

            echo wc_get_stock_html( $product ); // WPCS: XSS ok.

            if ( $product->is_in_stock() ) : ?>

            <?php do_action( 'woocommerce_before_add_to_cart_form' ); ?>

            <form class="cart" action="<?php echo esc_url( apply_filters( 'woocommerce_add_to_cart_form_action', $product->get_permalink() ) ); ?>" method="post" enctype='multipart/form-data'>
            <?php do_action( 'woocommerce_before_add_to_cart_button' ); ?>

            <?php
            do_action( 'woocommerce_before_add_to_cart_quantity' );

            woocommerce_quantity_input( array(
            'min_value' => apply_filters( 'woocommerce_quantity_input_min', $product->get_min_purchase_quantity(), $product ),
            'max_value' => apply_filters( 'woocommerce_quantity_input_max', $product->get_max_purchase_quantity(), $product ),
            'input_value' => isset( $_POST['quantity'] ) ? wc_stock_amount( wp_unslash( $_POST['quantity'] ) ) : $product->get_min_purchase_quantity(), // WPCS: CSRF ok, input var ok.
            ) );

            do_action( 'woocommerce_after_add_to_cart_quantity' );
            ?>
            <div class="woocommerce-product-details__short-description">
            <?php echo $short_description; // WPCS: XSS ok. ?>
            </div>
            <button type="submit" name="add-to-cart" value="<?php echo esc_attr( $product->get_id() ); ?>" class="single_add_to_cart_button button alt"><?php echo esc_html( $product->single_add_to_cart_text() ); ?></button>

            <?php do_action( 'woocommerce_after_add_to_cart_button' ); ?>
            </form>

            <?php do_action( 'woocommerce_after_add_to_cart_form' ); ?>

            <?php endif; ?>



          3. Add this code to functions.php:



            remove_action( 'woocommerce_single_product_summary', 'woocommerce_template_single_excerpt', 20 );







          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%2f53456061%2fmove-stock-availability-location-in-woocommerce-single-product-page%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















            1. Create single.php file in your active child theme (or active theme) in:
              woocommerce/single-product/add-to-cart/single.php



            2. Change the code to:



              <?php
              /**
              * Simple product add to cart
              *
              * This template can be overridden by copying it to yourtheme/woocommerce/single-product/add-to-cart/simple.php.
              *
              * HOWEVER, on occasion WooCommerce will need to update template files and you
              * (the theme developer) will need to copy the new files to your theme to
              * maintain compatibility. We try to do this as little as possible, but it does
              * happen. When this occurs the version of the template file will be bumped and
              * the readme will list any important changes.
              *
              * @see https://docs.woocommerce.com/document/template-structure/
              * @package WooCommerce/Templates
              * @version 3.4.0
              */

              defined( 'ABSPATH' ) || exit;

              global $post;

              $short_description = apply_filters( 'woocommerce_short_description', $post->post_excerpt );

              if ( ! $short_description ) {
              return;
              }

              global $product;

              if ( ! $product->is_purchasable() ) {
              return;
              }

              echo wc_get_stock_html( $product ); // WPCS: XSS ok.

              if ( $product->is_in_stock() ) : ?>

              <?php do_action( 'woocommerce_before_add_to_cart_form' ); ?>

              <form class="cart" action="<?php echo esc_url( apply_filters( 'woocommerce_add_to_cart_form_action', $product->get_permalink() ) ); ?>" method="post" enctype='multipart/form-data'>
              <?php do_action( 'woocommerce_before_add_to_cart_button' ); ?>

              <?php
              do_action( 'woocommerce_before_add_to_cart_quantity' );

              woocommerce_quantity_input( array(
              'min_value' => apply_filters( 'woocommerce_quantity_input_min', $product->get_min_purchase_quantity(), $product ),
              'max_value' => apply_filters( 'woocommerce_quantity_input_max', $product->get_max_purchase_quantity(), $product ),
              'input_value' => isset( $_POST['quantity'] ) ? wc_stock_amount( wp_unslash( $_POST['quantity'] ) ) : $product->get_min_purchase_quantity(), // WPCS: CSRF ok, input var ok.
              ) );

              do_action( 'woocommerce_after_add_to_cart_quantity' );
              ?>
              <div class="woocommerce-product-details__short-description">
              <?php echo $short_description; // WPCS: XSS ok. ?>
              </div>
              <button type="submit" name="add-to-cart" value="<?php echo esc_attr( $product->get_id() ); ?>" class="single_add_to_cart_button button alt"><?php echo esc_html( $product->single_add_to_cart_text() ); ?></button>

              <?php do_action( 'woocommerce_after_add_to_cart_button' ); ?>
              </form>

              <?php do_action( 'woocommerce_after_add_to_cart_form' ); ?>

              <?php endif; ?>



            3. Add this code to functions.php:



              remove_action( 'woocommerce_single_product_summary', 'woocommerce_template_single_excerpt', 20 );







            share|improve this answer






























              0















              1. Create single.php file in your active child theme (or active theme) in:
                woocommerce/single-product/add-to-cart/single.php



              2. Change the code to:



                <?php
                /**
                * Simple product add to cart
                *
                * This template can be overridden by copying it to yourtheme/woocommerce/single-product/add-to-cart/simple.php.
                *
                * HOWEVER, on occasion WooCommerce will need to update template files and you
                * (the theme developer) will need to copy the new files to your theme to
                * maintain compatibility. We try to do this as little as possible, but it does
                * happen. When this occurs the version of the template file will be bumped and
                * the readme will list any important changes.
                *
                * @see https://docs.woocommerce.com/document/template-structure/
                * @package WooCommerce/Templates
                * @version 3.4.0
                */

                defined( 'ABSPATH' ) || exit;

                global $post;

                $short_description = apply_filters( 'woocommerce_short_description', $post->post_excerpt );

                if ( ! $short_description ) {
                return;
                }

                global $product;

                if ( ! $product->is_purchasable() ) {
                return;
                }

                echo wc_get_stock_html( $product ); // WPCS: XSS ok.

                if ( $product->is_in_stock() ) : ?>

                <?php do_action( 'woocommerce_before_add_to_cart_form' ); ?>

                <form class="cart" action="<?php echo esc_url( apply_filters( 'woocommerce_add_to_cart_form_action', $product->get_permalink() ) ); ?>" method="post" enctype='multipart/form-data'>
                <?php do_action( 'woocommerce_before_add_to_cart_button' ); ?>

                <?php
                do_action( 'woocommerce_before_add_to_cart_quantity' );

                woocommerce_quantity_input( array(
                'min_value' => apply_filters( 'woocommerce_quantity_input_min', $product->get_min_purchase_quantity(), $product ),
                'max_value' => apply_filters( 'woocommerce_quantity_input_max', $product->get_max_purchase_quantity(), $product ),
                'input_value' => isset( $_POST['quantity'] ) ? wc_stock_amount( wp_unslash( $_POST['quantity'] ) ) : $product->get_min_purchase_quantity(), // WPCS: CSRF ok, input var ok.
                ) );

                do_action( 'woocommerce_after_add_to_cart_quantity' );
                ?>
                <div class="woocommerce-product-details__short-description">
                <?php echo $short_description; // WPCS: XSS ok. ?>
                </div>
                <button type="submit" name="add-to-cart" value="<?php echo esc_attr( $product->get_id() ); ?>" class="single_add_to_cart_button button alt"><?php echo esc_html( $product->single_add_to_cart_text() ); ?></button>

                <?php do_action( 'woocommerce_after_add_to_cart_button' ); ?>
                </form>

                <?php do_action( 'woocommerce_after_add_to_cart_form' ); ?>

                <?php endif; ?>



              3. Add this code to functions.php:



                remove_action( 'woocommerce_single_product_summary', 'woocommerce_template_single_excerpt', 20 );







              share|improve this answer




























                0












                0








                0








                1. Create single.php file in your active child theme (or active theme) in:
                  woocommerce/single-product/add-to-cart/single.php



                2. Change the code to:



                  <?php
                  /**
                  * Simple product add to cart
                  *
                  * This template can be overridden by copying it to yourtheme/woocommerce/single-product/add-to-cart/simple.php.
                  *
                  * HOWEVER, on occasion WooCommerce will need to update template files and you
                  * (the theme developer) will need to copy the new files to your theme to
                  * maintain compatibility. We try to do this as little as possible, but it does
                  * happen. When this occurs the version of the template file will be bumped and
                  * the readme will list any important changes.
                  *
                  * @see https://docs.woocommerce.com/document/template-structure/
                  * @package WooCommerce/Templates
                  * @version 3.4.0
                  */

                  defined( 'ABSPATH' ) || exit;

                  global $post;

                  $short_description = apply_filters( 'woocommerce_short_description', $post->post_excerpt );

                  if ( ! $short_description ) {
                  return;
                  }

                  global $product;

                  if ( ! $product->is_purchasable() ) {
                  return;
                  }

                  echo wc_get_stock_html( $product ); // WPCS: XSS ok.

                  if ( $product->is_in_stock() ) : ?>

                  <?php do_action( 'woocommerce_before_add_to_cart_form' ); ?>

                  <form class="cart" action="<?php echo esc_url( apply_filters( 'woocommerce_add_to_cart_form_action', $product->get_permalink() ) ); ?>" method="post" enctype='multipart/form-data'>
                  <?php do_action( 'woocommerce_before_add_to_cart_button' ); ?>

                  <?php
                  do_action( 'woocommerce_before_add_to_cart_quantity' );

                  woocommerce_quantity_input( array(
                  'min_value' => apply_filters( 'woocommerce_quantity_input_min', $product->get_min_purchase_quantity(), $product ),
                  'max_value' => apply_filters( 'woocommerce_quantity_input_max', $product->get_max_purchase_quantity(), $product ),
                  'input_value' => isset( $_POST['quantity'] ) ? wc_stock_amount( wp_unslash( $_POST['quantity'] ) ) : $product->get_min_purchase_quantity(), // WPCS: CSRF ok, input var ok.
                  ) );

                  do_action( 'woocommerce_after_add_to_cart_quantity' );
                  ?>
                  <div class="woocommerce-product-details__short-description">
                  <?php echo $short_description; // WPCS: XSS ok. ?>
                  </div>
                  <button type="submit" name="add-to-cart" value="<?php echo esc_attr( $product->get_id() ); ?>" class="single_add_to_cart_button button alt"><?php echo esc_html( $product->single_add_to_cart_text() ); ?></button>

                  <?php do_action( 'woocommerce_after_add_to_cart_button' ); ?>
                  </form>

                  <?php do_action( 'woocommerce_after_add_to_cart_form' ); ?>

                  <?php endif; ?>



                3. Add this code to functions.php:



                  remove_action( 'woocommerce_single_product_summary', 'woocommerce_template_single_excerpt', 20 );







                share|improve this answer
















                1. Create single.php file in your active child theme (or active theme) in:
                  woocommerce/single-product/add-to-cart/single.php



                2. Change the code to:



                  <?php
                  /**
                  * Simple product add to cart
                  *
                  * This template can be overridden by copying it to yourtheme/woocommerce/single-product/add-to-cart/simple.php.
                  *
                  * HOWEVER, on occasion WooCommerce will need to update template files and you
                  * (the theme developer) will need to copy the new files to your theme to
                  * maintain compatibility. We try to do this as little as possible, but it does
                  * happen. When this occurs the version of the template file will be bumped and
                  * the readme will list any important changes.
                  *
                  * @see https://docs.woocommerce.com/document/template-structure/
                  * @package WooCommerce/Templates
                  * @version 3.4.0
                  */

                  defined( 'ABSPATH' ) || exit;

                  global $post;

                  $short_description = apply_filters( 'woocommerce_short_description', $post->post_excerpt );

                  if ( ! $short_description ) {
                  return;
                  }

                  global $product;

                  if ( ! $product->is_purchasable() ) {
                  return;
                  }

                  echo wc_get_stock_html( $product ); // WPCS: XSS ok.

                  if ( $product->is_in_stock() ) : ?>

                  <?php do_action( 'woocommerce_before_add_to_cart_form' ); ?>

                  <form class="cart" action="<?php echo esc_url( apply_filters( 'woocommerce_add_to_cart_form_action', $product->get_permalink() ) ); ?>" method="post" enctype='multipart/form-data'>
                  <?php do_action( 'woocommerce_before_add_to_cart_button' ); ?>

                  <?php
                  do_action( 'woocommerce_before_add_to_cart_quantity' );

                  woocommerce_quantity_input( array(
                  'min_value' => apply_filters( 'woocommerce_quantity_input_min', $product->get_min_purchase_quantity(), $product ),
                  'max_value' => apply_filters( 'woocommerce_quantity_input_max', $product->get_max_purchase_quantity(), $product ),
                  'input_value' => isset( $_POST['quantity'] ) ? wc_stock_amount( wp_unslash( $_POST['quantity'] ) ) : $product->get_min_purchase_quantity(), // WPCS: CSRF ok, input var ok.
                  ) );

                  do_action( 'woocommerce_after_add_to_cart_quantity' );
                  ?>
                  <div class="woocommerce-product-details__short-description">
                  <?php echo $short_description; // WPCS: XSS ok. ?>
                  </div>
                  <button type="submit" name="add-to-cart" value="<?php echo esc_attr( $product->get_id() ); ?>" class="single_add_to_cart_button button alt"><?php echo esc_html( $product->single_add_to_cart_text() ); ?></button>

                  <?php do_action( 'woocommerce_after_add_to_cart_button' ); ?>
                  </form>

                  <?php do_action( 'woocommerce_after_add_to_cart_form' ); ?>

                  <?php endif; ?>



                3. Add this code to functions.php:



                  remove_action( 'woocommerce_single_product_summary', 'woocommerce_template_single_excerpt', 20 );








                share|improve this answer














                share|improve this answer



                share|improve this answer








                edited Nov 25 '18 at 13:20









                LoicTheAztec

                97.9k1472114




                97.9k1472114










                answered Nov 24 '18 at 22:57









                Henk DuursmaHenk Duursma

                6




                6
































                    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%2f53456061%2fmove-stock-availability-location-in-woocommerce-single-product-page%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







                    這個網誌中的熱門文章

                    Xamarin.form Move up view when keyboard appear

                    Post-Redirect-Get with Spring WebFlux and Thymeleaf

                    Anylogic : not able to use stopDelay()