id = 'products'; $this->label = __( 'Products', 'woocommerce' ); parent::__construct(); } /** * Get sections. * * @return array */ public function get_sections() { $sections = array( '' => __( 'General', 'woocommerce' ), 'inventory' => __( 'Inventory', 'woocommerce' ), 'downloadable' => __( 'Downloadable products', 'woocommerce' ), ); return apply_filters( 'woocommerce_get_sections_' . $this->id, $sections ); } /** * Output the settings. */ public function output() { global $current_section; $settings = $this->get_settings( $current_section ); $this->product_display_settings_moved_notice(); WC_Admin_Settings::output_fields( $settings ); } /** * Show a notice showing where some options have moved. * * @since 3.3.0 * @todo remove in next major release. */ private function product_display_settings_moved_notice() { if ( get_user_meta( get_current_user_id(), 'dismissed_product_display_settings_moved_notice', true ) ) { return; } ?>
get_settings( $current_section ); WC_Admin_Settings::save_fields( $settings ); if ( $current_section ) { do_action( 'woocommerce_update_options_' . $this->id . '_' . $current_section ); } } /** * Get settings array. * * @param string $current_section Current section name. * @return array */ public function get_settings( $current_section = '' ) { if ( 'inventory' === $current_section ) { $settings = apply_filters( 'woocommerce_inventory_settings', array( array( 'title' => __( 'Inventory', 'woocommerce' ), 'type' => 'title', 'desc' => '', 'id' => 'product_inventory_options', ), array( 'title' => __( 'Manage stock', 'woocommerce' ), 'desc' => __( 'Enable stock management', 'woocommerce' ), 'id' => 'woocommerce_manage_stock', 'default' => 'yes', 'type' => 'checkbox', ), array( 'title' => __( 'Hold stock (minutes)', 'woocommerce' ), 'desc' => __( 'Hold stock (for unpaid orders) for x minutes. When this limit is reached, the pending order will be cancelled. Leave blank to disable.', 'woocommerce' ), 'id' => 'woocommerce_hold_stock_minutes', 'type' => 'number', 'custom_attributes' => array( 'min' => 0, 'step' => 1, ), 'css' => 'width: 80px;', 'default' => '60', 'autoload' => false, 'class' => 'manage_stock_field', ), array( 'title' => __( 'Notifications', 'woocommerce' ), 'desc' => __( 'Enable low stock notifications', 'woocommerce' ), 'id' => 'woocommerce_notify_low_stock', 'default' => 'yes', 'type' => 'checkbox', 'checkboxgroup' => 'start', 'autoload' => false, 'class' => 'manage_stock_field', ), array( 'desc' => __( 'Enable out of stock notifications', 'woocommerce' ), 'id' => 'woocommerce_notify_no_stock', 'default' => 'yes', 'type' => 'checkbox', 'checkboxgroup' => 'end', 'autoload' => false, 'class' => 'manage_stock_field', ), array( 'title' => __( 'Notification recipient(s)', 'woocommerce' ), 'desc' => __( 'Enter recipients (comma separated) that will receive this notification.', 'woocommerce' ), 'id' => 'woocommerce_stock_email_recipient', 'type' => 'text', 'default' => get_option( 'admin_email' ), 'css' => 'width: 250px;', 'autoload' => false, 'desc_tip' => true, 'class' => 'manage_stock_field', ), array( 'title' => __( 'Low stock threshold', 'woocommerce' ), 'desc' => __( 'When product stock reaches this amount you will be notified via email.', 'woocommerce' ), 'id' => 'woocommerce_notify_low_stock_amount', 'css' => 'width:50px;', 'type' => 'number', 'custom_attributes' => array( 'min' => 0, 'step' => 1, ), 'default' => '2', 'autoload' => false, 'desc_tip' => true, 'class' => 'manage_stock_field', ), array( 'title' => __( 'Out of stock threshold', 'woocommerce' ), 'desc' => __( 'When product stock reaches this amount the stock status will change to "out of stock" and you will be notified via email. This setting does not affect existing "in stock" products.', 'woocommerce' ), 'id' => 'woocommerce_notify_no_stock_amount', 'css' => 'width:50px;', 'type' => 'number', 'custom_attributes' => array( 'min' => 0, 'step' => 1, ), 'default' => '0', 'desc_tip' => true, 'class' => 'manage_stock_field', ), array( 'title' => __( 'Out of stock visibility', 'woocommerce' ), 'desc' => __( 'Hide out of stock items from the catalog', 'woocommerce' ), 'id' => 'woocommerce_hide_out_of_stock_items', 'default' => 'no', 'type' => 'checkbox', ), array( 'title' => __( 'Stock display format', 'woocommerce' ), 'desc' => __( 'This controls how stock quantities are displayed on the frontend.', 'woocommerce' ), 'id' => 'woocommerce_stock_format', 'css' => 'min-width:150px;', 'class' => 'wc-enhanced-select', 'default' => '', 'type' => 'select', 'options' => array( '' => __( 'Always show quantity remaining in stock e.g. "12 in stock"', 'woocommerce' ), 'low_amount' => __( 'Only show quantity remaining in stock when low e.g. "Only 2 left in stock"', 'woocommerce' ), 'no_amount' => __( 'Never show quantity remaining in stock', 'woocommerce' ), ), 'desc_tip' => true, ), array( 'type' => 'sectionend', 'id' => 'product_inventory_options', ), ) ); } elseif ( 'downloadable' === $current_section ) { $settings = apply_filters( 'woocommerce_downloadable_products_settings', array( array( 'title' => __( 'Downloadable products', 'woocommerce' ), 'type' => 'title', 'id' => 'digital_download_options', ), array( 'title' => __( 'File download method', 'woocommerce' ), 'desc' => sprintf( /* translators: 1: X-Accel-Redirect 2: X-Sendfile 3: mod_xsendfile */ __( 'Forcing downloads will keep URLs hidden, but some servers may serve large files unreliably. If supported, %1$s / %2$s can be used to serve downloads instead (server requires %3$s).', 'woocommerce' ), 'X-Accel-Redirect
',
'X-Sendfile
',
'mod_xsendfile
'
),
'id' => 'woocommerce_file_download_method',
'type' => 'select',
'class' => 'wc-enhanced-select',
'css' => 'min-width:300px;',
'default' => 'force',
'desc_tip' => true,
'options' => array(
'force' => __( 'Force downloads', 'woocommerce' ),
'xsendfile' => __( 'X-Accel-Redirect/X-Sendfile', 'woocommerce' ),
'redirect' => __( 'Redirect only', 'woocommerce' ),
),
'autoload' => false,
),
array(
'title' => __( 'Access restriction', 'woocommerce' ),
'desc' => __( 'Downloads require login', 'woocommerce' ),
'id' => 'woocommerce_downloads_require_login',
'type' => 'checkbox',
'default' => 'no',
'desc_tip' => __( 'This setting does not apply to guest purchases.', 'woocommerce' ),
'checkboxgroup' => 'start',
'autoload' => false,
),
array(
'desc' => __( 'Grant access to downloadable products after payment', 'woocommerce' ),
'id' => 'woocommerce_downloads_grant_access_after_payment',
'type' => 'checkbox',
'default' => 'yes',
'desc_tip' => __( 'Enable this option to grant access to downloads when orders are "processing", rather than "completed".', 'woocommerce' ),
'checkboxgroup' => 'end',
'autoload' => false,
),
array(
'type' => 'sectionend',
'id' => 'digital_download_options',
),
)
);
} else {
$settings = apply_filters(
'woocommerce_product_settings', apply_filters(
'woocommerce_products_general_settings', array(
array(
'title' => __( 'Shop pages', 'woocommerce' ),
'type' => 'title',
'desc' => '',
'id' => 'catalog_options',
),
array(
'title' => __( 'Shop page', 'woocommerce' ),
'desc' => '