I have WordPress Multisite installed with WooCommerce network activated. I want to add an action to a hook in ONE of the sites that has WooCommerce installed, instead of all of them.

For example, I only want this action that adds specific meta data to the order to occur on one of the sites with WooCommerce installed.

add_action('woocommerce_checkout_update_order_meta', 'new_meta_values'), 2);

function new_meta_values($order_id) {
    $order = new WC_Order($order_id);
    $items = $order->get_items();

    foreach($items as $k => $v){
       $item_id = $k;       
       woocommerce_add_order_item_meta( $item_id, '_seminar_members_', $data);
    }
}

Is this possible?

1
1

Use get_current_blog_id() to check the current site. To run on site 2 only, use this:

function new_meta_values($order_id) {
    if ( 2 !== get_current_blog_id() )
        return;

    /* the rest of the function code */
}

Leave a Reply

Your email address will not be published. Required fields are marked *