WC_Shipping_Zone_Data_Store::get_methods()
Get a list of shipping methods for a specific zone.
Method of the class: WC_Shipping_Zone_Data_Store{}
No Hooks.
Return
Array
. Array of objects containing method_id, method_order, instance_id, is_enabled
Usage
$WC_Shipping_Zone_Data_Store = new WC_Shipping_Zone_Data_Store(); $WC_Shipping_Zone_Data_Store->get_methods( $zone_id, $enabled_only );
- $zone_id(int) (required)
- Zone ID.
- $enabled_only(true|false) (required)
- True to request enabled methods only.
Changelog
Since 3.0.0 | Introduced. |
WC_Shipping_Zone_Data_Store::get_methods() WC Shipping Zone Data Store::get methods code WC 9.4.2
public function get_methods( $zone_id, $enabled_only ) { global $wpdb; if ( $enabled_only ) { $raw_methods_sql = "SELECT method_id, method_order, instance_id, is_enabled FROM {$wpdb->prefix}woocommerce_shipping_zone_methods WHERE zone_id = %d AND is_enabled = 1"; } else { $raw_methods_sql = "SELECT method_id, method_order, instance_id, is_enabled FROM {$wpdb->prefix}woocommerce_shipping_zone_methods WHERE zone_id = %d"; } return $wpdb->get_results( $wpdb->prepare( $raw_methods_sql, $zone_id ) ); // phpcs:ignore WordPress.DB.PreparedSQL.NotPrepared }