diff --git a/plugins/woocommerce-admin/client/settings/content.js b/plugins/woocommerce-admin/client/settings/content.js index 61a74939833..4e7b531dfa5 100644 --- a/plugins/woocommerce-admin/client/settings/content.js +++ b/plugins/woocommerce-admin/client/settings/content.js @@ -67,32 +67,31 @@ export const Content = ( { data, nonce } ) => { // body: JSON.stringify( gatherFormInputs() ), // } ); - // const { page } = useSettingsLocation(); - // const formData = new FormData(); - // const formInputs = gatherFormInputs(); - // for ( const [ key, value ] of Object.entries( formInputs ) ) { - // formData.append( key, value ); - // } - // // Add _wpnonce to form data + const { page } = useSettingsLocation(); + const formData = new FormData(); + const formInputs = gatherFormInputs(); + for ( const [ key, value ] of Object.entries( formInputs ) ) { + formData.append( key, value ); + } + // Add _wpnonce to form data // formData.append( '_wpnonce', nonce ); - // formData.append( 'save', 'Save changes' ); - // formData.append( 'save_type', 'modern_settings' ); + formData.append( 'save', 'Save changes' ); - // const response = await fetch( - // // `/wp-admin/admin.php?page=wc-settings&tab=${ page }`, - // // `/wp-json/wc/v3/modern-settings`, - // `/wp-json/wc-admin/settings`, - // { - // method: 'POST', - // body: formData, - // } - // ); + const response = await fetch( + // `/wp-admin/admin.php?page=wc-settings&tab=${ page }`, + // `/wp-json/wc/v3/modern-settings`, + '/wp-json/wc-admin/settings', + { + method: 'POST', + body: formData, + } + ); - const response = await fetch( '/wp-json/wc-admin/settings', { - method: 'POST', - headers: { 'content-type': 'application/json' }, - body: JSON.stringify( gatherFormInputs() ), - } ); + // const response = await fetch( '/wp-json/wc-admin/settings', { + // method: 'POST', + // headers: { 'content-type': 'application/json' }, + // body: JSON.stringify( gatherFormInputs() ), + // } ); console.log( response ); diff --git a/plugins/woocommerce/package.json b/plugins/woocommerce/package.json index 9683d1f7905..7f93452575e 100644 --- a/plugins/woocommerce/package.json +++ b/plugins/woocommerce/package.json @@ -20,7 +20,6 @@ "build:project:copy-assets:admin": "wireit", "build:project:copy-assets:blocks": "wireit", "build:project:actualize-translation-domains": "wireit", - "build:zip": "./bin/build-zip.sh", "changelog": "XDEBUG_MODE=off composer install --quiet && composer exec -- changelogger", "docker:down": "pnpm exec wc-e2e docker:down", "docker:ssh": "pnpm exec wc-e2e docker:ssh", @@ -721,6 +720,7 @@ "node_modules/@woocommerce/e2e-core-tests/CHANGELOG.md", "node_modules/@woocommerce/api/dist/", "node_modules/@woocommerce/admin-e2e-tests/build", + "node_modules/@woocommerce/classic-assets/build", "node_modules/@woocommerce/block-library/build", "node_modules/@woocommerce/block-library/blocks.ini", "node_modules/@woocommerce/admin-library/build", diff --git a/plugins/woocommerce/src/Admin/API/Init.php b/plugins/woocommerce/src/Admin/API/Init.php index 541123022ed..4d3ac0dff6d 100644 --- a/plugins/woocommerce/src/Admin/API/Init.php +++ b/plugins/woocommerce/src/Admin/API/Init.php @@ -73,6 +73,7 @@ class Init { 'Automattic\WooCommerce\Admin\API\MarketingCampaigns', 'Automattic\WooCommerce\Admin\API\MarketingCampaignTypes', 'Automattic\WooCommerce\Admin\API\Options', + 'Automattic\WooCommerce\Admin\API\Settings', 'Automattic\WooCommerce\Admin\API\PaymentGatewaySuggestions', 'Automattic\WooCommerce\Admin\API\Themes', 'Automattic\WooCommerce\Admin\API\Plugins', diff --git a/plugins/woocommerce/src/Admin/API/Settings.php b/plugins/woocommerce/src/Admin/API/Settings.php index 67b256cf2f0..cd358dddb63 100644 --- a/plugins/woocommerce/src/Admin/API/Settings.php +++ b/plugins/woocommerce/src/Admin/API/Settings.php @@ -33,7 +33,6 @@ class Settings extends \WC_REST_Data_Controller { * Register routes. */ public function register_routes() { - error_log( 'register_routes for settings' ); register_rest_route( $this->namespace, '/' . $this->rest_base, @@ -43,6 +42,7 @@ class Settings extends \WC_REST_Data_Controller { 'callback' => array( $this, 'save_settings' ), 'permission_callback' => array( $this, 'permissions_check' ), ), + 'schema' => array( $this, 'get_item_schema' ), ) ); } @@ -55,7 +55,6 @@ class Settings extends \WC_REST_Data_Controller { */ public function permissions_check( $request ) { return true; - // return current_user_can( 'manage_options' ); } /** @@ -65,6 +64,25 @@ class Settings extends \WC_REST_Data_Controller { * @return WP_Error|WP_REST_Response */ public function save_settings( $request ) { + error_log('this is workign'); return new \WP_REST_Response( array( 'status' => 'success' ) ); } + + public function get_item_schema() { + $schema = array( + '$schema' => 'http://json-schema.org/draft-04/schema#', + 'title' => 'options', + 'type' => 'object', + 'properties' => array( + 'options' => array( + 'type' => 'array', + 'description' => __( 'Array of options with associated values.', 'woocommerce' ), + 'context' => array( 'view' ), + 'readonly' => true, + ), + ), + ); + + return $schema; + } } \ No newline at end of file