1 回答

TA贡献1852条经验 获得超1个赞
以下内容会将您的自定义字段保存为订单项元数据并在各处显示:
// Save and display "shipping delay" on order items everywhere
add_filter( 'woocommerce_checkout_create_order_line_item', 'action_wc_checkout_create_order_line_item', 10, 4 );
function action_wc_checkout_create_order_line_item( $item, $cart_item_key, $values, $order ) {
// Get the shipping delay
$value = $values['data']->get_meta( 'shipping_delay_for_out_of_stock_items' );
if( ! empty( $value ) ) {
// Save it and display it
$item->update_meta_data( __( 'Shipping Delay', 'woocommerce' ), $value );
}
}
代码位于活动子主题(或活动主题)的functions.php 文件中。经过测试并有效。
- 1 回答
- 0 关注
- 105 浏览
添加回答
举报