Complete the code to add a flat rate shipping method in WooCommerce.
add_filter('woocommerce_shipping_methods', function($methods) { $methods['flat_rate'] = [1]; return $methods; });
The correct class name for flat rate shipping in WooCommerce is WC_Shipping_Flat_Rate.
Complete the code to set the shipping zone to 'US' in WooCommerce.
$zone = new WC_Shipping_Zone([1]);Shipping zones are identified by numeric IDs. '1' is usually the default zone ID.
Fix the error in the code to add a shipping method to a zone.
$zone = new WC_Shipping_Zone(1); $zone->add_shipping_method([1]);
The add_shipping_method function expects the method ID as a string, such as 'flat_rate'.
Fill both blanks to create a shipping method instance and set its cost.
$method = new [1](); $method->[2] = '10';
Create a new flat rate shipping method instance and set its cost property to '10'.
Fill all three blanks to register a custom shipping method class in WooCommerce.
add_filter('woocommerce_shipping_methods', function($methods) { $methods[[1]] = '[2]'; return $methods; }); class [3] extends WC_Shipping_Method {}
The shipping method ID is 'custom_shipping', the class name is Custom_Shipping_Method, which extends WC_Shipping_Method.