Add Woocommerce formatted product price to theme's product navigationCustom decimals in WooCommerce product prices for a product categoryChange product prices via a hook in WooCommerce 3Display product prices with a shortcode by product ID in WooCommerceDisplay the discounted price and percentage on Woocommerce productsSet product sale price programmatically in WooCommerce 3Custom Price for a specific product in WoocommerceCustom variable product formatted price without decimals in WoocommerceAdd Woocommerce product price (+ currency) with add to cart in a pageHide displayed product prices from Woocommerce Product Add-ons Fields

Gofer work in exchange for LoR

Why should I pay for an SSL certificate?

Will Force.com stop working on salesforce Lightning?

Select elements of a list by comparing it to another list

What should I do if actually I found a serious flaw in someone's PhD thesis and an article derived from that PhD thesis?

Attacking the Hydra

Problem with GFCI at start of circuit with both lights and two receptacles

How does the Moon's gravity affect Earth's oceans despite Earth's stronger gravitational pull?

Expressing a chain of boolean ORs using ILP

How does the ability of Bloodthirsty Aerialist resolve with other life link creatures?

Are there any rules on how characters go from 0th to 1st level in a class?

Why does Japan use the same type of AC power outlet as the US?

Build a mob of suspiciously happy lenny faces ( ͡° ͜ʖ ͡°)

Output with the same length always

Weird resistor with dots around it on the schematic

Why do so many people play out of turn on the last lead?

Meaning of だけはわからない

What ways are there to share spells between characters, besides a Ring of Spell Storing?

What if a restaurant suddenly cannot accept credit cards, and the customer has no cash?

The space of cusp forms for GL_2 over F_q(T)

Have there ever been other TV shows or Films that told a similiar story to the new 90210 show?

Minimum population for language survival

What should we do with manuals from the 80s?

Will some rockets really collapse under their own weight?



Add Woocommerce formatted product price to theme's product navigation


Custom decimals in WooCommerce product prices for a product categoryChange product prices via a hook in WooCommerce 3Display product prices with a shortcode by product ID in WooCommerceDisplay the discounted price and percentage on Woocommerce productsSet product sale price programmatically in WooCommerce 3Custom Price for a specific product in WoocommerceCustom variable product formatted price without decimals in WoocommerceAdd Woocommerce product price (+ currency) with add to cart in a pageHide displayed product prices from Woocommerce Product Add-ons Fields






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








1















Just installed Wordpress with BeTheme and Woocommerce in it and faced the following problem: when enter single product page there is Next-Prev buttons showing some info about next-prev product - name, date of upload, picture. Now I want to add price also but nothing found in StackOverflow works for me.



Here is my code, want to add the price instead of the date.



If need can provide the code of theme-shortcodes.php file.



Thank you in advance.



 if( is_object( $post ) )
// move this DOM element with JS
$output .= '<a class="fixed-nav fixed-nav-'. $next_prev .' format-'. get_post_format( $post ) .'" href="'. get_permalink( $post ) .'">';

$output .= '<span class="arrow"><i class="'. $icon .'"></i></span>';

$output .= '<div class="photo">';
$output .= get_the_post_thumbnail( $post->ID, 'blog-navi' );
$output .= '</div>';

$output .= '<div class="desc">';
$output .= '<h6>'. get_the_title( $post ) .'</h6>';
$output .= '<span class="date"><i class="icon-clock"></i>'. get_the_date(get_option('date_format'), $post->ID) .'</span>';
$output .= '</div>';

$output .= '</a>';










share|improve this question
































    1















    Just installed Wordpress with BeTheme and Woocommerce in it and faced the following problem: when enter single product page there is Next-Prev buttons showing some info about next-prev product - name, date of upload, picture. Now I want to add price also but nothing found in StackOverflow works for me.



    Here is my code, want to add the price instead of the date.



    If need can provide the code of theme-shortcodes.php file.



    Thank you in advance.



     if( is_object( $post ) )
    // move this DOM element with JS
    $output .= '<a class="fixed-nav fixed-nav-'. $next_prev .' format-'. get_post_format( $post ) .'" href="'. get_permalink( $post ) .'">';

    $output .= '<span class="arrow"><i class="'. $icon .'"></i></span>';

    $output .= '<div class="photo">';
    $output .= get_the_post_thumbnail( $post->ID, 'blog-navi' );
    $output .= '</div>';

    $output .= '<div class="desc">';
    $output .= '<h6>'. get_the_title( $post ) .'</h6>';
    $output .= '<span class="date"><i class="icon-clock"></i>'. get_the_date(get_option('date_format'), $post->ID) .'</span>';
    $output .= '</div>';

    $output .= '</a>';










    share|improve this question




























      1












      1








      1








      Just installed Wordpress with BeTheme and Woocommerce in it and faced the following problem: when enter single product page there is Next-Prev buttons showing some info about next-prev product - name, date of upload, picture. Now I want to add price also but nothing found in StackOverflow works for me.



      Here is my code, want to add the price instead of the date.



      If need can provide the code of theme-shortcodes.php file.



      Thank you in advance.



       if( is_object( $post ) )
      // move this DOM element with JS
      $output .= '<a class="fixed-nav fixed-nav-'. $next_prev .' format-'. get_post_format( $post ) .'" href="'. get_permalink( $post ) .'">';

      $output .= '<span class="arrow"><i class="'. $icon .'"></i></span>';

      $output .= '<div class="photo">';
      $output .= get_the_post_thumbnail( $post->ID, 'blog-navi' );
      $output .= '</div>';

      $output .= '<div class="desc">';
      $output .= '<h6>'. get_the_title( $post ) .'</h6>';
      $output .= '<span class="date"><i class="icon-clock"></i>'. get_the_date(get_option('date_format'), $post->ID) .'</span>';
      $output .= '</div>';

      $output .= '</a>';










      share|improve this question
















      Just installed Wordpress with BeTheme and Woocommerce in it and faced the following problem: when enter single product page there is Next-Prev buttons showing some info about next-prev product - name, date of upload, picture. Now I want to add price also but nothing found in StackOverflow works for me.



      Here is my code, want to add the price instead of the date.



      If need can provide the code of theme-shortcodes.php file.



      Thank you in advance.



       if( is_object( $post ) )
      // move this DOM element with JS
      $output .= '<a class="fixed-nav fixed-nav-'. $next_prev .' format-'. get_post_format( $post ) .'" href="'. get_permalink( $post ) .'">';

      $output .= '<span class="arrow"><i class="'. $icon .'"></i></span>';

      $output .= '<div class="photo">';
      $output .= get_the_post_thumbnail( $post->ID, 'blog-navi' );
      $output .= '</div>';

      $output .= '<div class="desc">';
      $output .= '<h6>'. get_the_title( $post ) .'</h6>';
      $output .= '<span class="date"><i class="icon-clock"></i>'. get_the_date(get_option('date_format'), $post->ID) .'</span>';
      $output .= '</div>';

      $output .= '</a>';







      php wordpress woocommerce product price






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited Mar 27 at 17:20









      LoicTheAztec

      108k15 gold badges90 silver badges129 bronze badges




      108k15 gold badges90 silver badges129 bronze badges










      asked Mar 27 at 12:29









      All ChannelsAll Channels

      365 bronze badges




      365 bronze badges

























          2 Answers
          2






          active

          oldest

          votes


















          0














          You can create a product object using the following function:



          $product = wc_get_product( $post->ID );


          And after that you will be able to access to all product's data. All available methods can be found here, but the ones you need are:



          $regular_price = $product->get_regular_price();
          $sale_price = $product->get_sale_price();
          $price = $product->get_price();


          and echo the price variable which price do you want to show.






          share|improve this answer

























          • Thank you, think that is. Problem is I'm not familiar with php so tried few times and the result was only broken page. May you show me example in my code?

            – All Channels
            Mar 27 at 13:02



















          0














          The best thing is to get the active formatted product price form the WC_Product Object instance using dedicated get_price_html() method.



          I have revisited a bit your code too:



          if( is_a( $post, 'WP_Post' ) && 'product' === get_post_type( $post ) )
          global $product;

          if( ! is_a( $product, 'WP_Product' ) )
          $product = wc_get_product( $post->ID );


          // move this DOM element with JS
          $output .= '<a class="fixed-nav fixed-nav-'. $next_prev .' format-'. get_post_format( $post ) .'" href="'. get_permalink( $post ) .'">
          <span class="arrow"><i class="'. $icon .'"></i></span>
          <div class="photo">' . get_the_post_thumbnail( $post->ID, 'blog-navi' ). '</div>
          <div class="desc">
          <h6>'. get_the_title( $post ) .'</h6>
          <span class="price">'. $product->get_price_html() .'</span>
          </div>
          </a>';



          Tested and works.






          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%2f55377247%2fadd-woocommerce-formatted-product-price-to-themes-product-navigation%23new-answer', 'question_page');

            );

            Post as a guest















            Required, but never shown

























            2 Answers
            2






            active

            oldest

            votes








            2 Answers
            2






            active

            oldest

            votes









            active

            oldest

            votes






            active

            oldest

            votes









            0














            You can create a product object using the following function:



            $product = wc_get_product( $post->ID );


            And after that you will be able to access to all product's data. All available methods can be found here, but the ones you need are:



            $regular_price = $product->get_regular_price();
            $sale_price = $product->get_sale_price();
            $price = $product->get_price();


            and echo the price variable which price do you want to show.






            share|improve this answer

























            • Thank you, think that is. Problem is I'm not familiar with php so tried few times and the result was only broken page. May you show me example in my code?

              – All Channels
              Mar 27 at 13:02
















            0














            You can create a product object using the following function:



            $product = wc_get_product( $post->ID );


            And after that you will be able to access to all product's data. All available methods can be found here, but the ones you need are:



            $regular_price = $product->get_regular_price();
            $sale_price = $product->get_sale_price();
            $price = $product->get_price();


            and echo the price variable which price do you want to show.






            share|improve this answer

























            • Thank you, think that is. Problem is I'm not familiar with php so tried few times and the result was only broken page. May you show me example in my code?

              – All Channels
              Mar 27 at 13:02














            0












            0








            0







            You can create a product object using the following function:



            $product = wc_get_product( $post->ID );


            And after that you will be able to access to all product's data. All available methods can be found here, but the ones you need are:



            $regular_price = $product->get_regular_price();
            $sale_price = $product->get_sale_price();
            $price = $product->get_price();


            and echo the price variable which price do you want to show.






            share|improve this answer













            You can create a product object using the following function:



            $product = wc_get_product( $post->ID );


            And after that you will be able to access to all product's data. All available methods can be found here, but the ones you need are:



            $regular_price = $product->get_regular_price();
            $sale_price = $product->get_sale_price();
            $price = $product->get_price();


            and echo the price variable which price do you want to show.







            share|improve this answer












            share|improve this answer



            share|improve this answer










            answered Mar 27 at 12:50









            Sukhjinder SinghSukhjinder Singh

            3172 silver badges14 bronze badges




            3172 silver badges14 bronze badges















            • Thank you, think that is. Problem is I'm not familiar with php so tried few times and the result was only broken page. May you show me example in my code?

              – All Channels
              Mar 27 at 13:02


















            • Thank you, think that is. Problem is I'm not familiar with php so tried few times and the result was only broken page. May you show me example in my code?

              – All Channels
              Mar 27 at 13:02

















            Thank you, think that is. Problem is I'm not familiar with php so tried few times and the result was only broken page. May you show me example in my code?

            – All Channels
            Mar 27 at 13:02






            Thank you, think that is. Problem is I'm not familiar with php so tried few times and the result was only broken page. May you show me example in my code?

            – All Channels
            Mar 27 at 13:02














            0














            The best thing is to get the active formatted product price form the WC_Product Object instance using dedicated get_price_html() method.



            I have revisited a bit your code too:



            if( is_a( $post, 'WP_Post' ) && 'product' === get_post_type( $post ) )
            global $product;

            if( ! is_a( $product, 'WP_Product' ) )
            $product = wc_get_product( $post->ID );


            // move this DOM element with JS
            $output .= '<a class="fixed-nav fixed-nav-'. $next_prev .' format-'. get_post_format( $post ) .'" href="'. get_permalink( $post ) .'">
            <span class="arrow"><i class="'. $icon .'"></i></span>
            <div class="photo">' . get_the_post_thumbnail( $post->ID, 'blog-navi' ). '</div>
            <div class="desc">
            <h6>'. get_the_title( $post ) .'</h6>
            <span class="price">'. $product->get_price_html() .'</span>
            </div>
            </a>';



            Tested and works.






            share|improve this answer





























              0














              The best thing is to get the active formatted product price form the WC_Product Object instance using dedicated get_price_html() method.



              I have revisited a bit your code too:



              if( is_a( $post, 'WP_Post' ) && 'product' === get_post_type( $post ) )
              global $product;

              if( ! is_a( $product, 'WP_Product' ) )
              $product = wc_get_product( $post->ID );


              // move this DOM element with JS
              $output .= '<a class="fixed-nav fixed-nav-'. $next_prev .' format-'. get_post_format( $post ) .'" href="'. get_permalink( $post ) .'">
              <span class="arrow"><i class="'. $icon .'"></i></span>
              <div class="photo">' . get_the_post_thumbnail( $post->ID, 'blog-navi' ). '</div>
              <div class="desc">
              <h6>'. get_the_title( $post ) .'</h6>
              <span class="price">'. $product->get_price_html() .'</span>
              </div>
              </a>';



              Tested and works.






              share|improve this answer



























                0












                0








                0







                The best thing is to get the active formatted product price form the WC_Product Object instance using dedicated get_price_html() method.



                I have revisited a bit your code too:



                if( is_a( $post, 'WP_Post' ) && 'product' === get_post_type( $post ) )
                global $product;

                if( ! is_a( $product, 'WP_Product' ) )
                $product = wc_get_product( $post->ID );


                // move this DOM element with JS
                $output .= '<a class="fixed-nav fixed-nav-'. $next_prev .' format-'. get_post_format( $post ) .'" href="'. get_permalink( $post ) .'">
                <span class="arrow"><i class="'. $icon .'"></i></span>
                <div class="photo">' . get_the_post_thumbnail( $post->ID, 'blog-navi' ). '</div>
                <div class="desc">
                <h6>'. get_the_title( $post ) .'</h6>
                <span class="price">'. $product->get_price_html() .'</span>
                </div>
                </a>';



                Tested and works.






                share|improve this answer













                The best thing is to get the active formatted product price form the WC_Product Object instance using dedicated get_price_html() method.



                I have revisited a bit your code too:



                if( is_a( $post, 'WP_Post' ) && 'product' === get_post_type( $post ) )
                global $product;

                if( ! is_a( $product, 'WP_Product' ) )
                $product = wc_get_product( $post->ID );


                // move this DOM element with JS
                $output .= '<a class="fixed-nav fixed-nav-'. $next_prev .' format-'. get_post_format( $post ) .'" href="'. get_permalink( $post ) .'">
                <span class="arrow"><i class="'. $icon .'"></i></span>
                <div class="photo">' . get_the_post_thumbnail( $post->ID, 'blog-navi' ). '</div>
                <div class="desc">
                <h6>'. get_the_title( $post ) .'</h6>
                <span class="price">'. $product->get_price_html() .'</span>
                </div>
                </a>';



                Tested and works.







                share|improve this answer












                share|improve this answer



                share|improve this answer










                answered Mar 27 at 17:20









                LoicTheAztecLoicTheAztec

                108k15 gold badges90 silver badges129 bronze badges




                108k15 gold badges90 silver badges129 bronze badges






























                    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%2f55377247%2fadd-woocommerce-formatted-product-price-to-themes-product-navigation%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

                    Kamusi Yaliyomo Aina za kamusi | Muundo wa kamusi | Faida za kamusi | Dhima ya picha katika kamusi | Marejeo | Tazama pia | Viungo vya nje | UrambazajiKuhusu kamusiGo-SwahiliWiki-KamusiKamusi ya Kiswahili na Kiingerezakuihariri na kuongeza habari

                    Swift 4 - func physicsWorld not invoked on collision? The Next CEO of Stack OverflowHow to call Objective-C code from Swift#ifdef replacement in the Swift language@selector() in Swift?#pragma mark in Swift?Swift for loop: for index, element in array?dispatch_after - GCD in Swift?Swift Beta performance: sorting arraysSplit a String into an array in Swift?The use of Swift 3 @objc inference in Swift 4 mode is deprecated?How to optimize UITableViewCell, because my UITableView lags

                    Access current req object everywhere in Node.js ExpressWhy are global variables considered bad practice? (node.js)Using req & res across functionsHow do I get the path to the current script with Node.js?What is Node.js' Connect, Express and “middleware”?Node.js w/ express error handling in callbackHow to access the GET parameters after “?” in Express?Modify Node.js req object parametersAccess “app” variable inside of ExpressJS/ConnectJS middleware?Node.js Express app - request objectAngular Http Module considered middleware?Session variables in ExpressJSAdd properties to the req object in expressjs with Typescript