How to get all checkout fields from WooCommerce?

前端 未结 3 1912
甜味超标
甜味超标 2021-02-10 04:13

I like to get all available checkout fields, including third party ones:

$fields = WC()->checkout()->checkout_fields;

returns a fatal err

3条回答
  •  遇见更好的自我
    2021-02-10 04:42

    i was facing the same issue . here's how i managed it .

    class my_checkout_fields_class {
        var $countries;
    
    function __construct() {
    
            $this->countries = new WC_Countries();
    
    }
    
    
    }
    

    Now you can get billing and shipping fields respectively in this class.

    $billlingfields             = $this->countries->get_address_fields( $this->countries->get_base_country(),'billing_');
    
    $shippingfields             = $this->countries->get_address_fields( $this->countries->get_base_country(),'shipping_');
    

    regards

提交回复
热议问题