Fixing Critical Errors caused by Dynamic Pricing Misconfiguration

Like any other plugin, a failed update to Dynamic Pricing may cause critical errors, but if updating and/or reinstalling the plugin does not resolve your critical error it may be due to a misconfiguration in the plugin. This guide will help you recognize when this is the case and show you how to fix the misconfiguration.

Common Symptoms of Misconfiguration

Every site is different, so the symptoms may not always be identical but if the site is exhibiting any of the following symptoms the issue may be due to misconfiguration:

  • The critical error happens on the front of site but the WordPress dashboard is still accessible
  • The critical error occurs if the site is using php 8.0+ but does occur when the site is on php 7.4
  • Updating or reinstalling the Dynamic Pricing plugin does not resolve the issue

Identifying the Fatal Error Message

As always when troubleshooting a critical error, you should turn on debug mode to review the fatal error message and identify a root cause of the issue. When Dynamic Pricing is misconfigured the fatal error message is likely to reflect the following example:

PHP Fatal error:  Uncaught TypeError: round(): Argument #1 ($num) must be of type int|float, string given in /var/www/wp-content/plugins/woocommerce-dynamic-pricing/classes/modules/class-wc-dynamic-pricing-simple-membership.php:407

If we review the message, it is identifying the misconfiguration for us with the following text: “Argument #1 ($num) must be of type int|float, string given”. This is stating that there is pricing in this plugin that is expecting to be a number value, but it’s not. Basically, there is a field somewhere that somebody filled out wrong. To fix this, you will need to find these fields.

Fixing the Issue

To resolve this issue, you will need to review the Dynamic Pricing settings on the products. This issue may be present on just a single product or on various products and we do not have a reliable way to identify offending products other than checking them manually.

To review a product you will want to check the Dynamic Pricing settings. To do this from the WordPress dashboard click on Products -> All Products -> Edit Product -> Click “Dynamic Pricing” in the Product Data section

You will want to look out for red flags, such as empty fields or fields with incorrect values in them.  For example, the screenshot below features both empty rows and an incorrect value in the “Max Quantity” column. The fields in that column expect a numeric value but one of them features the words “or more”.

In this situation, you would want to delete all the empty rows and replace any invalid values with a valid one. For example, the “or more” text would be replaced with an “*” as per the plugin documentation.

Please note: If there are a large number of products to review, you may send the ticket back to the vendor with instructions to review the products and resolve this themselves. If there are a small number of products to review, please complete the review yourself so we can confirm the issue has been resolved before closing the clarification.