• Resolved elmersw

    (@elmersw)


    I use a custom field “alcoholpercentage” (ACF) and have set it to be numeric. I have also created a filter slider for this field using your plugin. However this seems to be sensitive for errors. I keep getting the following error:

    Fatal error: Uncaught TypeError: floor(): Argument #1 ($num) must be of type int|float, string given in C:\xampp\htdocs\speciaalbierwebshop\wp-content\plugins\filter-everything\src\Entities\PostMetaNumEntity.php:308 Stack trace: #0 C:\xampp\htdocs\speciaalbierwebshop\wp-content\plugins\filter-everything\src\Entities\PostMetaNumEntity.php(308): floor('') #1 C:\xampp\htdocs\speciaalbierwebshop\wp-content\plugins\filter-everything\src\Entities\PostMetaNumEntity.php(146): FilterEverything\Filter\PostMetaNumEntity->selectTerms() #2 C:\xampp\htdocs\speciaalbierwebshop\wp-content\plugins\filter-everything\src\Entities\PostMetaNumEntity.php(49): FilterEverything\Filter\PostMetaNumEntity->getAllExistingTerms() #3 C:\xampp\htdocs\speciaalbierwebshop\wp-content\plugins\filter-everything\src\Entities\PostMetaNumEntity.php(27): FilterEverything\Filter\PostMetaNumEntity->setPostTypes(Array) #4 C:\xampp\htdocs\speciaalbierwebshop\wp-content\plugins\filter-everything\src\Entities\EntityManager.php(81): FilterEverything\Filter\PostMetaNumEntity->__construct('alcoholpercenta...', 'product') #5 C:\xampp\htdocs\speciaalbierwebshop\wp-content\plugins\filter-everything\src\Entities\EntityManager.php(115): FilterEverything\Filter\EntityManager->createEntity('post_meta_num#a...', 'product') #6 C:\xampp\htdocs\speciaalbierwebshop\wp-content\plugins\filter-everything\src\Admin\FilterFields.php(313): FilterEverything\Filter\EntityManager->getEntityByFilter(Array, 'product') #7 C:\xampp\htdocs\speciaalbierwebshop\wp-content\plugins\filter-everything\src\Admin\FilterFields.php(271): FilterEverything\Filter\FilterFields->prepareFilterInputs(Array) #8 C:\xampp\htdocs\speciaalbierwebshop\wp-content\plugins\filter-everything\src\wpc-helpers.php(297): FilterEverything\Filter\FilterFields->getFiltersInputs(4871) #9 C:\xampp\htdocs\speciaalbierwebshop\wp-content\plugins\filter-everything\views\admin\filters-set.php(8): flrt_get_configured_filters(4871) #10 C:\xampp\htdocs\speciaalbierwebshop\wp-content\plugins\filter-everything\src\TemplateManager.php(30): include('C:\\xampp\\htdocs...') #11 C:\xampp\htdocs\speciaalbierwebshop\wp-content\plugins\filter-everything\src\wpc-helpers.php(275): FilterEverything\Filter\TemplateManager->includeAdminView('filters-set', Array) #12 C:\xampp\htdocs\speciaalbierwebshop\wp-content\plugins\filter-everything\src\Admin\MetaBoxes.php(69): flrt_include_admin_view('filters-set', Array) #13 C:\xampp\htdocs\speciaalbierwebshop\wp-admin\includes\template.php(1395): FilterEverything\Filter\MetaBoxes->filtersMetabox(Object(WP_Post), Array) #14 C:\xampp\htdocs\speciaalbierwebshop\wp-admin\edit-form-advanced.php(688): do_meta_boxes(Object(WP_Screen), 'normal', Object(WP_Post)) #15 C:\xampp\htdocs\speciaalbierwebshop\wp-admin\post.php(206): require('C:\\xampp\\htdocs...') #16 {main} thrown in C:\xampp\htdocs\speciaalbierwebshop\wp-content\plugins\filter-everything\src\Entities\PostMetaNumEntity.php on line 308ontent\plugins\filter-everything\src\Entities\PostMetaNumEntity.php on line 308`

    Apparently one or more values are treated as strings instead of numeric values. I now discovered the error message appears if I leave the custom field blank while publishing a product. As there will be some products where this custom field is not applicable, I can’t fill out this field for every product. Entering “0” as a value does solve the problem. However, I’d rather keep this field blank for some products.

    Is it possible to let the filter ignore empty fields?

    Or would it be possible to turn off the filter for specified categories? (All products without a value are in a separate product category.)

Viewing 6 replies - 1 through 6 (of 6 total)
  • Plugin Author stepasyuk

    (@stepasyuk)

    Hello @elmersw

    Sorry for the late response and thank you for your report.
    I’ve added this to my backlog and will fix it as soon as possible.

    Thread Starter elmersw

    (@elmersw)

    I can’t remember when this was fixed, but the filter was working the last couple of weeks. Until now. Since yesterday’s update the error is back.

    Unfortunately I can’t even change the filter set, because the error appears in the backend too.

    Plugin Author stepasyuk

    (@stepasyuk)

    Hello @elmersw

    It seems in your post meta values there are something different from numbers. Maybe you stored there values like 10% or some strings and this is the reason, why it doesn’t work properly.

    Let me know what are values stored in your post meta field.

    Thread Starter elmersw

    (@elmersw)

    Thanks for your quick reply.

    I agree with you that the most likely cause would be any field stored as a string (or just an empty field) instead of a number.

    In my webshop I use 3 categories. Products, bundles and giftcards. Each category only contains only 1 type of product. Products: simple product. Bundles: smart bundle (created by plugin WPC Product Bundles). Giftcards: PW gift card (created by plugin PW Giftcards). The giftcard product type also has variations.

    Given the error message I suspect that my custom meta field ‘alcoholpercentage’ is causing the error. In the filter set I use a slider on this field.

    I have not made any recent changes to the products and bundles. To be sure I have reviewed all simple products that are published: no values missing and all values seem to be a number. My bundles do not contain the field ‘alcoholpercentage’. For debugging purposes I have unpublished and deleted all these bundles.

    The giftcards may cause the problem. I have added these just after updating your plugin. I’m not sure whether the filter plugin was working after the update and before adding this giftcard plugin. I have already tried removing the plugin completely and deleting the related gift cards and category. If the gift cards would cause the error, I would expect the error to disappear after these actions. Unfortunately it didn’t.

    Additionally I have removed all products with the unpublished status. The only products left are the published simple products. And as said before, I have not made any changes to these products.

    So, I believe all published products have the necessary fields for the filter to work properly. If you want to see for yourself, I can share the export of the products.

    As a last attempt, I removed all products except for one for which I’m absolutely sure the filter was working. Still get an error.

    Is the previous version of the plugin still available? I’d like to manually install the previous version to see if it makes any difference.

    Is it possible to change the filter settings outside the regular settings screen? I can’t change the filter set in the settings screen while this error occurs. I’d like to make sure it’s this particular custom field causing the error and remove it from the filter set.

    Thread Starter elmersw

    (@elmersw)

    Update: I got it working again. But I’m really surprised: I added values to the ‘alcoholpercentage’ field for the unpublished products.

    So it seems the plugin is now taking unpublished products into account! I’m pretty sure previous versions of the plugin did not.

    This brings me back to my initial request. Could you please add functionality to exclude product types / categories from a filter set? As you probably can imagine an attribute does not apply to all categories. In my case: a gift card does not have attributes like alcohol percentage or origin.

    Maybe a more generic solution would be to treat all empty numeric fields as zero, not as NULL string.

    Plugin Author stepasyuk

    (@stepasyuk)

    Hello @elmersw

    I already fixed this bug and updated the plugin to the version 1.5.1 Try it please.

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘Uncaught TypeError: floor()’ is closed to new replies.