Thanks for your reply NogDog, thats what's happened but i'm pretty certain it's only the code which needs a slight adjustment as the template is still used; and as usual it was overwrote when updating but i re-added it then noticed the code no longer worked as it should.. i think something like "$price_excl_tax" may have changed; but i'm not to sure what this is and couldn't work anything out from the changelog. I keep my plugins up to date so it's an update within the last 2 months which has caused the issues.

P.s WooCommerce uses template files to display the data so in this case "single-product.php" is used to display the information on product pages, i used the code above to change how the price is displayed (hope that helps)

    I might try something like this at first, just to see if you're getting into that code:

    echo "<p>About to hit the if</p>";
    if ( $product->get_price_html() ) :
    echo "<p>Made it into the if</p>";
    

    (Or error_log() instead of echo if you prefer?)
    If neither shows up, then you at least know that you need to figure out why it's not getting there at all, whereas if only the first debug paragraph show, then the likely suspect is the get_price_html() method.

    PS: might be useful to add this while debugging:

    <?php
    ini_set('display_errors', true); // change to false or remove when you go live
    error_reporting(E_ALL);
    // rest of code...
    

    NogDog Thanks again for you reply, the code displays ok it's just not working as it should (Prices display as 0.00 and it also displays part of the code frontend) Debugging is beyond my PHP knowledge; if i set up a live draft site to replicate the issue would you be interested in taking a look?

      Well i'll be damned, just set up a test site and the code works fine so must be something conflicting on the actual website; is there any advice you can offer on how to approach troubleshooting my site?

        All fixed, not even a PHP issue #WordpressProblems

          Just an aside here - you shouldn't modify the plugin files at all. WooCommerce templates are nothing but hooks, so you can modify the output via your functions.php or another custom plugin file, or duplicate the file into a sub-directory of your theme as described in the manual and make your changes there. That way any changes you make aren't overwritten every time you update the plugin. Which, by the way, is quite often.

            Thanks for your input @maxxd i had actually set it up in a sub directory as you mentioned but occasionally when updating i still have to re-upload the files; curious how would i go about adding it to the functions.php The file i edit is single-product.php how do you target the template from the functions file?

            This is is the custom code used:

            if ( $product->get_price_html() ) :
            // Get the prices
            $price_excl_tax = wc_get_price_excluding_tax( $product ); // price without VAT
            $price_incl_tax = wc_get_price_including_tax( $product ); // price with VAT
            $tax_amount = $price_incl_tax - $price_excl_tax; // VAT amount
            // Display the prices
            ?>
            <span class="price price-excl"><?php echo wc_price( $price_excl_tax ); ?></span><br>
            <span class="price tax-price">+ VAT = <?php echo wc_price( $tax_amount ); ?></span><br>
            <span class="price price-incl">Total = <?php echo wc_price( $price_incl_tax ); ?></span>

            JackieChan i had actually set it up in a sub directory as you mentioned

            In which case you're fine - I'd be interested to know why you still have to upload the files on occasion, unless it's due to updates that WC made that caused the versioning to fall out of sync.

            As for using the functions.php file, unless they've changed something drastically in the past 2 or 3 months, WC templates are far more hooks than HTML. You can use those hooks just like any other in the system to modify what the template displays.

            23 days later

            maxxd Thanks i think initially i set it up wrong updates fine now!

              11 days later

              With respect to utilizing the functions.php record, except if they've changed something radically in the previous 50 TO 70 days, WC layouts are definitely a bigger number of snares than HTML. You can utilize those snares simply like some other in the framework to change what the layout shows.

              Thomas4 Thanks for your input, how do you go about finding the names of those snares?

                Write a Reply...