8

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 Answer 1

6

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 */
}
0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.