第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

使用 woocommerce 預訂動態(tài)詢問人名。?

使用 woocommerce 預訂動態(tài)詢問人名。?

PHP
慕哥6287543 2022-06-17 10:35:11
我正在使用 woo commerce bookings 插件來預訂旅行,但我想根據(jù)動態(tài)人數(shù)在結(jié)帳頁面上單獨獲取每個人的類型名稱。我發(fā)現(xiàn)堆棧溢出的帖子對我不起作用,它一直說未定義的偏移量 0 作為結(jié)帳頁面上的錯誤。//* Add a new checkout fieldadd_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 fieldforeach( 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 checkoutadd_filter( 'woocommerce_form_field_participant_details', 'ppp_filter_checkout_field_group', 10, 4 );function ppp_filter_checkout_field_group( $field, $key, $args, $value ){$op_cart_count = WC()->cart->get_cart_contents_count();$items = WC()->cart->get_cart();foreach($items as $item) {    $person = $item['booking']['_persons'][0];}if ($person > 1) {    $html = '';    $html .= "<h3>Deelnemers</h3>";    for ( $i = 1; $i < $person; $i++) {        $counter = $i + 1;        $html .= "Deelnemer ". $counter . "<br>";        $html .= woocommerce_form_field( "participant_details[$i][full_name]", array(            "type" => "text",            "return" => true,            "value" => "",            "required"      => true,            "label" => __( "Naam" )            )        );        $html .= woocommerce_form_field( "participant_details[$i][email_address]", array(            "type" => "email",            "return" => true,            "value" => "",            "required"      => true,            "label" => __( "Emailadres" )            )        );    }    return $html;}}這是我試圖實現(xiàn)這一目標的網(wǎng)站。 網(wǎng)站
查看完整描述

1 回答

?
子衿沉夜

TA貢獻1828條經(jīng)驗 獲得超3個贊

 // Add checkout custom text fields

     add_action( 'woocommerce_before_order_notes', 'add_checkout_custom_text_fields', 20, 1 );

   function add_checkout_custom_text_fields( $checkout) {

$index = 0;


// 1st Loop through cart items

foreach(WC()->cart->get_cart() as $cart_item){

    $index++;

    // 2nd Loop through each unit related to item quantity

    for($i = 1; $i <= $cart_item['booking']['Adults']; $i++){


        woocommerce_form_field("Adult[$index][$i]", array(

            'type' =>'text',

            'class'=>array('my-field-class form-row-wide'),

            'label'=>__('Adult Name')." ($i)",

            'placeholder'=>__('Enter adult name'),

        ), $checkout->get_value("Adult[$index][$i]"));

    }


    for($i = 1; $i <= $cart_item['booking']['Childs']; $i++){


        woocommerce_form_field("Child[$index][$i]", array(

            'type' =>'text',

            'class'=>array('my-field-class form-row-wide'),

            'label'=>__('Child Name')." ($i)",

            'placeholder'=>__('Enter child name'),

        ), $checkout->get_value("Child[$index][$i]"));

    }

}

 }


查看完整回答
反對 回復 2022-06-17
  • 1 回答
  • 0 關注
  • 93 瀏覽

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網(wǎng)微信公眾號