对于预订网站,我正在尝试创建一个功能,该功能可以根据人数添加与会者列表。感谢 LoicTheAztec,我已经获得了单次预订的代码。那部分工作正常。
我还需要为多个预订提供相同的功能。我怎样才能做到这一点?
这是代码:
//* Add a new checkout field
add_filter( 'woocommerce_checkout_fields', 'ppp_filter_checkout_fields' );
function ppp_filter_checkout_fields($fields){
$fields['extra_fields'] = array(
'participant_details' => array(
'type' => 'participant_details',
'required' => false,
'label' => __( 'Participant Details' )
),
);
// Add a "persons" hidden input field
foreach( WC()->cart->get_cart() as $cart_item ) {
$persons = $cart_item['booking']['_persons'][0];
}
echo '<input type="hidden" name="persons" value="' . $persons . '">';
return $fields;
}
//* Add the field to the checkout
add_filter( 'woocommerce_form_field_participant_details', 'ppp_filter_checkout_field_group', 10, 4 );
function ppp_filter_checkout_field_group( …Run Code Online (Sandbox Code Playgroud)