• Resolved DensitySK

    (@densitysk)


    HI,

    while creating a Facebook feed I have noticed a facebook error message that some of my items have too many decimal numbers – instead of 84,00 the value is 84,0000000054

    This is happening on Product Bundle items created via the official Woocommerce product bundle plugin that has an option to calculate the price based on the sum of all components. If there is a component that has a discount in percentage applied to it, the result is a long number with many decimal spaces as above – even though Woocommerce correctly displays all shop prices only with two decimals as set by shop admin

    Example XML feed source

    <item>
    <g:id>2254</g:id>
    <g:availability>in stock</g:availability>
    <g:condition>New</g:condition>
    <g:description>XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX</g:description>
    <g:image_link>https://www.XXXX.sk/wp-content/uploads/XXXXXXXXXXXXXXXXX.jpg</g:image_link&gt;
    <g:link>https://www.XXXXX.sk/product/XXXXXXXXXXXXXXXXXXXXXXXXXXX/?utm_source=Facebook Catalog Feed / Instagram&utm_campaign=Facebook Feed&utm_medium=cpc&utm_term=2254</g:link>
    <g:title>XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX</g:title>
    <g:price>EUR 85,000029</g:price>
    <g:brand>XXXXXXXXXXXXXXXXXXXX</g:brand>
    <g:google_product_category>296</g:google_product_category>
    <g:mpn>XXXXXXXXXXXXXX</g:mpn>
    <g:shipping_weight>0.14</g:shipping_weight>
    <g:identifier_exists>yes</g:identifier_exists>
    </item>

    Do you have a soulution for that?

    Kind regards
    Michal

Viewing 15 replies - 1 through 15 (of 16 total)
  • Hi Michal,

    Thanks for using our plugin and reaching out to us

    Unfortunately there is nothing we can do about this, the plugin is just using the price it gets returned from WooCommerce / the bundle plugin.

    Thread Starter DensitySK

    (@densitysk)

    I have contacted the Woocommerce support and they have confirmed, that it should not be related to their bundle product plugin. The product bundle plugins generate a price with decimals based on the woocommerce settings. Even if I export the product data in a regular CSV file (i.e. I export orders with these products, etc) than they always have a price with two decimal spaces as set in the woocommerce settings. Therefore please check again. Here the answer from Woocommerce:

    Things we’ve tested:
    During the chat we tried to export the products in a CSV file however, you mentioned that your issue was with the XML format.
    Also, you shared the link to your conversation with the developers of Product Feed PRO for WooCommerce here: https://www.ads-software.com/support/topic/change-decimal-separator-2/
    After the chat, I forwarded your question to our developers and they got back to me with the following answer:
    Product Bundles doesn’t include any code that determines how many decimals should be used in an XML context.
    In general, Product Bundles falls back to the WooCommerce core decimal precision settings: https://d.pr/i/BqidA4. From the data they shared, I understand that all decimals show up in the XML export. So, there is a high chance that the plugin used to do this export, doesn’t respect the WooCommerce core settings and uses its own decimal precision settings.
    Next steps:
    As Product Bundles just respects the rules set by the core WooCommerce Decimal settings I’d suggest checking whether something is overwriting that setting. Possibly another plugin.
    Finally, please forward this information to the developers of Product Feed PRO for WooCommerce so that they can further test this issue.

    • This reply was modified 2 years, 8 months ago by Jan Dembowski. Reason: Formatting

    Product Bundles just respects the rules set by the core WooCommerce Decimal setting

    , and so does our plugin. Yet still somehow somewhere extra decimals are added.

    • Are you perhaps using another 3th party plugin that does things with sale / discount prices that could be causing this?
    • Can you share with us screenshots of your WooCommerce decimal settings configuration and screenshots of the product edit pages of the above bundled product so we can try reproducing everything at our end?
    • A screenshot of your field mapping page
    Thread Starter DensitySK

    (@densitysk)

    HI,

    Are you perhaps using another 3th party plugin that does things with sale / discount prices that could be causing this?
    No – I do not use any kind of plugin that could affect the price calculation or similar.
    Here is the screenshot of plugins that I use if that can help you: https://ibb.co/sH68s96

    Can you share with us screenshots of your WooCommerce decimal settings configuration and screenshots of the product edit pages of the above bundled product so we can try reproducing everything at our end?
    Here is the screenshot of the decimal settings
    https://ibb.co/K6LmShk
    Here is the link to an example product where the price has correct 2 decimals on the website:
    https://www.density.sk/product/standard-pci-e-3-0-riser-cable-with-bracket-v2/

    Here is the link to the product settings in the backend:
    https://ibb.co/mrjTkHs

    Here is the excerpt from the Facebook Feed with the incorrect price with a lot of decimals

    <item>
    <g:id>2253</g:id>
    <g:availability>in stock</g:availability>
    <g:condition>New</g:condition>
    <g:description>ADT-Link PCIe 3.0 16x riser cable V2 in 23cm length, improved shielding and mounting bracket</g:description>
    <g:image_link>https://www.density.sk/wp-content/uploads/R33SL-23CM-Gen3-Standard-Bracket-Riser-Cable-2.jpg</g:image_link>
    <g:link>https://www.density.sk/product/standard-pci-e-3-0-riser-cable-with-bracket-v2/?utm_source=Facebook Catalog Feed / Instagram&utm_campaign=Facebook Feed&utm_medium=cpc&utm_term=2253</g:link>
    <g:title>Standard PCIe 3.0 Riser Cable with Bracket V2</g:title>
    <g:price>EUR 29,000015</g:price>
    <g:brand>ADT-Link,Sliger Designs</g:brand>
    <g:google_product_category>296</g:google_product_category>
    <g:mpn>PCIE-SINGLE-GEN3-V2</g:mpn>
    <g:shipping_weight>0.14</g:shipping_weight>
    <g:identifier_exists>yes</g:identifier_exists>
    </item>

    A screenshot of your field mapping page
    Screenshot of field mapping for facebook feed https://ibb.co/g78jHxQ

    Here is also the screenshot from Facebook Commerce manager with related visible error https://ibb.co/7NB8jBj

    • This reply was modified 2 years, 8 months ago by DensitySK.

    Hi,

    Thanks for this. We were now able to reproduce the issue at hand and can, with a 100% certainty say, that the WooCommerce bundled plugin is returning the prices like this.

    When calling this code:

    if ($this->woosea_is_plugin_active('woocommerce-product-bundles/woocommerce-product-bundles.php')){
    $product_data['price'] = get_post_meta($product_data['id'], '_price', true);
    $product_data['sale_price'] = get_post_meta($product_data['id'], '_sale_price', true);
    
    error_log($product_data['price']);                                                error_log($product_data['sale_price']);

    We are getting this returned for a test bundled product of ours:
    [21-Mar-2022 15:26:26 UTC] 166.9429
    [21-Mar-2022 15:26:26 UTC] 166.9429

    I think the issue at hand is actually being caused by the discount percentage you are using, which they probably did not anticipate on: 42.8571 (with 4 decimals).

    Now the ideal situation would be for them to solve the issue at hand but when they are unwilling to do so let us know so we can try fixing it at our end.

    Thread Starter DensitySK

    (@densitysk)

    HI,

    unfortunately woocommerce is very unwilling to help in this and insists that the issue is with the feed export plugin. Would you be able to check for a possible future fix?

    We did already, we pushed out a new release yesterday that should solve the issue for you. Can you update the plugin and see if it works for you?

    Thread Starter DensitySK

    (@densitysk)

    Hi,

    I have noticed it and have already updated. But the weird decimals are still there. I tried to manually refresh the product feed multiple times as well as disabled caching plugin, but the feed still includes those

    <item>
    <g:id>2255</g:id>
    <g:availability>in stock</g:availability>
    <g:condition>New</g:condition>
    <g:price>EUR 85,000029</g:price>
    <g:brand>Linkup,Sliger Designs</g:brand>
    <g:google_product_category>296</g:google_product_category>
    <g:shipping_weight>0.14</g:shipping_weight>
    <g:identifier_exists>yes</g:identifier_exists>
    </item>

    That really wouldn’t be possible as we round all prices to two decimals. Sounds like your feed is not refreshing or indeed cached. Did you already try creating a new feed?

    Thread Starter DensitySK

    (@densitysk)

    Not yet. i can give it a try. But I have had this issue in general with refreshing the feed. Even when I disable my caching plugin completely. Not sure why that is.

    Thread Starter DensitySK

    (@densitysk)

    tried and it is not working. I have created a copy and tried to create the first feed, but it is simply stuck in processing at 0%. Caching is disabled and I have followed your tutorial here:
    https://adtribes.io/help-my-feed-processing-is-stuck/

    I have found out, that as soon as I try to refresh any product feed, I get a fatal errors in my logs:

    2022-03-22T14:33:08+00:00 CRITICAL Uncaught TypeError: round(): Argument #1 ($num) must be of type int|float, string given in /data/f/c/fc2fe6bd-5916-44b4-b9c0-13c5319e4e79/xxxxxx/web/wp-content/plugins/woo-product-feed-pro/classes/class-get-products.php:2939
    Stack trace:
    #0 /data/f/c/fc2fe6bd-5916-44b4-b9c0-13c5319e4e79/xxxxxx/web/wp-content/plugins/woo-product-feed-pro/classes/class-get-products.php(2939): round('', 2)
    #1 /data/f/c/fc2fe6bd-5916-44b4-b9c0-13c5319e4e79/xxxxxx/web/wp-content/plugins/woo-product-feed-pro/woocommerce-sea.php(4556): WooSEA_Get_Products->woosea_get_products(Array)
    #2 /data/f/c/fc2fe6bd-5916-44b4-b9c0-13c5319e4e79/xxxxxx/web/wp-content/plugins/woo-product-feed-pro/woocommerce-sea.php(2189): woosea_continue_batch('eCrcNfm5tJrmgFV...')
    #3 /data/f/c/fc2fe6bd-5916-44b4-b9c0-13c5319e4e79/xxxxxx/web/wp-includes/class-wp-hook.php(307): woosea_project_refresh('')
    #4 /data/f/c/fc2fe6bd-5916-44b4-b9c0-13c5319e4e79/xxxxxx/web/wp-includes/class-wp-hook.php(331): WP_Hook->apply_filters('', Array)
    #5 /data/f/c/fc2fe6bd-5916-44b4-b9c0-13c5319e4e79/xxxxxx/web/wp-includes/plugin.php(474): WP_Hook->do_action(Array)
    #6 /data/f/c/fc2fe6bd-5916-44b4-b9c0-13c5319e4e79/xxxxxx/web/wp-admin/admin-ajax.php(187): do_action('wp_ajax_woosea_...')
    #7 {main}
      thrown in /data/f/c/fc2fe6bd-5916-44b4-b9c0-13c5319e4e79/xxxxxx/web/wp-content/plugins/woo-product-feed-pro/classes/class-get-products.php on line 2939

    Ok. that means the rounding to two decimals is not working as WooCommerce apparently doesn’t return the prices as an int|float. Unfortunately that means we will have to revert back the changes we made and just go with the prices that WooCommerce returns, even when that is more than 2 decimal prices.

    Thread Starter DensitySK

    (@densitysk)

    Woocommerce support has responded with the following

    Our developers did come back to us regarding your issue and this was what was mentioned:
    ? When calculating the bundled item discounts, Product Bundles uses the wc_get_rounding_precision() core function to decide how many decimals to use in the calculation. According to the function’s documentation
    ? So, if your price precision is set to 2 digits in the WooCommerce settings, this function will use 4 digits for calculation.

    They have also asked the following>
    Our developers are asking following information to point you in the right direction:
    ? Do you get 2-digit bundled item prices when you use a 2-digit discount? Is this an approach you would consider following?

    I have tried it and have seen some changes, but the FEED output was still too long

    Using bundle component discount with two decimals still does not fixes the issue and the bundle products still output XML data incorrectly without respecting the rounding. 
    
    So when the bundle component discount had 4 decimals
    
    The XML output was this
    <item>
    <g:id>2255</g:id>
    <g:availability>in stock</g:availability>
    <g:condition>New</g:condition>
    <g:price>EUR 85,000029</g:price>
    <g:brand>Linkup,Sliger Designs</g:brand>
    <g:google_product_category>296</g:google_product_category>
    <g:shipping_weight>0.14</g:shipping_weight>
    <g:identifier_exists>yes</g:identifier_exists>
    </item>
    
    When I use only 2 decimals in bundle component discount the output is still too long
    
    <item>
    <g:id>2255</g:id>
    <g:availability>in stock</g:availability>
    <g:condition>New</g:condition>
    <g:price>EUR 85,0031</g:price>
    <g:brand>Linkup,Sliger Designs</g:brand>
    <g:google_product_category>296</g:google_product_category>
    <g:shipping_weight>0.14</g:shipping_weight>
    <g:identifier_exists>yes</g:identifier_exists>
    </item>
    Thread Starter DensitySK

    (@densitysk)

    Hi,

    Woocommerce support provided more details to this issue. Kindly check below>

    It looks like a special integration between Product Bundles and Product Feed PRO in order to achieve the result that you are looking for, since Product Bundles falls back to WooCommerce core functions to determine how many digits should be used in calculations

    Link to screenshot: https://d.pr/i/SHu49u

    That is not a particular helpful reply from them as we have shown already that we are getting way more decimals returned from WooCommerce.

    Anyhow, we have tried something else and pushed out a new release today. Can you see if that solves the issue for you?

Viewing 15 replies - 1 through 15 (of 16 total)
  • The topic ‘Limit Feed decimal places on prices’ is closed to new replies.