2021年3月12日星期五

Get shipping ID WooCommerce

I try to get a shipping ID list by country like flat_rate:1, local_pickup:2 etc. I tried this below

$all_zones = WC_Shipping_Zones::get_zones();  $country_code = 'BE';  foreach ($all_zones as $zone) {      foreach ($zone['zone_locations'] as $location) {          if ($country_code === $location->code) {              foreach ($zone['shipping_methods'] as $flat_rate) {                  print_r($flat_rate);//ID here              }          }      }  }  

I tried also this but I can not set a country by myself?

$shippingmethods = WC()->session->get( 'shipping_for_package_0')['rates'];  foreach ($shippingmethods as $shippingmethod ) {      shippingmethod->get_id();  }  
https://stackoverflow.com/questions/66608806/get-shipping-id-woocommerce March 13, 2021 at 08:08AM

没有评论:

发表评论