Uncaught TypeError: floor()
-
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 308
ontent\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.)
- The topic ‘Uncaught TypeError: floor()’ is closed to new replies.