• Resolved Mikey

    (@mikeyhash)


    While checking up my site with debug log on, I’ve encountered these PHP notices:

    Notice: A non well formed numeric value encountered in \wp-content\plugins\msrp-for-woocommerce\includes\class-alg-wc-msrp-core.php on line 701

    (i.e. 701. $diff = $msrp - $price;)

    Notice: A non well formed numeric value encountered in \wp-content\plugins\msrp-for-woocommerce\includes\class-alg-wc-msrp-core.php on line 708

    (i.e. 708. round( $diff / $msrp * 100, $this->options['msrp_display'][ $section_id ]['you_save_round'] ),

    Maybe it also has something to do with the other issue that I’ve mentioned in a previous topic regarding rounding values which still don’t work properly?

    Thanks

Viewing 15 replies - 1 through 15 (of 17 total)
  • Plugin Contributor Algoritmika

    (@algoritmika)

    Hi @mikeyhash,

    Thank you for the info. Will definetely check that first thing tomorrow morning. Will get back to you here asap.

    Plugin Contributor Algoritmika

    (@algoritmika)

    Hi @mikeyhash,

    We’ve just released new v1.3.1. Could you please try and let me know if there is still message in debug log and if rounding issue is still there. Unfortunately I still was unable to reproduce it on my server – no messages in log here, but I’ve added additional conversion to float, so maybe that will help. Generally it looks like this notice is the reason why rounding is happening on your server for the MSRP. By the way – maybe you can let me know which PHP version do you have installed on your server (you can check it in “WooCommerce > Status” in your admin dashboard)?

    Thread Starter Mikey

    (@mikeyhash)

    Well, no more messages in debug now, but it still doesn’t display the exact MSRP amount. The notices would’ve appeared only with respect to the MSRP that are not fixed numbers.

    For instance, for products where I have MSRP = 139,70 -> it displays 139,00 and there was the debug notice. The debug notices are gone with plugin ver 1.3.1, but MSRP still displays 139,00.

    My website runs on PHP version 7.2.11, with Woocommerce version 3.5.0.

    This rounding issue is becoming really annoying. Any other ideas?

    Please keep in mind that my national currency is with a comma (“,”) and not a dot (“.”). WooCommerce has my national currency already built-in, so no issues with the original price / sale price. But maybe your plugin is not properly configured to work for commas? (Just throwing out non-developer-skills ideas)

    • This reply was modified 6 years ago by Mikey.
    Plugin Contributor Algoritmika

    (@algoritmika)

    Hi again @mikeyhash,

    You may be correct – the problem can be in wrong dot / comma parsing. Please give me an hour or two to release the fix.

    Plugin Contributor Algoritmika

    (@algoritmika)

    Hi again @mikeyhash,

    Ok, hopefully I’ve managed to fix it. Please update to v1.3.2 and please let me know if it’s solved. You were correct – comma decimal separator in price wasn’t parsed correctly.

    Thread Starter Mikey

    (@mikeyhash)

    Hi @algoritmika,

    Updated, tested and now it works without any other issue.

    It appears that we finally managed to find the damned culprit. ??

    You may also mark the other topic as resolved.

    Thank you, I really appreciate it.

    Plugin Contributor Algoritmika

    (@algoritmika)

    Hi @mikeyhash,

    Really happy to hear it’s solved! And thanks for pointing me in a right direction.

    Thread Starter Mikey

    (@mikeyhash)

    Hi @algoritmika,

    This issue somehow came back.

    Here’s what I get -> https://prntscr.com/maihda

    These are the two lines in my class-alg-wc-msrp-core.php:
    721) $diff = $msrp - $price;
    728) round( $diff / $msrp * 100, $this->options['msrp_display'][ $section_id ]['you_save_round'] ),

    Can you please help?

    Thank you.

    Plugin Contributor Algoritmika

    (@algoritmika)

    Hi @mikeyhash,

    Hmm.. That’s strange. Lines you mentioned are different in latest plugin version (705 instead of 721 and 712 instead of 728). Which plugin version do you have installed? Is it latest v1.3.2?

    Thread Starter Mikey

    (@mikeyhash)

    Yes, I have 1.3.2. And I know the lines are different, that’s why I copy-pasted mine here. I’ve added a few lines and also tried to get rid of the issue described below.

    Last time, to solve the issues, I think you added these to the code:

    1) `if ( ! empty( $msrp ) ) {
    $msrp = str_replace( ‘,’, ‘.’, $msrp );
    $msrp = floatval( $msrp );
    }`
    and
    2) '%msrp%' => wc_price( $msrp, array( 'currency' => $currency ) ),

    This solved the issue, but it had one flaw that I’ve tried to fix by myself: I didn’t want for %msrp% to inherit the style (font color and size) applied to regular wc prices. I needed to make the two set of prices visually distinct from one another.

    So what I basically did was to remove the wc_price() function and just leave it as '%msrp%' => $msrp; and to also remove entirely the 4 lines from point 1) above.

    This way the MSRP is displayed as expected, but gives the debug Notices.

    Therefore, how can I keep the wc_price() format, but at the same time to be able to style the %msrp% as I please in terms of font-size and color?

    Plugin Contributor Algoritmika

    (@algoritmika)

    Hi again @mikeyhash,

    Ok – if you’ve removed those 4 lines from “point 1)”, it’s clear why the debug notices are back. Those lines are needed to convert comma representation to correct (i.e. dot) representation of decimal numbers in PHP. I would suggest instead of making any modifications to the plugin, just use CSS to style MSRP differently from main price. MSRP is wrapped in <span id="alg_wc_msrp"></span>, so you can add custom CSS (e.g. to “Dashboard > Appearance > Customize > Additional CSS”) like this:

    #alg_wc_msrp {
    	color: red;
    	font-size: small;
    }

    Please let me know if that’s good enough.

    Thread Starter Mikey

    (@mikeyhash)

    This is what I’m trying to explain to you. Using CSS like you suggested is not going to work, because of the wc_price() function. And I can’t figure out how to override that.

    It’s like this: <span id="alg_wc_msrp">%msrp%</span>, but %msrp% = wc_price(&msrp);.

    Therefore, you cannot change the font-size and color by using an outer rule, because there already is an inner rule given by wc_price().

    Plugin Contributor Algoritmika

    (@algoritmika)

    @mikeyhash,

    Actually I’ve just tried it on my test server and both color and font size were overridden properly (i.e. MSRP became red and small). I’m not very good at CSS, but maybe you need to add !important to it (it worked without it on my test server, but maybe that will be different on your theme/site), i.e.:

    #alg_wc_msrp {
    	color: red !important;
    	font-size: small !important;
    }
    • This reply was modified 5 years, 10 months ago by Algoritmika.
    Thread Starter Mikey

    (@mikeyhash)

    !important would not work in my case.

    Here’s the console, it makes it easier to understand -> https://prntscr.com/maovll

    So, as you can see, using wc_price() gives the inner span these 2 classes (<span class="woocommerce-Price-amount amount"> which are the same as for the Product’s Regular Price. Thus, both Regular Price and MSRP will look the same.

    Now that I think about it, could it possible be that my theme has somehow customized Woocommerce’s wc_price() function? Otherwise, this would mean that these classes belong to WooCommerce and you should’ve had the same issue in your tests, but you don’t. xD

    • This reply was modified 5 years, 10 months ago by Mikey.
    Plugin Contributor Algoritmika

    (@algoritmika)

    And if you try to set inner elements directly, it still doesn’t work? I.e.:

    #alg_wc_msrp .woocommerce-Price-amount {
    	color: red !important;
    	font-size: small !important;
    }
    #alg_wc_msrp .woocommerce-Price-amount .woocommerce-Price-currencySymbol {
    {
    	color: green !important;
    	font-size: small !important;
    }

    P.S. And it looks like your theme didn’t customize wc_price() function – all HTML elements from your screenshot look exactly the same on my server.

    • This reply was modified 5 years, 10 months ago by Algoritmika.
Viewing 15 replies - 1 through 15 (of 17 total)
  • The topic ‘PHP Notice in Debug log mode’ is closed to new replies.