【发布时间】:2021-05-07 11:27:13
【问题描述】:
我正在尝试获取用户的当前送货区域,但每次尝试获取时都会出错
// The package.
// Get cart shipping packages
$shipping_packages = $woocommerce->cart->get_shipping_packages();
// Get the WC_Shipping_Zones instance object for the first package
$shipping_zone = $woocommerce->wc_get_shipping_zone( reset( $shipping_packages ) );
$zone_id = $shipping_zone->get_id(); // Get the zone ID
$zone_name = $shipping_zone->get_zone_name(); // Get the zone name
// Testing output
echo '<p>Zone id: ' . $zone_id . ' | Zone name: ' . $zone_name . '</p>';
错误信息
【问题讨论】:
标签: php wordpress woocommerce hook-woocommerce woocommerce-bookings