在woocommerce中处理付款之前如何获取帐单地址?

时间:2019-01-23 12:02:20

标签: php wordpress woocommerce

在处理付款之前,我必须从付款服务器获取结帐令牌。如何获取用户帐户和来宾帐户的帐单地址。是否可以获取账单地址信息。我正在做一个cusotm付款网关插件。

db = sqlite3.connect(':memory:')
cursor = db.cursor()

with open('scheduling.sql', 'r') as sql_file:
    sql_script = sql_file.read()
cursor.executescript(sql_script)

with open('dummy.sql', 'r') as sql_file:
    sql_script = sql_file.read()
fetch=cursor.fetchone()
while fetch:
    cursor.execute(fetch)
    fetch=cursor.fetchone()

1 个答案:

答案 0 :(得分:0)

尝试使用WC_Customer这样的方法:

$billing_first_name = WC()->customer->get_billing_first_name();
$billing_last_name  = WC()->customer->get_billing_last_name();

$billing_address_1  = WC()->customer->get_billing_address_1();
$billing_address_2  = WC()->customer->get_billing_address_2();
$billing_postcode   = WC()->customer->get_billing_postcode();
$billing_city       = WC()->customer->get_billing_city();
$billing_state      = WC()->customer->get_billing_state();
$billing_country    = WC()->customer->get_billing_country();

或者可以使用以下方法访问的WC_Session客户数据:

$customer_data      = WC()->session->get('customer');

$billing_first_name = $customer_data['first_name'];
$billing_last_name  = $customer_data['last_name'];

$billing_address_1  = $customer_data['address_1'];
$billing_address_2  = $customer_data['address_2'];
$billing_postcode   = $customer_data['postcode'];
$billing_city       = $customer_data['city'];
$billing_state      = $customer_data['state'];
$billing_country    = $customer_data['country'];