Automattic\WooCommerce\Internal\StockNotifications\Admin
SettingsController::add_customer_stock_notifications_section
Add a 'Customer stock notifications' section to Products settings.
Method of the class: SettingsController{}
No Hooks.
Returns
Array. New Products settings sections.
Usage
$SettingsController = new SettingsController(); $SettingsController->add_customer_stock_notifications_section( $sections );
- $sections(array) (required)
- Products settings sections.
SettingsController::add_customer_stock_notifications_section() SettingsController::add customer stock notifications section code WC 10.3.6
public function add_customer_stock_notifications_section( $sections ) {
if ( ! is_array( $sections ) ) {
return $sections;
}
$section_title = __( 'Customer stock notifications', 'woocommerce' );
// Add 'Customer stock notifications' section to the Products tab, after Inventory.
$inventory_index = array_search( 'inventory', array_keys( $sections ), true );
if ( false !== $inventory_index ) {
$sections = array_slice( $sections, 0, $inventory_index + 1, true ) +
array( 'customer_stock_notifications' => $section_title ) +
array_slice( $sections, $inventory_index + 1, null, true );
} else {
$sections['customer_stock_notifications'] = $section_title;
}
return $sections;
}