• Resolved manikandang1

    (@manikandang1)


    Hello,

    I was using the get_post_meta() to get the meta value. As I need to make my plugin to get compatible with WC HPOS, I changed it to $order->get_meta(). but it shows errors like Notice: Function is_internal_meta_key was called?incorrectly. Generic add/update/get meta methods should not be used for internal meta data, including "_shipping_phone".

    Please help to resolve this

Viewing 7 replies - 1 through 7 (of 7 total)
  • Hi @manikandang1

    Thanks for reaching out!

    I understand that you are experiencing issues with the get_meta() function after updating your plugin to be compatible with WC HPOS.

    The error message you provided indicates that the function is_internal_meta_key was called incorrectly, specifically for the internal meta data _shipping_phone.

    This is a bit of a complicated topic that would need some customization to address. Unfortunately, custom coding is not something we can assist with directly. However, I’ll keep this thread open for a bit to see if anyone from the community can lend a hand.

    If you have any other questions related to development or custom coding, don’t hesitate to reach out to some of the great resources we have available for support. The WooCommerce community is filled with talented open-source developers, and many of them are active on the channels listed below:

    Hope this helps!

    Hello, @manikandang1,
    I have the same issue. Did you find any solution? Or at least a way to stop logging it?

    In my case, the problem is because my custom plugin collects shipping data and saves it in the standard fields. Before I updated my plugin to support WC HPOS, there was no such problem, of course, because it worked with post meta, not order meta.

    @xue28, can you suggest some way to stop this notice from creating a log file at least? Thanks.

    Thread Starter manikandang1

    (@manikandang1)

    Hello @alex4e ,

    To prevent errors, it’s recommended to use $order->get_meta() instead of get_post_meta() when retrieving order metadata.

    Hope this helps!

    Hi @alex4e

    Does that help?

    If you require more help, I suggest starting a new topic and making sure to send us more details on how your website is set up.

    Thanks!

    Hey, @manikandang1, thank you for your time and help. In my plugin I use update, not get.

    For example, before HPOS was:
    update_post_meta($order_id, ‘_billing_state’, ”);
    Now, with HPOS is:
    $order->update_meta_data(‘_billing_state’, ”);

    And because I’m updating default fields (with underscore in the begining), WC throws this error in the log. There is no problem with the functionality, everything works, the custom order meta is all there, but for each order and for each field from it this notice is logged. And I want to prevent this from loging and keep that logic, because I need to update these fields.

    Thank you, @aguinaldodarla. I think it will be more valuable to anyone who comes across it to find all the information in one place.

    Internal meta keys have their own functions.

    Instead of $order->get_meta('_shipping_phone')
    Use $order->get_shipping_phone()

    Instead of $order->update_meta_data('_billing_state', '')
    Use
    $order->set_billing_state('');
    $order->save();

    For a full list of what is available see https://woocommerce.github.io/code-reference/classes/WC-Order.html

    • This reply was modified 1 year, 4 months ago by yffaffy.

    Dear @yffaffy,
    Thank you for this reminder. I cannot say how, but somehow I missed these functions. I have made the necessary changes and the error log is no longer created. Thanks!

Viewing 7 replies - 1 through 7 (of 7 total)
  • The topic ‘Alternative for $order->get_meta() in when using WC HPOS’ is closed to new replies.