Вы можете сделать это двумя способами:
1) Старый способ из $product_id
динамический идентификатор продукта (или идентификатор заказа) :
if( ( $value = get_post_meta( $product_id, 'custom_field_1', true ) || $value = get_post_meta( $product_id, 'custom_field_2', true ) ) && ! get_post_meta( $product_id, 'custom_field_3', true ) ){
update_post_meta( $product_id, 'custom_field_3', $value );
}
2) Новый способ (начиная с WooCommerce 3, методы CRUD ) из $product
, WC_Product
Объект (или от $order
, WC_Order
Объект) :
if( ( $value = $product->get_meta( 'custom_field_1' ) || $value = $product->get_meta( 'custom_field_2') ) && ! $product->get_meta( 'custom_field_3' ) ){
$product->update_meta_data( 'custom_field_3', $value );
}
Код помещается в файл function.php вашей активной дочерней темы (или активной темы). Оба способа работают.