• Resolved stefrikhof

    (@stefrikhof)


    I updated my hosting php version to 8.1.23. After that i installed Yoast premium and Yoast SEO Woocommerce. Now my product page isn’t showing correctly. Looks like container / css file is missing or not loading.

    I tried to check all the plug-ins by deactivating them one by one. If i deactivate Really Simple SSL the normal styling is back but the page loads to a certain point. So the footer isn’t loading and showing.

    Screenshot.
    https://aedonline.nl/image.png

    For now i kept deactivating the Really Simple SSL plugin because without it will load the page partially so the shop does function.

    Anyone got any tips or help? Tried everything i know so far…

    The page I need help with: [log in to see the link]

Viewing 6 replies - 1 through 6 (of 6 total)
  • Thread Starter stefrikhof

    (@stefrikhof)

    Also on a catergory page it also doesn’t show all the products and there is no pagination showing. Which there is.

    Link: https://aedonline.nl/product-categorie/aed

    Its just verry strange because this site is always working correctly without any problems for almost 2 years already.

    Moderator bcworkz

    (@bcworkz)

    Updating to a recent PHP version can introduce errors in older code that has never been updated to maintain compatibility.

    At the bottom of each page we get “Er heeft zich een kritieke fout voorgedaan op deze site.” (“A critical error has occurred on this site” for any non-Dutch speakers following along)

    Please check your server’s PHP error log for more specific information about what error(s) occurred where. Sometimes it’s an easy fix, sometimes it’s more complicated. Whether it’s something you can fix yourself or not, I recommend reporting the problem to the developer responsible for the erroneous code so the fix can be passed on to all users.

    Thread Starter stefrikhof

    (@stefrikhof)

    Thanks bvworkz for your reaction. I looked at the PHP error log and found the following:

    AH01071: Got error ‘PHP message: PHP Fatal error: Uncaught TypeError: number_format(): Argument #1 ($num) must be of type float, string given in /home/aedonline.nl/httpdocs/wp-content/themes/aedonline/functions.php:95\nStack trace:\n#0 /home/aedonline.nl/httpdocs/wp-content/themes/aedonline/functions.php(95): number_format()\n#1 /home/aedonline.nl/httpdocs/wp-includes/class-wp-hook.php(324): edit_price_display()\n#2 /home/aedonline.nl/httpdocs/wp-includes/plugin.php(205): WP_Hook->apply_filters()\n#3 /home/aedonline.nl/httpdocs/wp-content/plugins/woocommerce/includes/abstracts/abstract-wc-product.php(1884): apply_filters()\n#4 /home/aedonline.nl/httpdocs/wp-content/plugins/woocommerce/templates/loop/price.php(25): WC_Product->get_price_html()\n#5 /home/aedonline.nl/httpdocs/wp-content/plugins/woocommerce/includes/wc-core-functions.php(345): include(‘…’)\n#6 /home/aedonline.nl/httpdocs/wp-content/plugins/woocommerce/includes/wc-template-functions.php(1404): wc_get_template()\n#7 /home/aedonline.nl/httpdocs/wp-includes/class-wp-hook…’, referer: https://www.google.com/

    Haven’t had time to fix this yet and not really sure were to start.

    Moderator bcworkz

    (@bcworkz)

    Looks to be an issue with your theme. What’s the code at line 95 of its functions.php file? I’m guessing it’s something roughly like:
    echo number_format( $price, 2, '.', ',');

    Try altering like so:
    echo number_format( floatval( $price ), 2, '.', ',');

    Thread Starter stefrikhof

    (@stefrikhof)

    I had there some code so i get the right prices and classes arround them to style them correctly.

    // Prijs tonen
    function edit_price_display() {
        global $product;
        $regular_price = $product->get_regular_price();
        $sale_price = $product->get_sale_price();
        $normal_price = $product->get_price();
        $price_btw = $product->get_price_including_tax();
        $regular_price = number_format($regular_price, 2, ",", ".");
        $sale_price = number_format( floatval($sale_price), 2, ",", ".");     
        $normal_price = number_format($normal_price, 2, ",", "."); 
        $price_btw = number_format($price_btw, 2, ",", ".");
        if ($sale_price > 0) {
            $display_price = '<span class="price">';
            $display_price .= '<span class="shopping-prijs amount striped">€' . $regular_price . '<small class="woocommerce-price-suffix"> Excl. BTW</small></span>';
            $display_price .= '<br>';
            $display_price .= '<span class="shopping-prijs amount">€' . $normal_price . '<small class="woocommerce-price-suffix"> Excl. BTW</small></span>';
            $display_price .= '<br>';
            $display_price .= '<span class="woocommerce-Price-amount amount" itemprop="price">€' . $price_btw . '<small class="woocommerce-price-suffix"> Incl. BTW</small></span>';
            $display_price .= '</span>';
            return $display_price;
        } else {
            $display_price = '<span class="price">';
            $display_price .= '<span class="shopping-prijs amount">€' . $normal_price . '<small class="woocommerce-price-suffix"> Excl. BTW</small></span>';
            $display_price .= '<br>';
            $display_price .= '<span class="woocommerce-Price-amount amount" itemprop="price">€' . $price_btw . '<small class="woocommerce-price-suffix"> Incl. BTW</small></span>';
            $display_price .= '</span>';
            return $display_price;
        }
    }
    add_filter('woocommerce_get_price_html', 'edit_price_display', 10, 2);

    You’re suggestion has fixed the problem but does it also needs to be corrected for the other lines of code?

    Moderator bcworkz

    (@bcworkz)

    It depends on context. If there is no chance a numeric variable will occur as string type, and that it’ll reliably be float type, then there’s no need. OTOH there’s little harm in applying floatval() to a variable that is already float type. It does add a very tiny amount of execution time, but would not cause any sort of warning or notice.

    If you don’t encounter any more errors then applying floatval() elsewhere is probably unwarranted but you could do so anyway. But consider that if your theme is subject to periodic updates, any alterations you apply will be undone during an update. I suggest notifying the theme’s devs about the error so they can fix their source code to benefit everyone. Then you wouldn’t need to re-patch your theme’s code after updates.

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘Woocommerce product page not showing correctly’ is closed to new replies.