• Resolved refluxcomponents

    (@refluxcomponents)


    When I try to validate the field like this:

    $_weight = absint( sanitize_text_field( $postdata['_weight'] ) );

    to make sure the weight field isn’t empty, it gives me an error if the weight contains a decimal place in it, for example, 6 lbs. works, but .6 lbs. does not. Thank you for your help.

Viewing 3 replies - 1 through 3 (of 3 total)
  • Hello @refluxcomponents ,

    Can you please explain where exactly you are having this issue?

    Dokan’s vendor edit product area can save both 6 & .6 in its dimension fields. If you are developing a custom field and have queries regarding coding best practices these are some good places to discuss that:
    https://stackoverflow.com/
    https://www.ads-software.com/support/forum/miscellaneous/

    Thank you ??

    Thread Starter refluxcomponents

    (@refluxcomponents)

    I am trying to validate WooCommerce product fields to ensure they are not blank or empty for weight and dimensions using dokan_can_add_product and dokan_can_edit_product. It works for dimensions, but when I try to use $_weight = absint( sanitize_text_field( $postdata[‘_weight’] ) );, it also works, but only for whole numbers, not decimal places. This would be your code, nothing custom.

    Hello @refluxcomponents ,

    Can you please share the exact file location where you see this code in Dokan?

    I can see that you are validating using absint() by the documentation it is used for – Convert a value to non-negative integer.. So it is expected to work for whole numbers.

    You can rather use empty() or isset() functions to identify if the variable has values or not.

    If this does not satisfy the problem please share the exact location where you see the code & I will discuss this with our developers.

    Thank you ??

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Weight with decimal places won’t validate’ is closed to new replies.