### Get and Use Recaptcha Instance Source: https://storefront.developers.shoper.pl/js-api/apis/recaptcha/methods/get-recaptcha-ready-instance This example demonstrates how to retrieve the Recaptcha instance using `getRecaptchaReadyInstance` and then use its `ready` and `execute` methods to generate a token. Ensure you have the `RecaptchaV3Api` available in your storefront context. ```javascript useStorefront(async (storefront) => { const recaptchaApi = await storefront.getApi('RecaptchaV3Api'); const recaptchaInstance = await recaptchaApi.getRecaptchaReadyInstance(); recaptchaInstance.ready(function() { recaptchaInstance.execute('reCAPTCHA_site_key', { action: 'submit' }).then(function(token) { // Add your logic to submit to your backend server here. }); }); }); ``` -------------------------------- ### Search Popup Form with Opener and Modal Source: https://storefront.developers.shoper.pl/webcomponents/webcomponents/functional/search-popup-form This example demonstrates a complete `` setup, including an opener button and the modal dialog structure. The `module-instance-id` is crucial for linking the opener to the modal. ```html Open search engine

Search

``` -------------------------------- ### Registering a Command Listener Source: https://storefront.developers.shoper.pl/webcomponents/events/buses/command-bus/methods/on This example demonstrates how to use the `on` method to listen for a command named 'example-command' and execute a callback function when it's emitted. ```APIDOC ## commandBus.on ### Description Allows to listen to the command similarly to how `addEventListener` works for DOM events. ### Parameters #### messageName `messageName` is a mandatory parameter of the `string` type which represents the name of the message to listen to. #### listener `listener` is a mandatory parameter of type TMessageListener which represents a callback for the command emission. ### Example ```javascript useStorefront(async (storefront) => { storefront.commandBus.on('example-command', () => { console.log('Listening to the command...') }); }); ``` ``` -------------------------------- ### year Property Example Source: https://storefront.developers.shoper.pl/object-api/objects/datetime/datetime Get the year. ```APIDOC ### `year` property #### Source ``` {% set datetime = ObjectApi.getDateTime("2022-09-01") %} {{ datetime.year }} ``` #### Output ``` 2022 ``` ``` -------------------------------- ### Example: Get Selected Payment Option Source: https://storefront.developers.shoper.pl/js-api/apis/basket/apis/basket-payments-api/basket-payments-api This example demonstrates how to retrieve the currently selected payment option using the `basketPaymentsApi`. ```APIDOC ## Example In this example, we use the `basketPaymentsApi` to retrieve the currently selected payment option. ```javascript useStorefront(async ({ eventBus, getApi }) => { eventBus.on('basket.initialized', async () => { const basketPaymentsApi = await getApi('basketPaymentsApi'); const selectedPayment = basketPaymentsApi.getSelectedPayment(); if (selectedPayment) { console.log('Selected payment option:', selectedPayment); } else { console.log('No payment option has been selected.'); } }); }); ``` ``` -------------------------------- ### Start Theme Watch Mode with Live Preview Source: https://storefront.developers.shoper.pl/cli/how-to-examples Enable real-time development by automatically uploading theme changes and refreshing the browser preview. Use `--open` to automatically launch the store preview in your browser. ```bash shoper theme watch --open ``` -------------------------------- ### Example Creation Date Source: https://storefront.developers.shoper.pl/object-api/objects/products/product Shows an example of the product's creation date format. ```text 23 september 2019 ``` -------------------------------- ### hours Property Example Source: https://storefront.developers.shoper.pl/object-api/objects/datetime/datetime Get the number of hours. ```APIDOC ### `hours` property #### Source ``` {% set datetime = ObjectApi.getDateTime("2022-09-01 12:30:15") %} {{ datetime.hours }} ``` #### Output ``` 12 ``` ``` -------------------------------- ### Get Special Offer Start Date Source: https://storefront.developers.shoper.pl/object-api/objects/special-offer/special-offer Retrieve the start date of a special offer. The date is formatted as 'day month year'. ```html {{ specialOffer.startDate.date }} ``` -------------------------------- ### Product Files HTML Example Source: https://storefront.developers.shoper.pl/styling/components/product/product-files Demonstrates the structure of the product files component with nested file boxes. Use this to implement product file listings. ```html

Example header

File icon Title 10 kb

File description

File icon Title 10 kb

File description

``` -------------------------------- ### Execute Command and Handle Response Source: https://storefront.developers.shoper.pl/webcomponents/events/buses/command-bus/methods/execute This example demonstrates executing a command and asynchronously handling its response using a Promise. It also shows how to register a listener for a specific command. ```javascript useStorefront(async (storefront) => { storefront.commandBus.on('get-body-length', function ({ body }) { const bodyLength = typeof body === 'string' ? body.length : 0; return bodyLength; }); storefront.commandBus.execute({ name: 'get-body-length', type: 'command', body: 'command body' }).then((bodyLength) => { console.log('body length:', bodyLength); }); }); ``` -------------------------------- ### time Property Example Source: https://storefront.developers.shoper.pl/object-api/objects/datetime/datetime Get the formatted time string. ```APIDOC ### `time` property #### Source ``` {% set datetime = ObjectApi.getDateTime("2022-09-01 12:30:15") %} {{ datetime.time }} ``` #### Output ``` 12:30:15 ``` ``` -------------------------------- ### Example Video Rendering Source: https://storefront.developers.shoper.pl/macros/video This example demonstrates how to set up and render a video using the video macro, dynamically configuring settings based on module configuration. ```twig {% from "@macros/video.twig" import video %} {% set src = moduleConfig.videoType == 'self-hosted' ? moduleConfig.ownVideoLink : moduleConfig.youtubeVideoLink %} {% set autoplay = moduleConfig.autoplay %} {% set controls = moduleConfig.videoType == 'self-hosted' ? moduleConfig.vidControls : moduleConfig.controls %} {% set muted = moduleConfig.vidMuted %} {% set loop = moduleConfig.vidLoop %} {% set locale = ObjectApi.getShopLocale() %} {% set currentLanguage = locale.locale|split('_')[0] %} {% set video_settings = { video_type: moduleConfig.videoType, posterSrc: moduleConfig.addPosterImage ? moduleConfig.posterImage.paths.original : "", videoDescription: moduleConfig.videoDescription, autoplay: autoplay == '1', controls: controls == '1', muted: muted == '1', loop: loop == '1', aspectRatio: moduleConfig.youtubeAspectRatio|default('16/9'), captionTrackLink: moduleConfig.captionTrackLink, captionLang: currentLanguage, audioDescriptionTrackLink: moduleConfig.audioDescriptionTrackLink, audioDescriptionLang: currentLanguage, transcriptTrackLink: moduleConfig.transcriptTrackLink } %} {{ video(src, video_settings|merge({ moduleInstanceId: moduleInstance })) }} ``` -------------------------------- ### seconds Property Example Source: https://storefront.developers.shoper.pl/object-api/objects/datetime/datetime Get the number of seconds (0-59). ```APIDOC ### `seconds` property #### Source ``` {% set datetime = ObjectApi.getDateTime("2022-09-01 12:30:15") %} {{ datetime.seconds }} ``` #### Output ``` 15 ``` ``` -------------------------------- ### Listening to a Query Source: https://storefront.developers.shoper.pl/webcomponents/events/buses/query-bus/methods/on This example demonstrates how to use the `on` method to listen for a specific query message named 'example-query' and execute a callback function when it's emitted. ```APIDOC ## queryBus.on ### Description Allows to listen to the query similarly to how `addEventListener` works for DOM events. ### Parameters #### messageName - **messageName** (string) - Required - The name of the message to listen to. #### listener - **listener** (TMessageListener) - Required - A callback function for the query emission. ### Example ```javascript useStorefront(async (storefront) => { storefront.queryBus.on('example-query', () => { console.log('Listening to the query...') }); }); ``` ``` -------------------------------- ### minutes Property Example Source: https://storefront.developers.shoper.pl/object-api/objects/datetime/datetime Get the number of minutes (0-59). ```APIDOC ### `minutes` property #### Source ``` {% set datetime = ObjectApi.getDateTime("2022-09-01 12:30:15") %} {{ datetime.minutes }} ``` #### Output ``` 30 ``` ``` -------------------------------- ### weekdayShort Property Example Source: https://storefront.developers.shoper.pl/object-api/objects/datetime/datetime Get the short name of the weekday. ```APIDOC ### `weekdayShort` property #### Source ``` {% set datetime = ObjectApi.getDateTime("2022-09-01") %} {{ datetime.weekdayShort }} ``` #### Output ``` thu. ``` ``` -------------------------------- ### Twig Example for Product Details Source: https://storefront.developers.shoper.pl/sve/elements/product-selector Demonstrates fetching and displaying product details (name, description, URL) using the ObjectApi and module configuration in Twig. ```twig {% set productId = moduleConfig.selectedProductId %} {% if productId %} {% set product = ObjectApi.getProduct(productId) %} {% if product %}

{{ product.name }}

{% if moduleConfig.showDescription and product.description %}

{{ product.description|raw }}

{% endif %}
{{ translate("See product") }}
{% endif %} {% endif %} ``` -------------------------------- ### Example Product Quantity and Availability Usage Source: https://storefront.developers.shoper.pl/styling/components/product/product-quantity-and-availability Demonstrates the integration of product quantity and availability components with the h-input-stepper webcomponent. Ensure necessary icon assets are available. ```html
zestaw
Availability:
In stock
``` -------------------------------- ### weekday Property Example Source: https://storefront.developers.shoper.pl/object-api/objects/datetime/datetime Get the full name of the weekday. ```APIDOC ### `weekday` property #### Source ``` {% set datetime = ObjectApi.getDateTime("2022-09-01") %} {{ datetime.weekday }} ``` #### Output ``` thursday ``` ``` -------------------------------- ### monthNameShort Property Example Source: https://storefront.developers.shoper.pl/object-api/objects/datetime/datetime Get the short name of the month. ```APIDOC ### `monthNameShort` property #### Source ``` {% set datetime = ObjectApi.getDateTime("2022-09-01") %} {{ datetime.monthNameShort }} ``` #### Output ``` sep. ``` ``` -------------------------------- ### Display Shop Name Example Source: https://storefront.developers.shoper.pl/object-api/objects/shop/info Shows an example output for the shop's name. ```text My shop ``` -------------------------------- ### monthName Property Example Source: https://storefront.developers.shoper.pl/object-api/objects/datetime/datetime Get the full name of the month. ```APIDOC ### `monthName` property #### Source ``` {% set datetime = ObjectApi.getDateTime("2022-09-01") %} {{ datetime.monthName }} ``` #### Output ``` september ``` ``` -------------------------------- ### Hello World in C Source: https://storefront.developers.shoper.pl/example A standard 'Hello, World!' program in C. This is a basic example for beginners. ```c #include int main(void) { printf("Hello world!\n"); return 0; } ``` -------------------------------- ### month Property Example Source: https://storefront.developers.shoper.pl/object-api/objects/datetime/datetime Get the month number (1-12). ```APIDOC ### `month` property #### Source ``` {% set datetime = ObjectApi.getDateTime("2022-09-01") %} {{ datetime.month }} ``` #### Output ``` 9 ``` ``` -------------------------------- ### dayOfYear Property Example Source: https://storefront.developers.shoper.pl/object-api/objects/datetime/datetime Get the day of the year (1-366). ```APIDOC ### `dayOfYear` property #### Source ``` {% set datetime = ObjectApi.getDateTime("2022-09-01") %} {{ datetime.dayOfYear }} ``` #### Output ``` 244 ``` ``` -------------------------------- ### Display Shop Version Example Source: https://storefront.developers.shoper.pl/object-api/objects/shop/info Shows an example of the shop's version number. ```text 5.24.40 ``` -------------------------------- ### Module Configuration Schema Example Source: https://storefront.developers.shoper.pl/modules/rosters/roster-product-bestsellers This JSON snippet illustrates a part of a module configuration schema, showing how to define relations between parent properties and actions like setting visibility or enabled states. ```json { "allowVariables": true }, "relations": [ { "parentName": "hasImageBackgroundColor", "parentValueToActionsMap": [ { "value": 0, "actions": [ "setHidden", "setDisabled" ] }, { "value": 1, "actions": [ "setVisible", "setAvailable" ] } ] } ] } ] } ] } ] ``` -------------------------------- ### day Property Example Source: https://storefront.developers.shoper.pl/object-api/objects/datetime/datetime Get the day of the month (1-31). ```APIDOC ### `day` property #### Source ``` {% set datetime = ObjectApi.getDateTime("2022-09-01") %} {{ datetime.day }} ``` #### Output ``` 1 ``` ``` -------------------------------- ### Example Module JSON Configuration Source: https://storefront.developers.shoper.pl/sve/elements/numbers-syncer JSON configuration for an example module, defining a 'verticalPadding' NumbersSyncer element with various options and settings. ```json [ { "label": "General settings", "state": "folded", "elements": [ { "name": "verticalPadding", "type": "numbersSyncer", "hint": { "message": "For more information see [here](%s)", "placeholderValues": ["https:\/\/www.shoper.pl"] }, "options": { "prefix": "+", "postfix": "px", "placeholder": "10", "firstLabel": "Top", "secondLabel": "Bottom", "min": 0, "max": 10 }, "label": "Padding", "labelDescription": "Creates internal spacing between the element's content and its border.", "isHidden": false, "isRequired": true } ] } ] ``` -------------------------------- ### date Property Example Source: https://storefront.developers.shoper.pl/object-api/objects/datetime/datetime Get the formatted date string. ```APIDOC ### `date` property #### Source ``` {% set datetime = ObjectApi.getDateTime("2022-09-01") %} {{ datetime.date }} ``` #### Output ``` 1 september 2022 ``` ``` -------------------------------- ### Basic Address Rendering Example Source: https://storefront.developers.shoper.pl/macros/address Demonstrates how to import and use the address macro with sample data to display a formatted address. ```twig {% from "@macros/address.twig" import address %} {{ address({ name: 'Shoper', addressLine1: 'ul. Pawia 9', zipCode: '31-154', city: 'Kraków', country: { name: 'Polska' }, phoneNumber: '+48 501 509 509', email: 'pomoc@shoper.pl' }) }} ``` -------------------------------- ### Example: Get Payment Channel Strategy Source: https://storefront.developers.shoper.pl/js-api/apis/basket/apis/basket-payments-api/basket-payments-api This example shows how to retrieve the payment channel strategy for a specific channel key using `basketPaymentsApi`. ```APIDOC ## Example In this example, we use the `basketPaymentsApi` to retrieve the payment channel strategy for a given channel key. ```javascript useStorefront(async ({ eventBus, getApi }) => { eventBus.on('basket.initialized', async () => { const basketPaymentsApi = await getApi('basketPaymentsApi'); const channelKey = 'paypal'; const paymentChannelStrategy = basketPaymentsApi.getPaymentChannelStrategy(channelKey); console.log(`Payment channel strategy for ${channelKey}:`, paymentChannelStrategy); }); }); ``` ``` -------------------------------- ### weekdayDigit Property Example Source: https://storefront.developers.shoper.pl/object-api/objects/datetime/datetime Get the weekday as a digit (1=Monday, 7=Sunday). ```APIDOC ### `weekdayDigit` property #### Source ``` {% set datetime = ObjectApi.getDateTime("2022-09-01") %} {{ datetime.weekdayDigit }} ``` #### Output ``` 4 ``` ``` -------------------------------- ### Rate a Product using RateAndReviewApi Source: https://storefront.developers.shoper.pl/js-api/apis/rate-and-review/methods/rate This example demonstrates how to use the `rate` method from the `RateAndReviewApi` to submit a rating for a product. Ensure you have access to the storefront instance and have retrieved the `rateAndReviewApi`. ```javascript useStorefront((storefront) => { const rateAndReviewApi = await storefront.getApi('rateAndReviewApi'); await rateAndReviewApi.rate({ productId: "145", rating: 5, challenge: "xYz" }); }); ``` -------------------------------- ### Listening to an Event Source: https://storefront.developers.shoper.pl/webcomponents/events/buses/event-bus/methods/on This example demonstrates how to use the `on` method to listen for a specific event, 'example-event'. A callback function is provided to handle the event when it is emitted. ```APIDOC ## eventBus.on ### Description Allows to listen to the event similarly to how `addEventListener` works for DOM events. ### Parameters #### Path Parameters - **messageName** (string) - Required - The name of the message to listen to. - **listener** (TMessageListener) - Required - A callback for the event emission. ### Request Example ```javascript useStorefront(async (storefront) => { storefront.eventBus.on('example-event', () => { console.log('Listening to the event...') }); }); ``` ``` -------------------------------- ### week Property Example Source: https://storefront.developers.shoper.pl/object-api/objects/datetime/datetime Get the week number of the year (1-53). ```APIDOC ### `week` property #### Source ``` {% set datetime = ObjectApi.getDateTime("2022-09-01") %} {{ datetime.week }} ``` #### Output ``` 35 ``` ``` -------------------------------- ### Example Pickup Point Map and Strategy Source: https://storefront.developers.shoper.pl/js-models/models/delivery/pickup/pickup-point-map-strategy Demonstrates an example implementation of IPickupPointMap and PickupPointMapStrategy. Use this as a reference for creating your own strategy. ```typescript class ExampleDeliveryPointMap { public async showMap(choosePickupPointCallback) { // here goes code for showing a map } } class ExamplePickupPointMapStrategy { public execute() { return ExampleDeliveryPointMap; } } ``` -------------------------------- ### dateShort Property Example Source: https://storefront.developers.shoper.pl/object-api/objects/datetime/datetime Get the short formatted date string. ```APIDOC ### `dateShort` property #### Source ``` {% set datetime = ObjectApi.getDateTime("2022-09-01") %} {{ datetime.dateShort }} ``` #### Output ``` 13-04-2022 ``` ``` -------------------------------- ### iso8601 Property Example Source: https://storefront.developers.shoper.pl/object-api/objects/datetime/datetime Get the ISO 8601 formatted date string. ```APIDOC ### `iso8601` property #### Source ``` {{ datetime.iso8601 }} ``` #### Output ``` 2022-04-13 ``` ``` -------------------------------- ### Product Selector Configuration Example Source: https://storefront.developers.shoper.pl/sve/elements/product-selector An example of a product selector configuration, specifying its type, name, label, default value, and a lessEqThan validator. ```json { "type" : "productSelector", "name" : "product", "label" : "Displayed product", "isRequired" : false, "isHidden" : false, "defaultValue" : 12, "validators": [ { "type" : "lessEqThan", "options" : { "max" : 25 } } ] } ``` -------------------------------- ### Get User Addresses Observable Source: https://storefront.developers.shoper.pl/js-api/apis/user-api/methods/select-addresses Use this snippet to fetch the observable stream of user addresses. Subscribe to the observable to get the addresses and process them, for example, to find the default shipping address. ```javascript useStorefront(async (storefront) => { const userApi = await storefront.getApi('UserApi'); const userAddresses$ = await userApi.selectAddresses$(); userAddresses$.subscribe((addresses) => { const currentDefaultShippingAddress = addresses.find((address) => address.isShippingDefault); console.log('first name on the current default shipping address:', currentDefaultShippingAddress.address.firstName) }); }); ``` -------------------------------- ### Example Usage Source: https://storefront.developers.shoper.pl/webcomponents/webcomponents/form/controls/h-color-swatches-control Example of how to use the H-Color-Swatches-Control in HTML. ```APIDOC ## Example ```html ``` ``` -------------------------------- ### Product Actions HTML Example Source: https://storefront.developers.shoper.pl/styling/components/product/product-actions Demonstrates the basic HTML structure for product actions, including buttons for adding to basket and favorites. ```html
``` -------------------------------- ### dateLong Property Example Source: https://storefront.developers.shoper.pl/object-api/objects/datetime/datetime Get the long formatted date string, including the day of the week. ```APIDOC ### `dateLong` property #### Source ``` {% set datetime = ObjectApi.getDateTime("2022-09-01") %} {{ datetime.dateLong }} ``` #### Output ``` thursday, 1 september 2022 ``` ``` -------------------------------- ### Accessing `time` Property Source: https://storefront.developers.shoper.pl/object-api/objects/datetime/time Example of how to access the `time` property to get the formatted time string. ```APIDOC ## Accessing `time` Property ### Description Access the `time` property to retrieve the formatted time string. ### Source ```twig {% set time = ObjectApi.getTime("12:30:15") %} {{ time.time }} ``` ### Output Example ``` 12:30:15 ``` ``` -------------------------------- ### Radio Options Configuration Source: https://storefront.developers.shoper.pl/sve/elements/radio A comprehensive JSON example demonstrating various configurations for radio options, including keys, labels, descriptions, and hints with placeholders. ```json { "options": { "radioOptions" : [ { "key" : "KEY 1" , "label" : "Label 1"}, { "key" : "KEY 2" , "label" : "Label 2", "labelDescription" : "additional description for option 2"}, { "key" : "KEY 3" , "label" : "Label 3", "hint" : "hint for option 3 as markdown"}, { "key" : "KEY 4" , "label" : "Label 4", "hint" : "hint for option 4", "labelDescription" : "Description" }, { "key" : "KEY 5" , "label" : "Label 5", "labelDescription" : "Description", "hint" : { "message" : "Message as markdown %s %s", "placeholderValues" : ["placeholder 1", "placeholder 2"] } } ] } } ``` -------------------------------- ### Accessing `timeInSeconds` Property Source: https://storefront.developers.shoper.pl/object-api/objects/datetime/time Example of how to access the `timeInSeconds` property to get the time representation in seconds. ```APIDOC ## Accessing `timeInSeconds` Property ### Description Access the `timeInSeconds` property to retrieve the time representation in seconds. ### Source ```twig {% set time = ObjectApi.getTime("12:30:15") %} {{ time.timeInSeconds }} ``` ### Output Example ``` 45015 ``` ``` -------------------------------- ### PointPicker Element Example Configuration Source: https://storefront.developers.shoper.pl/sve/elements/point-picker An example of how to configure a PointPicker element within a larger configuration object. ```json { "type" : "pointPicker", "name" : "hotspotPosition", "label" : "Hotspot position", "labelDescription" : "Select the position of the hotspot on the image", "isRequired" : true, "isHidden" : false, "defaultValue" : { "x" : 50, "y" : 50, "unit" : "%" } } ``` -------------------------------- ### ProducerSelector Example Configuration Source: https://storefront.developers.shoper.pl/sve/elements/producer-selector An example of a producerSelector element configuration, demonstrating how to set its properties and include validators like 'lessEqThan'. ```json { "type" : "producerSelector", "name" : "producer", "label" : "Displayed producer", "isRequired" : false, "isHidden" : false, "defaultValue" : 12, "validators": [ { "type" : "lessEqThan", "options" : { "max" : 25 } } ] } ``` -------------------------------- ### timestamp Property Example Source: https://storefront.developers.shoper.pl/object-api/objects/datetime/datetime Get the date representation in seconds, converted using the shop's timezone. ```APIDOC ### `timestamp` property #### Source ``` {% set datetime = ObjectApi.getDateTime("2022-09-01") %} {{ datetime.timestamp }} ``` #### Output ``` 1661990400 ``` ``` -------------------------------- ### timeInSeconds Property Example Source: https://storefront.developers.shoper.pl/object-api/objects/datetime/datetime Get the date representation in seconds, converted using the shop's timezone. ```APIDOC ### `timeInSeconds` property #### Source ``` {% set datetime = ObjectApi.getDateTime("2022-09-01") %} {{ datetime.timeInSeconds }} ``` #### Output ``` 1661990400 ``` ``` -------------------------------- ### Base URL Example Source: https://storefront.developers.shoper.pl/object-api/objects/filters/filters Example output for the base URL. ```text /base/url ``` -------------------------------- ### Fetch Products with Options Source: https://storefront.developers.shoper.pl/js-api/apis/product-fetcher-api/objects/t-get-products-options Demonstrates how to use the TGetProductsOptions object to specify pagination parameters when fetching products via the ProductFetcherApi. ```javascript useStorefront(async (storefront) => { const productFetcherApi = await storefront.getApi('ProductFetcherApi'); const getProductsOptions = { queryParams: { page: 1, limit: 10 } }; const products = await productFetcherApi.getProducts([1, 2], getProductsOptions); console.log(products); }); ``` -------------------------------- ### Accessing `seconds` Property Source: https://storefront.developers.shoper.pl/object-api/objects/datetime/time Example of how to access the `seconds` property to get the number of seconds from the Time object. ```APIDOC ## Accessing `seconds` Property ### Description Access the `seconds` property to retrieve the number of seconds. ### Source ```twig {% set time = ObjectApi.getTime("12:30:15") %} {{ time.seconds }} ``` ### Output Example ``` 15 ``` ``` -------------------------------- ### Module Example with PointPicker Source: https://storefront.developers.shoper.pl/sve/elements/point-picker A complete TWIG example for a module that uses an image and a PointPicker to position a hotspot pin on that image. ```twig
{{ translate("Pin") }}
``` -------------------------------- ### Accessing `minutes` Property Source: https://storefront.developers.shoper.pl/object-api/objects/datetime/time Example of how to access the `minutes` property to get the number of minutes from the Time object. ```APIDOC ## Accessing `minutes` Property ### Description Access the `minutes` property to retrieve the number of minutes. ### Source ```twig {% set time = ObjectApi.getTime("12:30:15") %} {{ time.minutes }} ``` ### Output Example ``` 30 ``` ``` -------------------------------- ### Accessing `hours` Property Source: https://storefront.developers.shoper.pl/object-api/objects/datetime/time Example of how to access the `hours` property to get the number of hours from the Time object. ```APIDOC ## Accessing `hours` Property ### Description Access the `hours` property to retrieve the number of hours. ### Source ```twig {% set time = ObjectApi.getTime("12:30:15") %} {{ time.hours }} ``` ### Output Example ``` 12 ``` ``` -------------------------------- ### Basic Storefront Search Configuration Source: https://storefront.developers.shoper.pl/webcomponents/webcomponents/functional/h-storefront-search Configure the storefront search component with basic settings. This example shows how to enable phrase suggestions and search within categories, producers, and products. ```html ``` -------------------------------- ### Translate a phrase Source: https://storefront.developers.shoper.pl/js-api/apis/translations-api/methods/translate This example demonstrates how to use the translate method to get a translated phrase for a given key. ```APIDOC ## translate(key: TranslationKeys, options?: TTranslationOptions): string ### Description The `translate` method allows to translate a given phrase to a currently selected language in the shop. ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Parameters #### key `key` is a mandatory parameter of TranslationKeys type which represents a key that will be translated. #### options `options` is an optional parameter of TTranslationOptions type which represents options of a translation. ### Returned value A returned value has a type of `string` which represents a translated phrase based on the provided key and a currently selected language in the shop. ### Example ```javascript useStorefront(async (storefront) => { const translationsApi = await storefront.getApi('TranslationsApi'); const translatedPhrase = translationsApi.translate('Example phrase'); }); ``` ``` -------------------------------- ### Get Previous Breakpoint Example Source: https://storefront.developers.shoper.pl/js-api/apis/resolution-detector-api/methods/get-previous-breakpoint Use this method to retrieve the previously active breakpoint. It returns a `Breakpoint` object or `undefined` if no previous breakpoint was found. The example logs the name and width of the previous breakpoint if it exists. ```javascript useStorefront(async (storefront) => { const resolutionDetectorApi = storefront.getApiSync('ResolutionDetectorApi'); const previousBreakpoint = resolutionDetectorApi.getPreviousBreakpoint(); if (!previousBreakpoint) return; console.log(`Previous breakpoint was ${previousBreakpoint.name} which applied to screens of ${previousBreakpoint.value}px width and below.`); }); ``` -------------------------------- ### Render Product Price with Promotion Source: https://storefront.developers.shoper.pl/macros/product-price This example shows how to render a product price that is currently on promotion, including a specified percentage discount. Set `hasSpecialOffer` to true and provide the `percentageDiscountValue`. ```twig {% from "@macros/product_price.twig" import product_price %} {{ product_price({ priceValue: "$10.35", hasSpecialOffer: true, percentageDiscountValue: "12%" }) }} ``` -------------------------------- ### Display Profile Example Source: https://storefront.developers.shoper.pl/object-api/objects/shop/info Shows an example of the shop's profile. ```text clothes ``` -------------------------------- ### Render Loyalty Exchange Guide Modal with h-modal-opener Source: https://storefront.developers.shoper.pl/macros/loyalty-exchange-guide-modal This example shows how to render the loyalty exchange guide modal along with an `h-modal-opener` web component. Ensure the 'name' attribute of `h-modal-opener` matches the `modalName` option. ```twig {% from "@macros/loyalty_exchange_guide_modal.twig" import loyalty_exchange_guide_modal %} {{ loyalty_exchange_guide_modal({ modalName: 'some-modal-name' }) }} ``` -------------------------------- ### Using Product Bundles Webcomponent Source: https://storefront.developers.shoper.pl/webcomponents/webcomponents/bundle/product-bundles This example demonstrates the usage of the `` webcomponent, including nested `` components. It shows how to structure the HTML for displaying bundle items and their availability. ```html
example alt

Miniwulkan

Dostępność:
dostępny na zamówienie
example alt

Example product

Dostępność:
brak informacji
``` -------------------------------- ### Accessing `timeShort` Property Source: https://storefront.developers.shoper.pl/object-api/objects/datetime/time Example of how to access the `timeShort` property to get the formatted time string without seconds. ```APIDOC ## Accessing `timeShort` Property ### Description Access the `timeShort` property to retrieve the formatted time string without seconds. ### Source ```twig {% set time = ObjectApi.getTime("12:30:15") %} {{ time.timeShort }} ``` ### Output Example ``` 12:30 ``` ``` -------------------------------- ### Accessing `iso8601` Property Source: https://storefront.developers.shoper.pl/object-api/objects/datetime/time Example of how to access the `iso8601` property to get the ISO 8601 formatted time string. ```APIDOC ## Accessing `iso8601` Property ### Description Access the `iso8601` property to retrieve the time in ISO 8601 format. ### Source ``` {{ time.iso8601 }} ``` ### Output Example ``` 11:12:13 ``` ``` -------------------------------- ### Example Usage of Bundle Items in Twig Source: https://storefront.developers.shoper.pl/styling/components/bundle/bundle-items Demonstrates how to render bundle items using Twig, iterating through product bundle items and applying necessary classes and configurations. ```twig {% from "@macros/product_bundle_item_tile.twig" import product_bundle_item_tile %} {% set product = ObjectApi.getProduct(product_id) %}
{% for bundleItem in product.bundle.items %} {% if not loop.first %}

+

{% endif %} {% set variantId = moduleInstanceId ~ "-#{bundleItem.variant.product.id}" %} {{ product_bundle_item_tile( bundleItem, moduleConfig|merge({ instanceId: variantId, groupFlashMessengerName }) ) }} {% endfor %}
``` -------------------------------- ### Get All Listeners for a Message Source: https://storefront.developers.shoper.pl/webcomponents/events/buses/query-bus/methods/get-listeners This example demonstrates how to retrieve and log all listeners associated with a particular message name using the `getListeners` method. ```APIDOC ## queryBus.getListeners The `getListeners` method allows to get all listeners of given message. ### Parameters #### Input parameters - **messageName** (string) - Required - The name of the message to get the listeners from. ### Returned value - **TMessageListener[]** - An array of message listeners. ### Example ```javascript useStorefront(async (storefront) => { const listeners = storefront.queryBus.getListeners('my-query'); console.log('listeners of my-query:'); listeners.forEach((listener) => { console.log('listener:', listener) }) }); ``` ``` -------------------------------- ### Render Product Price with Unit Price and Promotion Details Source: https://storefront.developers.shoper.pl/macros/product-price This example renders a product price that includes a unit price and displays promotion details such as duration and the regular price alongside the promotional price. It utilizes `ObjectApi.getProduct` for dynamic promotion data and `options` to control visibility of promotion details. ```twig {% from "@macros/product_price.twig" import product_price %} {% set product = ObjectApi.getProduct(product_id) %} {{ product_price({ priceValue: "$10.35", unitPrice: "$2.24", unitName: "pcs.", hasSpecialOffer: product.hasSpecialOffer, percentageDiscountValue: product.specialOffer.formatDiscount }, { showSpecialOfferDuration: true, showRegularPrice: true }) }} ``` -------------------------------- ### Get Sum of Discounts in Basket Source: https://storefront.developers.shoper.pl/js-api/apis/basket/apis/basket-promotions-api/methods/get-discounts-sum Call the getDiscountsSum method on the basketPromotionsApi to retrieve the total discount amount. This example assumes the basket has been initialized. ```javascript useStorefront(async ({ eventBus, getApi }) => { eventBus.on('basket.initialized', async () => { const basketPromotionsApi = await getApi('basketPromotionsApi'); const discountsSum = basketPromotionsApi.getDiscountsSum(); }); }); ``` -------------------------------- ### HTML Example of Responsiveness Classes Source: https://storefront.developers.shoper.pl/styling/components/responsiveness Demonstrates how to use `hidden-*` classes to control element visibility. Elements with these classes will be hidden on specific screen sizes. ```html
This element is visible on a higher resolution
This element is visible on a lower resolution
``` -------------------------------- ### Search for items with suggestions Source: https://storefront.developers.shoper.pl/js-api/apis/search-api/methods/search This example demonstrates how to use the `search` method to find items based on a suggestion and the original search phrase. It listens for keydown events on a search input to trigger the search. ```javascript useStorefront(async (storefront) => { const searchApi = await storefront.getApi('SearchApi'); const $searchElement = document.querySelector('input[type="search"]'); $searchElement.addEventListener('keydown', (ev) => { if (ev.key.length !== 1) return; const searchPhrase = ev.target.value; const suggestions = await searchApi.getSuggestions(searchPhrase); const searchResultsWithSuggestions = await searchApi.search(suggestions[0], searchPhrase); console.log('search results with suggestions', searchResultsWithSuggestions); }); }); ``` -------------------------------- ### Get Basket Shippings API Source: https://storefront.developers.shoper.pl/js-api/apis/basket/apis/basket-shippings-api/basket-shippings-api To get the `Basket Shippings API` use its name `basketShippingsApi` with the `getApi` method. This API is not automatically initialized. Unless you initialize it by hand or use a proper event like in the example above, you won't be able to fetch the API. ```APIDOC ## Get API To get the `Basket Shippings API` use its name `basketShippingsApi` with the `getApi` method. ```javascript useStorefront(async ({ eventBus, getApi }) => { eventBus.on('basket.initialized', async () => { const basketShippingsApi = await getApi('basketShippingsApi'); }); }); ``` This API is not automatically initialized. Unless you initialize it by hand or use a proper event like in the example above, you won't be able to fetch the API. Read more in the Retrieving basket APIs section ``` -------------------------------- ### Get Basket Payments API Source: https://storefront.developers.shoper.pl/js-api/apis/basket/apis/basket-payments-api/basket-payments-api To get the `Basket Payments API` use its name `basketPaymentsApi` with the `getApi` method. This API is not automatically initialized. Unless you initialize it by hand or use a proper event like in the example above, you won't be able to fetch the API. ```APIDOC ## Get API To get the `Basket Payments API` use its name `basketPaymentsApi` with the `getApi` method. ```javascript useStorefront(async ({ eventBus, getApi }) => { eventBus.on('basket.initialized', async () => { const basketPaymentsApi = await getApi('basketPaymentsApi'); }); }); ``` This API is not automatically initialized. Unless you initialize it by hand or use a proper event like in the example above, you won't be able to fetch the API. Read more in the Retrieving basket APIs section ```