Last active
October 16, 2021 07:15
-
-
Save plugin-republic/f3e786b7f387a1210c0ab43ee7e2d0a8 to your computer and use it in GitHub Desktop.
This file contains 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 custom meta to order | |
*/ | |
function plugin_republic_checkout_create_order_line_item( $item, $cart_item_key, $values, $order ) { | |
if( isset( $values['pr_field'] ) ) { | |
$item->add_meta_data( | |
__( 'Your name', 'plugin-republic' ), | |
$values['pr_field'], | |
true | |
); | |
} | |
} | |
add_action( 'woocommerce_checkout_create_order_line_item', 'plugin_republic_checkout_create_order_line_item', 10, 4 ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
order item meta saves in wp_woocommerce_order_itemmeta table
and gets with $order->get_items(); method