Automattic\WooCommerce\Blocks\Shipping
ShippingController::remove_shipping_settings()
If the Checkout block Remove shipping settings from WC Core's admin panels that are now block settings.
Метод класса: ShippingController{}
Хуков нет.
Возвращает
Массив|Разное
. The filtered settings with relevant items removed.
Использование
$ShippingController = new ShippingController(); $ShippingController->remove_shipping_settings( $settings );
- $settings(массив) (обязательный)
- The default WC shipping settings.
Код ShippingController::remove_shipping_settings() ShippingController::remove shipping settings WC 7.7.2
public function remove_shipping_settings( $settings ) { // Do not add the "Hide shipping costs until an address is entered" setting if the Checkout block is not used on the WC checkout page. if ( CartCheckoutUtils::is_checkout_block_default() ) { $settings = array_filter( $settings, function( $setting ) { return ! in_array( $setting['id'], array( 'woocommerce_shipping_cost_requires_address', ), true ); } ); } // Do not add the shipping calculator setting if the Cart block is not used on the WC cart page. if ( CartCheckoutUtils::is_cart_block_default() ) { // If the Cart is default, but not the checkout, we should ensure the 'Calculations' title is added to the // `woocommerce_shipping_cost_requires_address` options group, since it is attached to the // `woocommerce_enable_shipping_calc` option that we're going to remove later. if ( ! CartCheckoutUtils::is_checkout_block_default() ) { $calculations_title = ''; // Get Calculations title so we can add it to 'Hide shipping costs until an address is entered' option. foreach ( $settings as $setting ) { if ( 'woocommerce_enable_shipping_calc' === $setting['id'] ) { $calculations_title = $setting['title']; break; } } // Add Calculations title to 'Hide shipping costs until an address is entered' option. foreach ( $settings as $index => $setting ) { if ( 'woocommerce_shipping_cost_requires_address' === $setting['id'] ) { $settings[ $index ]['title'] = $calculations_title; $settings[ $index ]['checkboxgroup'] = 'start'; break; } } } $settings = array_filter( $settings, function( $setting ) { return ! in_array( $setting['id'], array( 'woocommerce_enable_shipping_calc', ), true ); } ); } return $settings; }