如何在 woocommerce 中设置/获取邮政编码(Zip-code)?有这个功能吗?
即,我可以通过任何函数设置邮政编码吗?
我还想知道,如果用户未登录,如何用我的数据(例如 546621)填充此字段?
您可以执行以下操作来获取/设置帐单/运输邮政编码,
To set价值,
$customer = new WC_Customer();
$customer->set_postcode('123456'); //for setting billing postcode
$customer->set_shipping_postcode('123456'); //for setting shipping postcode
如果你只是想fetch邮政编码,您可以从用户元表本身获取它,
$shipping_postcode = get_user_meta( $current_user->ID, 'shipping_postcode', true );
$billing_postcode = get_user_meta( $current_user->ID, 'billing_postcode', true );
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)