Last active
December 5, 2019 03:14
-
-
Save luiseduardobraschi/488d52ee9a11260d2c27a0be95bb157e to your computer and use it in GitHub Desktop.
Add order meta to child orders in WC Marketplace
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
add_action( 'wcmp_checkout_update_order_meta', function( $vendor_order_id, $args ){ | |
$parent_order = wc_get_order( $args['order_id'] ); | |
$child_order = wc_get_order( $vendor_order_id ); | |
foreach( $parent_order->get_meta_data() as $meta ){ | |
$child_order->update_meta_data( $meta->key, $meta->value ); | |
} | |
$child_order->save(); | |
}, 11, 2 ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment