问题描述
我在 woocommerce 预订中添加了一些自定义结帐字段。但我注意到自定义字段数据不会与其他常规计费字段一起显示。我如何访问这些数据并打印出来?
add_action('woocommerce_after_order_notes','my_custom_checkout_fields',20,1 );
function my_custom_checkout_fields( $checkout ){
$index = 0;
echo '<div id="my_custom_checkout_fields"><h2>' .__('Child information').'</h2>';
// First Loop go through cart items
foreach(WC()->cart->get_cart() as $cart_item )
{
// 2nd Loop go through each unit related to item quantity
for( $i = 1; $i <= $cart_item['booking']['_persons']['26819']; $i++ )
{
$index++;
woocommerce_form_field('my_field_name_'.$index,array(
'type' =>'text','class'=>array('my-field-class form-row-wide'),'label'=>__('Fill this field') . ' ' . $index,'placeholder'=>__('Enter Something'),),$checkout->get_value('my_field_name_'.$index));
}
}
echo '</div>';
}
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)