feat(vendor-settings): flat-array Store settings backend (schema, mapper, writer, REST)#3310
Open
MdAsifHossainNadim wants to merge 2 commits into
Conversation
…per, writer, REST) Backend for the vendor Store Settings React migration (PR 1 of 3, spec: getdokan/plugin-internal-tasks#2115). Serves the plugin-ui flat-array schema with values from dokan_profile_settings and persists through the exact legacy pipeline - storage keys and value shapes stay byte-identical. - StoreSettingsSchema: sections/fields with legacy server-side gating; Pro extends via the new dokan_get_vendor_settings_schema filter. - ValueMapper: flat ids -> legacy keys (composite store_map/address, nested catalog_mode preserving RFQ's key + the legacy forced-off rule). - StoreSettingsWriter: shallow merge, dokan_store_name mirror, both legacy seams; never re-applies the legacy dokan_store_time POST filter. - VendorStoreSettingsController: GET/PUT /dokan/v1/vendor-settings/store, 400 {errors:{field_id}} contract, g:i a schedule validation, Pro sanitize/validate extension filters. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Contributor
|
Important Review skippedAuto reviews are disabled on base/target branches other than the default branch. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
This was referenced Jul 8, 2026
…ST saves Verifier finding (plan-aligner #7): RFQ's Seam-A handler is nonce-guarded and silent on REST saves, so a React save turning the cart button back on left request_a_quote_enabled='on' where the identical legacy save writes 'off'. The mapper now applies the same forced-off rule when the key exists, keeping REST and AJAX saves byte-identical. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
All Submissions:
Changes proposed in this Pull Request:
PR 1 of 3 for the vendor Store Settings → React migration (spec: getdokan/plugin-internal-tasks#2115, parent: getdokan/plugin-internal-tasks#1981). This is the pure PHP backend — no UI change, no behavior change for the legacy page.
Serves the plugin-ui flat-array schema with values from
dokan_profile_settingsand persists through the exact legacy save pipeline, so storage keys and value shapes stay byte-identical and every Pro consumer on the two seams keeps working.Vendor/Settings/Schema/StoreSettingsSchema.php— flatSettingsElement[](page → subpage → collapsible section cards → fields) with values populated inline. Conditional blocks use the same server-side gates astemplates/settings/store-form.php: map only withdokan_has_map_api_key(), ToC only whenseller_enable_terms_and_conditionsis on, schedule only when appearancestore_open_closeis on, email visibility hidden perdokan_is_vendor_info_hidden('email'), address handed over when Pro delivery-time is active, catalog-mode per its admin gates. Pro appends via the newdokan_get_vendor_settings_schemafilter (mirrorsdokan_get_admin_settings_schema).Vendor/Settings/ValueMapper.php— flat field ids → legacy keys. Composites handled bespoke:store_map→location+find_address;addressmerges over previous subkeys (preserves store-pickup'slocation_name); catalog-mode ids → nestedcatalog_modearray preserving RFQ'srequest_a_quote_enabled+ the legacy forced-off rule. Any Pro-injected field persists via its stringlegacy_key(defaults to the field id).Vendor/Settings/StoreSettingsWriter.php— the one write path: shallowarray_merge,dokan_store_namemirror meta,dokan_store_profile_settings_argsfilter, canonical meta write,dokan_store_profile_saved( $id, $merged, $prev ). Deliberately never re-applies the legacydokan_store_timePOST-parsing filter (Pro's parser returnsnullwithout the legacy nonce and would wipe the schedule on REST saves).REST/VendorStoreSettingsController.php—GET/PUT /dokan/v1/vendor-settings/storeonDokanBaseVendorController(vendor-staff aware viaget_vendor_id_for_user()), permissiondokandar+dokan_view_store_settings_menu. Validation failures return400 { errors: { field_id: [messages] } }(plugin-ui merges these into per-field errors). Validations use the plugin-ui client contract ([{ rules: 'not_empty', message }]) so one declaration drives both sides; the schedule validator enforces matchingg:i apairs with opening < closing (single Lite slot and Pro multi-slot both accepted). Pro extension filters:dokan_rest_vendor_settings_sanitize_field/dokan_rest_vendor_settings_validate_field.Related Pull Request(s)
Closes
How to test the changes in this Pull Request:
GET /wp-json/dokan/v1/vendor-settings/store— returns the flat schema with current values; sections respect the admin gates (disable the map API key →store_map_sectiondisappears, etc.).PUT /wp-json/dokan/v1/vendor-settings/storewith{ "values": { "store_name": "" } }→400witherrors.store_name.dokan_profile_settingskeys/shapes are byte-identical to a legacy form save ('yes'/'no','on'/'off', attachment-ID ints, per-day{status, opening_time[], closing_time[]}withg:i astrings); untouched keys (payment,vendor_biography, …) survive;dokan_store_namemirror meta syncs; both legacy seams fire (verify a Seam-B consumer like store-support still persists).Changelog entry
Vendor Store Settings flat-array backend
Adds the schema/REST backend for the React vendor Store Settings page. No user-facing change yet: the legacy page keeps rendering and saving as before; storage stays in
dokan_profile_settingswith unchanged keys and value shapes.🤖 Generated with Claude Code