salla-scopes
Modal that lets the customer choose the store scope (a branch or market) they are shopping from, or see a product's availability across scopes.
Modal that lets the customer choose the store scope (a branch or market) they are shopping from, or see a product's availability across scopes. Use it once in the theme layout and open it from a button or link.
Open it with the open() method or by firing the scopes::open event, for example salla.event.dispatch('scopes::open', { mode: 'availability', product_id: 123 }).
With selection="mandatory" the modal opens automatically on load until the customer has chosen a scope once, and it cannot be closed before that.
Inside the native app webview the component renders nothing and hands scope selection to the app.
Use it
In HTML or JSX, use the tag <salla-scopes> with the Attribute names below. In React, the wrapper takes the Property names (camelCase).
import { SallaScopes } from '@salla.sa/twilight-components-react/scopes';Client-only. On the server this wrapper renders a placeholder (a skeleton, or nothing), and the real component mounts in the browser. Do not rely on it for content that search engines must see.
Example
import { SallaScopes } from '@salla.sa/twilight-components-react/scopes';
export function Example() {
return (
<SallaScopes selection="mandatory" searchDisplayLimit={8} />
);
}Properties
| Property | Attribute | Description | Type | Default |
|---|---|---|---|---|
searchDisplayLimit | search-display-limit | Shows the search field only when the number of scopes is greater than this value (a count of scopes, default 6). | number | 6 |
selection | selection | optional lets the customer close the modal. mandatory opens it automatically on load and prevents closing until a scope has been chosen once. | "mandatory" | "optional" | 'optional' |
Methods
Call these on the element or a React ref.
close() => Promise<HTMLElement>
Closes the scope modal.
Returns Promise<HTMLElement>: A Promise that resolves when the modal has closed.
handleSubmit() => Promise<any>
Changes the store scope to the one currently selected in the list, then reloads the page with a scope URL parameter and resets the cart. Used by the default confirm button.
Returns Promise<any>: A Promise that resolves when the change request has finished.
open(mode?: any, product_id?: number) => Promise<any>
Opens the scope modal and loads the scopes (cached after the first load for each mode). Inside the native app it opens the app's own scope sheet instead.
| Parameter | Type | Description |
|---|---|---|
mode | any | default lists scopes to switch to, availability shows a product's availability per scope. Any other value is treated as default. |
product_id | number | The product id to check; used only with the availability mode. |
Returns Promise<any>: A Promise that resolves once the scopes have loaded.
Slots
| Slot | Description |
|---|---|
footer | The bottom section of the component, used for form action. Utilizes the handleSubmit method to submit the form. |
Related
Renders: <salla-placeholder>, <salla-button>, <salla-modal>, <salla-list-tile>, <salla-skeleton>.