• admirvirtua

    (@admirvirtua)


    So I’ve been trying to add new meta data to an order, that will be updated when the order gets changed to two custom status.

    Now I’ve tried adding the new meta data using this code in child themes function.php file:

    
    add_action('woocommerce_checkout_update_order_meta', 'add_bill_date_meta_data', 10, 2);
    
    function add_bill_date_meta_data($order_id, $data) {
    	update_post_meta($order_id, 'bill_date', NULL);
    }
    

    Shouldn’t this be enough to add a new meta data with content of it being NULL. Now I might be doing something really dumb here, but when the order gets created, or updated or anything, I don’t see this meta data in the webhook content, REST API or in the database.

Viewing 3 replies - 1 through 3 (of 3 total)
  • Hi @admirvirtua,

    This is a fairly complex development topic. I’m going to leave it open for a bit to see if anyone is able to chime in to help you out.

    I can also recommend the WooCommerce Developer Resources Portal for resources on developing for WooCommerce.

    You can also visit the WooCommerce Facebook group or the #developers channel of the WooCommerce Community Slack. We’re lucky to have a great community of open-source developers for WooCommerce, and many of our developers hang out there, as well.

    Plugin Support con

    (@conschneider)

    Engineer

    Hi there,

    > So I’ve been trying to add new meta data to an order, that will be updated when the order gets changed to two custom status.

    Wouldn’t you have to add an order status specific hook then? Similar to: https://gist.github.com/abegit/74e691d877cadc37d7b6

    woocommerce_checkout_update_order_meta is only called in checkout from what I can see.

    Kind regards,

    Thread Starter admirvirtua

    (@admirvirtua)

    Since we are using custom order statuses, I was thinking of just checking when the status happens and if it’s one of the two custom statuses.

    But with the original code I was just trying to figure out how the setting of meta data worked. That code did get run, but the meta data was never added. That’s the problem I’m having.

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Adding new meta data to orders’ is closed to new replies.