diff --git a/includes/admin/settings/class-wc-settings-checkout.php b/includes/admin/settings/class-wc-settings-checkout.php index e423328c7a5..96a752de3d5 100644 --- a/includes/admin/settings/class-wc-settings-checkout.php +++ b/includes/admin/settings/class-wc-settings-checkout.php @@ -61,191 +61,195 @@ class WC_Settings_Payment_Gateways extends WC_Settings_Page { * * @return array */ - public function get_settings() { - $settings = apply_filters( 'woocommerce_payment_gateways_settings', array( + public function get_settings( $current_section = '' ) { + $settings = array(); - array( - 'title' => __( 'Checkout process', 'woocommerce' ), - 'type' => 'title', - 'id' => 'checkout_process_options', - ), + if ( '' === $current_section ) { + $settings = apply_filters( 'woocommerce_payment_gateways_settings', array( - array( - 'title' => __( 'Coupons', 'woocommerce' ), - 'desc' => __( 'Enable the use of coupons', 'woocommerce' ), - 'id' => 'woocommerce_enable_coupons', - 'default' => 'yes', - 'type' => 'checkbox', - 'checkboxgroup' => 'start', - 'desc_tip' => __( 'Coupons can be applied from the cart and checkout pages.', 'woocommerce' ), - ), + array( + 'title' => __( 'Checkout process', 'woocommerce' ), + 'type' => 'title', + 'id' => 'checkout_process_options', + ), - array( - 'desc' => __( 'Calculate coupon discounts sequentially', 'woocommerce' ), - 'id' => 'woocommerce_calc_discounts_sequentially', - 'default' => 'no', - 'type' => 'checkbox', - 'desc_tip' => __( 'When applying multiple coupons, apply the first coupon to the full price and the second coupon to the discounted price and so on.', 'woocommerce' ), - 'checkboxgroup' => 'end', - 'autoload' => false, - ), + array( + 'title' => __( 'Coupons', 'woocommerce' ), + 'desc' => __( 'Enable the use of coupons', 'woocommerce' ), + 'id' => 'woocommerce_enable_coupons', + 'default' => 'yes', + 'type' => 'checkbox', + 'checkboxgroup' => 'start', + 'desc_tip' => __( 'Coupons can be applied from the cart and checkout pages.', 'woocommerce' ), + ), - array( - 'title' => __( 'Checkout process', 'woocommerce' ), - 'desc' => __( 'Enable guest checkout', 'woocommerce' ), - 'desc_tip' => __( 'Allows customers to checkout without creating an account.', 'woocommerce' ), - 'id' => 'woocommerce_enable_guest_checkout', - 'default' => 'yes', - 'type' => 'checkbox', - 'checkboxgroup' => 'start', - 'autoload' => false, - ), + array( + 'desc' => __( 'Calculate coupon discounts sequentially', 'woocommerce' ), + 'id' => 'woocommerce_calc_discounts_sequentially', + 'default' => 'no', + 'type' => 'checkbox', + 'desc_tip' => __( 'When applying multiple coupons, apply the first coupon to the full price and the second coupon to the discounted price and so on.', 'woocommerce' ), + 'checkboxgroup' => 'end', + 'autoload' => false, + ), - array( - 'desc' => __( 'Force secure checkout', 'woocommerce' ), - 'id' => 'woocommerce_force_ssl_checkout', - 'default' => 'no', - 'type' => 'checkbox', - 'checkboxgroup' => '', - 'show_if_checked' => 'option', - 'desc_tip' => sprintf( __( 'Force SSL (HTTPS) on the checkout pages (an SSL Certificate is required).', 'woocommerce' ), 'https://docs.woocommerce.com/document/ssl-and-https/#section-3' ), - ), + array( + 'title' => __( 'Checkout process', 'woocommerce' ), + 'desc' => __( 'Enable guest checkout', 'woocommerce' ), + 'desc_tip' => __( 'Allows customers to checkout without creating an account.', 'woocommerce' ), + 'id' => 'woocommerce_enable_guest_checkout', + 'default' => 'yes', + 'type' => 'checkbox', + 'checkboxgroup' => 'start', + 'autoload' => false, + ), - 'unforce_ssl_checkout' => array( - 'desc' => __( 'Force HTTP when leaving the checkout', 'woocommerce' ), - 'id' => 'woocommerce_unforce_ssl_checkout', - 'default' => 'no', - 'type' => 'checkbox', - 'checkboxgroup' => 'end', - 'show_if_checked' => 'yes', - ), + array( + 'desc' => __( 'Force secure checkout', 'woocommerce' ), + 'id' => 'woocommerce_force_ssl_checkout', + 'default' => 'no', + 'type' => 'checkbox', + 'checkboxgroup' => '', + 'show_if_checked' => 'option', + 'desc_tip' => sprintf( __( 'Force SSL (HTTPS) on the checkout pages (an SSL Certificate is required).', 'woocommerce' ), 'https://docs.woocommerce.com/document/ssl-and-https/#section-3' ), + ), - array( - 'type' => 'sectionend', - 'id' => 'checkout_process_options', - ), + 'unforce_ssl_checkout' => array( + 'desc' => __( 'Force HTTP when leaving the checkout', 'woocommerce' ), + 'id' => 'woocommerce_unforce_ssl_checkout', + 'default' => 'no', + 'type' => 'checkbox', + 'checkboxgroup' => 'end', + 'show_if_checked' => 'yes', + ), - array( - 'title' => __( 'Checkout pages', 'woocommerce' ), - 'desc' => __( 'These pages need to be set so that WooCommerce knows where to send users to checkout.', 'woocommerce' ), - 'type' => 'title', - 'id' => 'checkout_page_options', - ), + array( + 'type' => 'sectionend', + 'id' => 'checkout_process_options', + ), - array( - 'title' => __( 'Cart page', 'woocommerce' ), - 'desc' => sprintf( __( 'Page contents: [%s]', 'woocommerce' ), apply_filters( 'woocommerce_cart_shortcode_tag', 'woocommerce_cart' ) ), - 'id' => 'woocommerce_cart_page_id', - 'type' => 'single_select_page', - 'default' => '', - 'class' => 'wc-enhanced-select-nostd', - 'css' => 'min-width:300px;', - 'desc_tip' => true, - ), + array( + 'title' => __( 'Checkout pages', 'woocommerce' ), + 'desc' => __( 'These pages need to be set so that WooCommerce knows where to send users to checkout.', 'woocommerce' ), + 'type' => 'title', + 'id' => 'checkout_page_options', + ), - array( - 'title' => __( 'Checkout page', 'woocommerce' ), - 'desc' => sprintf( __( 'Page contents: [%s]', 'woocommerce' ), apply_filters( 'woocommerce_checkout_shortcode_tag', 'woocommerce_checkout' ) ), - 'id' => 'woocommerce_checkout_page_id', - 'type' => 'single_select_page', - 'default' => '', - 'class' => 'wc-enhanced-select-nostd', - 'css' => 'min-width:300px;', - 'desc_tip' => true, - ), + array( + 'title' => __( 'Cart page', 'woocommerce' ), + 'desc' => sprintf( __( 'Page contents: [%s]', 'woocommerce' ), apply_filters( 'woocommerce_cart_shortcode_tag', 'woocommerce_cart' ) ), + 'id' => 'woocommerce_cart_page_id', + 'type' => 'single_select_page', + 'default' => '', + 'class' => 'wc-enhanced-select-nostd', + 'css' => 'min-width:300px;', + 'desc_tip' => true, + ), - array( - 'title' => __( 'Terms and conditions', 'woocommerce' ), - 'desc' => __( 'If you define a "Terms" page the customer will be asked if they accept them when checking out.', 'woocommerce' ), - 'id' => 'woocommerce_terms_page_id', - 'default' => '', - 'class' => 'wc-enhanced-select-nostd', - 'css' => 'min-width:300px;', - 'type' => 'single_select_page', - 'desc_tip' => true, - 'autoload' => false, - ), + array( + 'title' => __( 'Checkout page', 'woocommerce' ), + 'desc' => sprintf( __( 'Page contents: [%s]', 'woocommerce' ), apply_filters( 'woocommerce_checkout_shortcode_tag', 'woocommerce_checkout' ) ), + 'id' => 'woocommerce_checkout_page_id', + 'type' => 'single_select_page', + 'default' => '', + 'class' => 'wc-enhanced-select-nostd', + 'css' => 'min-width:300px;', + 'desc_tip' => true, + ), - array( - 'type' => 'sectionend', - 'id' => 'checkout_page_options', - ), + array( + 'title' => __( 'Terms and conditions', 'woocommerce' ), + 'desc' => __( 'If you define a "Terms" page the customer will be asked if they accept them when checking out.', 'woocommerce' ), + 'id' => 'woocommerce_terms_page_id', + 'default' => '', + 'class' => 'wc-enhanced-select-nostd', + 'css' => 'min-width:300px;', + 'type' => 'single_select_page', + 'desc_tip' => true, + 'autoload' => false, + ), - array( 'title' => __( 'Checkout endpoints', 'woocommerce' ), 'type' => 'title', 'desc' => __( 'Endpoints are appended to your page URLs to handle specific actions during the checkout process. They should be unique.', 'woocommerce' ), 'id' => 'account_endpoint_options' ), + array( + 'type' => 'sectionend', + 'id' => 'checkout_page_options', + ), - array( - 'title' => __( 'Pay', 'woocommerce' ), - 'desc' => __( 'Endpoint for the "Checkout → Pay" page.', 'woocommerce' ), - 'id' => 'woocommerce_checkout_pay_endpoint', - 'type' => 'text', - 'default' => 'order-pay', - 'desc_tip' => true, - ), + array( 'title' => __( 'Checkout endpoints', 'woocommerce' ), 'type' => 'title', 'desc' => __( 'Endpoints are appended to your page URLs to handle specific actions during the checkout process. They should be unique.', 'woocommerce' ), 'id' => 'account_endpoint_options' ), - array( - 'title' => __( 'Order received', 'woocommerce' ), - 'desc' => __( 'Endpoint for the "Checkout → Order received" page.', 'woocommerce' ), - 'id' => 'woocommerce_checkout_order_received_endpoint', - 'type' => 'text', - 'default' => 'order-received', - 'desc_tip' => true, - ), + array( + 'title' => __( 'Pay', 'woocommerce' ), + 'desc' => __( 'Endpoint for the "Checkout → Pay" page.', 'woocommerce' ), + 'id' => 'woocommerce_checkout_pay_endpoint', + 'type' => 'text', + 'default' => 'order-pay', + 'desc_tip' => true, + ), - array( - 'title' => __( 'Add payment method', 'woocommerce' ), - 'desc' => __( 'Endpoint for the "Checkout → Add payment method" page.', 'woocommerce' ), - 'id' => 'woocommerce_myaccount_add_payment_method_endpoint', - 'type' => 'text', - 'default' => 'add-payment-method', - 'desc_tip' => true, - ), + array( + 'title' => __( 'Order received', 'woocommerce' ), + 'desc' => __( 'Endpoint for the "Checkout → Order received" page.', 'woocommerce' ), + 'id' => 'woocommerce_checkout_order_received_endpoint', + 'type' => 'text', + 'default' => 'order-received', + 'desc_tip' => true, + ), - array( - 'title' => __( 'Delete payment method', 'woocommerce' ), - 'desc' => __( 'Endpoint for the delete payment method page.', 'woocommerce' ), - 'id' => 'woocommerce_myaccount_delete_payment_method_endpoint', - 'type' => 'text', - 'default' => 'delete-payment-method', - 'desc_tip' => true, - ), + array( + 'title' => __( 'Add payment method', 'woocommerce' ), + 'desc' => __( 'Endpoint for the "Checkout → Add payment method" page.', 'woocommerce' ), + 'id' => 'woocommerce_myaccount_add_payment_method_endpoint', + 'type' => 'text', + 'default' => 'add-payment-method', + 'desc_tip' => true, + ), - array( - 'title' => __( 'Set default payment method', 'woocommerce' ), - 'desc' => __( 'Endpoint for the setting a default payment method page.', 'woocommerce' ), - 'id' => 'woocommerce_myaccount_set_default_payment_method_endpoint', - 'type' => 'text', - 'default' => 'set-default-payment-method', - 'desc_tip' => true, - ), + array( + 'title' => __( 'Delete payment method', 'woocommerce' ), + 'desc' => __( 'Endpoint for the delete payment method page.', 'woocommerce' ), + 'id' => 'woocommerce_myaccount_delete_payment_method_endpoint', + 'type' => 'text', + 'default' => 'delete-payment-method', + 'desc_tip' => true, + ), - array( - 'type' => 'sectionend', - 'id' => 'checkout_endpoint_options', - ), + array( + 'title' => __( 'Set default payment method', 'woocommerce' ), + 'desc' => __( 'Endpoint for the setting a default payment method page.', 'woocommerce' ), + 'id' => 'woocommerce_myaccount_set_default_payment_method_endpoint', + 'type' => 'text', + 'default' => 'set-default-payment-method', + 'desc_tip' => true, + ), - array( - 'title' => __( 'Payment gateways', 'woocommerce' ), - 'desc' => __( 'Installed gateways are listed below. Drag and drop gateways to control their display order on the frontend.', 'woocommerce' ), - 'type' => 'title', - 'id' => 'payment_gateways_options', - ), + array( + 'type' => 'sectionend', + 'id' => 'checkout_endpoint_options', + ), - array( - 'type' => 'payment_gateways', - ), + array( + 'title' => __( 'Payment gateways', 'woocommerce' ), + 'desc' => __( 'Installed gateways are listed below. Drag and drop gateways to control their display order on the frontend.', 'woocommerce' ), + 'type' => 'title', + 'id' => 'payment_gateways_options', + ), - array( - 'type' => 'sectionend', - 'id' => 'payment_gateways_options', - ), + array( + 'type' => 'payment_gateways', + ), - ) ); + array( + 'type' => 'sectionend', + 'id' => 'payment_gateways_options', + ), - if ( wc_site_is_https() ) { - unset( $settings['unforce_ssl_checkout'] ); + ) ); + + if ( wc_site_is_https() ) { + unset( $settings['unforce_ssl_checkout'] ); + } } - return apply_filters( 'woocommerce_get_settings_' . $this->id, $settings ); + return apply_filters( 'woocommerce_get_settings_' . $this->id, $settings, $current_section ); } /** diff --git a/includes/admin/settings/class-wc-settings-shipping.php b/includes/admin/settings/class-wc-settings-shipping.php index 7e2281ea058..7aa27f3bad1 100644 --- a/includes/admin/settings/class-wc-settings-shipping.php +++ b/includes/admin/settings/class-wc-settings-shipping.php @@ -71,61 +71,65 @@ class WC_Settings_Shipping extends WC_Settings_Page { * * @return array */ - public function get_settings() { - $settings = apply_filters( 'woocommerce_shipping_settings', array( + public function get_settings( $current_section = '' ) { + $settings = array(); - array( 'title' => __( 'Shipping options', 'woocommerce' ), 'type' => 'title', 'id' => 'shipping_options' ), + if ( '' === $current_section ) { + $settings = apply_filters( 'woocommerce_shipping_settings', array( - array( - 'title' => __( 'Calculations', 'woocommerce' ), - 'desc' => __( 'Enable the shipping calculator on the cart page', 'woocommerce' ), - 'id' => 'woocommerce_enable_shipping_calc', - 'default' => 'yes', - 'type' => 'checkbox', - 'checkboxgroup' => 'start', - 'autoload' => false, - ), + array( 'title' => __( 'Shipping options', 'woocommerce' ), 'type' => 'title', 'id' => 'shipping_options' ), - array( - 'desc' => __( 'Hide shipping costs until an address is entered', 'woocommerce' ), - 'id' => 'woocommerce_shipping_cost_requires_address', - 'default' => 'no', - 'type' => 'checkbox', - 'checkboxgroup' => 'end', - 'autoload' => false, - ), - - array( - 'title' => __( 'Shipping destination', 'woocommerce' ), - 'desc' => __( 'This controls which shipping address is used by default.', 'woocommerce' ), - 'id' => 'woocommerce_ship_to_destination', - 'default' => 'billing', - 'type' => 'radio', - 'options' => array( - 'shipping' => __( 'Default to customer shipping address', 'woocommerce' ), - 'billing' => __( 'Default to customer billing address', 'woocommerce' ), - 'billing_only' => __( 'Force shipping to the customer billing address', 'woocommerce' ), + array( + 'title' => __( 'Calculations', 'woocommerce' ), + 'desc' => __( 'Enable the shipping calculator on the cart page', 'woocommerce' ), + 'id' => 'woocommerce_enable_shipping_calc', + 'default' => 'yes', + 'type' => 'checkbox', + 'checkboxgroup' => 'start', + 'autoload' => false, ), - 'autoload' => false, - 'desc_tip' => true, - 'show_if_checked' => 'option', - ), - array( - 'title' => __( 'Debug mode', 'woocommerce' ), - 'desc' => __( 'Enable debug mode', 'woocommerce' ), - 'desc_tip' => __( 'Enable shipping debug mode to show matching shipping zones and to bypass shipping rate cache.', 'woocommerce' ), - 'id' => 'woocommerce_shipping_debug_mode', - 'default' => 'no', - 'type' => 'checkbox', - 'autoload' => false, - ), + array( + 'desc' => __( 'Hide shipping costs until an address is entered', 'woocommerce' ), + 'id' => 'woocommerce_shipping_cost_requires_address', + 'default' => 'no', + 'type' => 'checkbox', + 'checkboxgroup' => 'end', + 'autoload' => false, + ), - array( 'type' => 'sectionend', 'id' => 'shipping_options' ), + array( + 'title' => __( 'Shipping destination', 'woocommerce' ), + 'desc' => __( 'This controls which shipping address is used by default.', 'woocommerce' ), + 'id' => 'woocommerce_ship_to_destination', + 'default' => 'billing', + 'type' => 'radio', + 'options' => array( + 'shipping' => __( 'Default to customer shipping address', 'woocommerce' ), + 'billing' => __( 'Default to customer billing address', 'woocommerce' ), + 'billing_only' => __( 'Force shipping to the customer billing address', 'woocommerce' ), + ), + 'autoload' => false, + 'desc_tip' => true, + 'show_if_checked' => 'option', + ), - ) ); + array( + 'title' => __( 'Debug mode', 'woocommerce' ), + 'desc' => __( 'Enable debug mode', 'woocommerce' ), + 'desc_tip' => __( 'Enable shipping debug mode to show matching shipping zones and to bypass shipping rate cache.', 'woocommerce' ), + 'id' => 'woocommerce_shipping_debug_mode', + 'default' => 'no', + 'type' => 'checkbox', + 'autoload' => false, + ), - return apply_filters( 'woocommerce_get_settings_' . $this->id, $settings ); + array( 'type' => 'sectionend', 'id' => 'shipping_options' ), + + ) ); + } + + return apply_filters( 'woocommerce_get_settings_' . $this->id, $settings, $current_section ); } /**