• Resolved lorenzoboldrini95

    (@lorenzoboldrini95)


    Hi,
    I was able to save additional custom field for product variants with the update_post_meta function. The data are saved in the db as an array but the update_post_meta function automatically serializes it as a string. Using the Attribute – Custom meta field filter and entering the slug of the custom field saved in the db, the data is retrieved but appears as a string of this type: a:1:a:4{i:0;s:4: “test”;i:1;s:4: “test”;i:2;s:4: “test”;i:3;s:4: “test”;}, exactly as it is saved in the db. Is there any way to retrieve the data in the correct way and make the filter works? Thanks in advance!

Viewing 1 replies (of 1 total)
  • Plugin Author Nick McReynolds

    (@woobewoo)

    Hello lorenzoboldrini95,

    The filter does not support arrays.
    This will significantly slow down the filtering.

    It’s better to save this data in the correct format like WooCommerce does in different fields.

    https://woocommerce.github.io/code-reference/classes/WC-Product-Attribute.html – Using these class and methods, you can save attributes just like WordPress does and then there will be no problems with either the filter or with other plugins.

    The processing of meta fields in itself significantly affects performance, and if we add array parsing to this, then the performance will be at an unacceptable level.

Viewing 1 replies (of 1 total)
  • The topic ‘Custom Meta Field with Serialized Data’ is closed to new replies.