Skip to content

Instantly share code, notes, and snippets.

@asalkey
Last active August 22, 2017 23:57
Show Gist options
  • Save asalkey/d94e19a8b8d62f3755ecb9fd16efdc04 to your computer and use it in GitHub Desktop.
Save asalkey/d94e19a8b8d62f3755ecb9fd16efdc04 to your computer and use it in GitHub Desktop.
<?php
add_action( 'woocommerce_add_order_item_meta', 'add_esn_fields');
public function add_esn_fields( $item_id, $values, $cart_item_key ) {
if($values['attached_id']){
$x = 1;
while($x <= $values['quantity']) {
wc_add_order_item_meta( $item_id, 'esn', '', false );
$x++;
}
}else if($values['type'] == 'wholesaler') {
$x = 1;
while($x <= $values['quantity']) {
wc_add_order_item_meta( $item_id, 'esn', '', false );
$x++;
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment