在我的woocommerce项目中,我想在视图顺序页面中输入一个输入字段,如果客户单击视图顺序,它将显示一个文本框以添加注释,我想,这些值应存储在(wp_woocommerce_order_itemmeta)表中。可以帮助我......我试了一下..
function add_name_on_field() {
echo '<form class="cart" method="post" enctype="multipart/form-data"><table class="variations"
cellspacing="0"> <tbody><tr>
<td class="label"><label for="name">Add notes</label></td>
<td class="value">
<input type="text" name="name-on-tshirt" value="" /> <button type="submit"
class="">Submit</button</td></tr></tbody></table></form>'; }
add_filter( 'woocommerce_order_item_quantity_html',
'add_name_on_field' );
为了存储,我尝试了这个..
function tshirt_order_meta_handler( $item_id ) {
if( WC()->session->__isset( $cart_item_key.'_name_on_tshirt' ) ) {
wc_add_order_item_meta( $item_id, "name_on_tshirt", WC()->session->get( $cart_item_key.'_name_on_tshirt') );}}
add_action( 'woocommerce_add_order_item_meta', 'tshirt_order_meta_handler', 1, 3 );
答案 0 :(得分:0)