### Initialize Setup State Source: https://github.com/webasyst/shop-script/blob/master/templates/actions/backend/BackendWelcome.html Determines if the setup is complete based on the welcome action status. ```Smarty {$_is_complete = false} {if $actions['welcome'].complete == 1}{$_is_complete = true}{/if} ``` -------------------------------- ### Include CSV Setup Template Source: https://github.com/webasyst/shop-script/blob/master/templates/actions/csv/CsvProductsetup.html Dynamically includes a setup template based on the current import or export direction. ```smarty {include file="./CsvProductsetup.{$direction|default:'import'}.html"} ``` -------------------------------- ### Install Shop-Script via GIT Source: https://github.com/webasyst/shop-script/blob/master/README.md Use these commands to clone the Shop-Script repository into the appropriate Webasyst application directory. ```bash cd /PATH_TO_WEBASYST/wa-apps/shop/ git clone git://github.com/webasyst/shop-script.git ./ ``` -------------------------------- ### Alternative Product List View Source: https://github.com/webasyst/shop-script/blob/master/themes/sidebar/category.html Commented out example for switching to a table-based product list view. ```Smarty {\* or use the line below to change product list view {include file='list-table.html' sorting=!empty($category.params.enable_sorting)} \*} ``` -------------------------------- ### Install Shop-Script via SVN Source: https://github.com/webasyst/shop-script/blob/master/README.md Use these commands to checkout the Shop-Script repository into the appropriate Webasyst application directory. ```bash cd /PATH_TO_WEBASYST/wa-apps/shop/ svn checkout http://svn.github.com/webasyst/shop-script.git ./ ``` -------------------------------- ### Initialize SEO Settings & Installer Source: https://github.com/webasyst/shop-script/blob/master/templates/actions/seo/Seo.html This JavaScript code initializes the page title, loads SEO plugins via an installer iframe, and sets up a button to add new storefronts. It uses jQuery for DOM manipulation and AJAX requests. ```javascript (function ($) { "use strict"; document.title = "Settings & SEO — {$wa->accountName(false)|escape:javascript}"; // installer iframe with seo plugins let themes_url = {$installer_url|json_encode}; if (themes_url) { $("#js-insaller-iframe-wrapper").load(themes_url); } // button to add new storefront opens dialog let $button = $("#js-add-storefront-button").click(function() { $button.attr('disabled', true); $.get('?module=seo&action=dialog', function(html) { $button.attr('disabled', false); $.waDialog({ html, onOpen($dialog, dialog) { const $form = dialog.$block.find('form'); const $dialog_submit = $form.find('.js-submit-button'); $form.submit(function(e) { e.preventDefault(); $dialog_submit.attr('disabled', true); $form.find('.state-error-hint').remove(); $form.find('.state-error').removeClass('state-error'); $.post('?module=seo&action=createStorefront', $form.serialize(), function(r) { if (r.status === 'ok') { dialog.close(); window.location = r.data.redirect; } else { $dialog_submit.attr('disabled', false); if (r.errors) { r.errors.forEach(e => { var $el = $dialog_submit; if (e.field) { let $field = $form.find('[name="'+e.field+'"]"]').addClass('state-error'); if ($field.length) { $el = $field; } } $el.parent().append($('
').text(e.error_description)); }); } } }); }); } }); }); }); }(jQuery)); ``` -------------------------------- ### shop.settings.onboard — Complete onboarding wizard step Source: https://context7.com/webasyst/shop-script/llms.txt Advances the onboarding process by marking a specific step as completed. This is typically used during the initial setup of the platform and is an admin-only function. ```APIDOC ## shop.settings.onboard ### Description Complete onboarding wizard step. ### Method POST ### Endpoint `/api.php/shop.settings.onboard?access_token=ADMIN_TOKEN&format=json` ### Parameters #### Request Body - **step** (string) - Required - The identifier of the onboarding step to complete (e.g., 'welcome'). ``` -------------------------------- ### Get Cart URL Source: https://github.com/webasyst/shop-script/blob/master/themes/clear/list-thumbs.html Retrieves the URL for the shopping cart. It first attempts to get a general cart URL and then checks if a specific checkout method exists to get a more precise URL. ```smarty {$_cart_url = $wa->getUrl('shop/frontend/cart')} {if method_exists($wa->shop, 'checkout')} {$_cart_url = $wa->shop->checkout()->cartUrl()} {/if} ``` -------------------------------- ### SKU Features Setup Link Source: https://github.com/webasyst/shop-script/blob/master/templates/actions/product/ProductSkuSettings.html Provides a link to set up feature types and features, emphasizing their importance for dynamic product filtering and default SKU selection. ```smarty {if count($features)>1} ##### [\`SKU features\`] [\`Defining feature values for SKUs is great for dynamic product filtering customer experience. When customer finds a product using by-feature filters, product’s default SKU will be selected according to the filter conditions.\`] [[\`Set up types & features\`]]({$wa_app_url}?action=settings#/typefeat/) {/if} ``` -------------------------------- ### Initialize Product JavaScript Source: https://github.com/webasyst/shop-script/blob/master/templates/actions/product/Product.html Sets up global variables and initializes product data, reviews, and image handling. ```JavaScript {$title_suffix = " — "|cat:{$wa->accountName(false)}|escape:'javascript'} var wa_url = '{$wa_url}'; var wa_app = 'shop'; var wa_lang = '{$lang}'; $(function() { $('#s-product-description-content').data('uploadFields', { '_csrf': {waRequest::cookie('_csrf', '')|json_encode} }); $.product.setData('main','stocks',{$stocks|json_encode}); $.product.setData('main','stock_ids', {array_keys($stocks)|json_encode}); $.product.setData('main', 'category_name', {$category_name|json_encode}); {if !empty($product.reviews)} $.product_reviews.init({ container: '#s-reviews-block', reply: 'ignore', statuses: { deleted: '{shopProductReviewsModel::STATUS_DELETED}', published:'{shopProductReviewsModel::STATUS_PUBLISHED}' } }); {/if} }); {if !empty($product.reviews)} $('#s-all-reviews').find('.count-new:first').text({if $sidebar_counters.reviews.new}'+{$sidebar_counters.reviews.new}'{else}''{/if}) {/if} {if $product.id > 0} $.product_images.init({ product_id: '{$product.id}', images: {json_encode(array_values($product.images))}, type: 'crop', enable_2x: {if $wa->shop->config('enable_2x')}true{else}false{/if}, image_list: '#s-product-view .s-product-image-crops' }); {/if} var sales_data = {if !empty($sales_data) && $report_rights}{json_encode($sales_data)}{else}[]{/if}; var cash_type = {wa_currency_html(0, $primary_currency)|replace:'0':'%s'|json_encode}; // "By SKU" pie graph var sku_plot_data = {if !empty($sku_plot_data) && $report_rights}{json_encode($sku_plot_data)}{else}[]{/if}; $.product.setOptions({ title_suffix: '{$title_suffix}', edit_rights: {if $edit_rights}true{else}false{/if}, sidebar_width: {if $sidebar_width}{$sidebar_width}{else}0{/if} }); {if $product.id > 0} document.title = '{$product.name|escape:'javascript'|cat:$title_suffix}'; {else} document.title = '[`New product`]{$title_suffix}'; {/if} (function(container) { $('a', container).click(function() { if (!$(this).closest('li').hasClass('gray')) { container.find('li.selected').removeClass('selected'); container.find('input[type="hidden"]').attr('disabled', true); $(this).closest('li').addClass('selected').find('input[type=hidden]').attr('disabled', false).trigger('change'); } return false; }); $('input', container).bind('disabled', function(e, disabled) { var item = $(this); if (disabled) { item.closest('li').removeClass('selected').addClass('gray'); item.siblings('a').addClass('s-disable-selling-mode'); item.attr('disabled', true); } else { item.closest('li').removeClass('gray'); item.siblings('a').removeClass('s-disabl ``` -------------------------------- ### Get Cart URL Source: https://github.com/webasyst/shop-script/blob/master/themes/clear/list-thumbs-mini.html Retrieves the URL for the shopping cart. It first attempts to get a general cart URL and then checks if a specific checkout method is available to get a more precise URL. ```Smarty {$_cart_url = $wa->getUrl('shop/frontend/cart')} {if method_exists($wa->shop, 'checkout')} {$_cart_url = $wa->shop->checkout()->cartUrl()} {/if} ``` -------------------------------- ### Initialize Products Module Source: https://github.com/webasyst/shop-script/blob/master/templates/actions/backend/BackendProducts.html Initialize the products interface with specific view settings and the application URL. ```javascript $(function() { $.products.init({ view: 'presentation', shop_url: '{$wa_app_url}', }); }); ``` -------------------------------- ### Initialize Product Component with JavaScript Source: https://github.com/webasyst/shop-script/blob/master/themes/nifty/product.cart.html Initializes the Product component with configuration options, including currency, compare price, services, and features. ```javascript $(function () { new Product('#cart-form{if $wa->get('cart')}-dialog{/if}', { currency: {json\_encode($currency\_info)}, compare\_price: {if !empty($product.compare\_price)}{shop\_currency($product.compare\_price, null, null, 0)}{else}0{/if} {if count($product.skus) > 1 or $product.sku\_type} ,services: {json\_encode($sku\_services)} {/if} {if $product.sku\_type} ,features: {json\_encode($sku\_features\_selectable)} {/if} }); }); ``` -------------------------------- ### Render Installer Review Widget Source: https://github.com/webasyst/shop-script/blob/master/templates/actions/reports/ReportsSales.html Conditionally renders the review widget if the installer app and required method exist. ```smarty {if $wa->installer && method_exists($wa->installer, 'reviewWidget')} {$wa->installer->reviewWidget('app/shop')} {/if} ``` -------------------------------- ### Create a new product using shop.product.add Source: https://context7.com/webasyst/shop-script/llms.txt Use this endpoint to create a new product. Requires 'name' and 'skus' unless 'sku_type' is set to 1. Access is checked against the product type. ```bash curl -X POST "https://example.com/api.php/shop.product.add?access_token=TOKEN&format=json" \ -d "name=Blue+T-Shirt" \ -d "type_id=1" \ -d "summary=Comfortable+cotton+tee" \ -d "description=

100%25+cotton

" \ -d "skus[0][price]=29.99" \ -d "skus[0][count]=50" \ -d "skus[0][sku]=TSHIRT-BLU-M" ``` -------------------------------- ### shop.order.getInfo Source: https://context7.com/webasyst/shop-script/llms.txt Get full order details. ```APIDOC ## shop.order.getInfo ### Description Retrieves the complete details for a specific order. ### Method GET ### Endpoint /api.php/shop.order.getInfo ### Parameters #### Query Parameters - **access_token** (string) - Required - API access token. - **id** (integer) - Required - The ID of the order to retrieve. - **format** (string) - Optional - Response format (e.g., json). ### Response #### Success Response (200) - **status** (string) - Indicates the status of the request ('ok' or 'error'). - **response** (object) - The full order details object, including items, contact, and parameters. - **id** (integer) - Unique identifier for the order. - **state_id** (string) - The current state of the order. - **total** (string) - The total amount of the order. - **currency** (string) - The currency of the order. - **paid_datetime** (string) - The date and time the order was paid. - **items** (array) - Array of items included in the order. - **params** (object) - Additional parameters associated with the order. - **contact** (object) - Information about the customer. ### Request Example ```bash curl "https://example.com/api.php/shop.order.getInfo?access_token=TOKEN&id=1001&format=json" ``` ### Response Example ```json { "status": "ok", "response": { "id": 1001, "state_id": "processing", "total": "49.98", "currency": "USD", "paid_datetime": "2024-06-01 11:00:00", "items": [...], "params": {...}, "contact": {...} } } ``` ``` -------------------------------- ### Initialize Product JavaScript Source: https://github.com/webasyst/shop-script/blob/master/themes/facebook/product.cart.html Loads the product JavaScript file and initializes the Product controller with configuration data. ```JavaScript ( function($) { $.getScript("{$wa_theme_url}product.js?v{$wa_theme_version}", function() { if (typeof Product === "function") { new Product('#cart-form{if $wa->get('cart')}-dialog{/if}', { currency: {json_encode($currency_info)}, compare_price: {if !empty($product.compare_price)}{shop_currency($product.compare_price, null, null, 0)}{else}0{/if} {if count($product.skus) > 1 or $product.sku_type} ,services: {json_encode($sku_services)} {/if} {if $product.sku_type} ,features: {json_encode($sku_features_selectable)} {/if} }); } }); })(jQuery); ``` -------------------------------- ### Initialize Product Video Source: https://github.com/webasyst/shop-script/blob/master/themes/vk/product.html Checks for product video availability and retrieves the URL and thumbnail data. ```Smarty {$_video = false} {$_video_url = false} {if $product->video} {$_video = $product->getVideo(['96x96'])} {if $_video.url} {$_video_url = $_video.url} {/if} {/if} ``` -------------------------------- ### shop.category.getParents Source: https://context7.com/webasyst/shop-script/llms.txt Get ancestor chain for a category. ```APIDOC ## shop.category.getParents ### Description Retrieves the ancestor chain (parent categories) for a given category. ### Method GET ### Endpoint /api.php/shop.category.getParents ### Parameters #### Query Parameters - **access_token** (string) - Required - API access token. - **id** (integer) - Required - The ID of the category for which to retrieve parents. - **format** (string) - Optional - Response format (e.g., json). ### Request Example ```bash curl "https://example.com/api.php/shop.category.getParents?access_token=TOKEN&id=3&format=json" ``` ``` -------------------------------- ### Initialize Product JavaScript Source: https://github.com/webasyst/shop-script/blob/master/themes/default2/product.cart.html Initializes the Product JavaScript controller with currency and SKU data. ```JavaScript $(function () { new Product('#cart-form{if $wa->get('cart')}-dialog{/if}', { currency: {json_encode($currency_info)} {if count($product.skus) > 1 or $product.sku_type} ,services: {json_encode($sku_services)} {/if} {if $product.sku_type} ,features: {json_encode($sku_features_selectable)} {/if} }); }); ``` -------------------------------- ### shop.category.getInfo Source: https://context7.com/webasyst/shop-script/llms.txt Get single category information. ```APIDOC ## shop.category.getInfo ### Description Retrieves detailed information for a single category. ### Method GET ### Endpoint /api.php/shop.category.getInfo ### Parameters #### Query Parameters - **access_token** (string) - Required - API access token. - **id** (integer) - Required - The ID of the category to retrieve. - **format** (string) - Optional - Response format (e.g., json). ### Request Example ```bash curl "https://example.com/api.php/shop.category.getInfo?access_token=TOKEN&id=3&format=json" ``` ``` -------------------------------- ### Initialize What to Sell Report Source: https://github.com/webasyst/shop-script/blob/master/templates/actions/reports/ReportsProductsWhatToSell.html Sets up the 'What to Sell' report by initializing the table with product data, handling user interactions like changing the number of products displayed or filtering sold items. It also sets up event listeners for input changes and sorting. ```javascript (function() { "use strict"; document.title = "[\`What to sell\'] — {" + "$wa->accountName(false)|escape:javascript" + "}"; var cur_tmpl_plain = {" + "$cur_tmpl_plain|json_encode" + "}; var format_thousands_separator = "{" + "ifset($locale_info.thousands_sep, ' ')" + "}"; {"literal"}var format_regexp = new RegExp('\\B(?=(\\d{3})+(?!\\d))', 'g');{"/literal"} var products = {" + "json_encode($products)" + "}; var request_options = {" + "json_encode($request_options)" + "}; var action_url = '?module=reportsproducts&action=whattosell'; var $table = $('#s-reports-what-to-sell-table'); var $period_selector = $('#future-period-selector'); var $thead = $table.children('thead'); var $limit_selector = $('#limit-selector'); $limit_selector.change(function() { $limit_selector.parent().after(''); var limit = $limit_selector.val(); $.storage.set('shop/reports/whattosell/limit', limit); $.post(action_url, $.extend({}, request_options, { limit: limit }), function(r) { $.reports.replaceContent(r); }); }); var $only_sold_selector = $('#only-sold-selector'); $only_sold_selector.change(function() { $only_sold_selector.parent().after(''); var val = $only_sold_selector.val(); $.storage.set('shop/reports/whattosell/only_sold', val); $.post(action_url, $.extend({}, request_options, { only_sold: val }), function(r) { $.reports.replaceContent(r); }); }); (function() { "use strict"; var $template_tr = $thead.children('tr.template'), trs = [], max_margin; $.each(products, function(i, p) { var $tr = $template_tr.clone().removeClass('hidden template').attr('data-id', p.id).data('product', p); if (p.image_id) { $tr.find('> .col-img a').attr('href', 'products/'+p.id+'/'); $tr.find('> .col-img img').attr('src', p.image_url); } else { $tr.find('> .col-img').empty(); } $tr.find('> .col-name a').attr('href', 'products/'+p.id+'/'); $tr.find('> .col-name .product-name').text(p.name); $tr.find('> .col-name .sku-names').text(p.sku_names); $tr.find('> .col-margin input').attr('placeholder', p.margin); $tr.find('> .col-margin .amount').html(p.margin); $tr.find('> .col-sold input').attr('placeholder', p.sold); $tr.find('> .col-sold input').attr('value', p.sold); $tr.find('> .col-to-ship .in-stock').html(formatNum(p.count)); trs.push($tr[0]); }); var period = $.storage.get('shop/reports/whattosell/period'); period && $period_selector.val(period); $table.children('tbody').empty().append(trs); updateTable(); })(); ( function() { "use strict"; var timeout = null; $table.on('change keyup', function() { timeout && clearTimeout(timeout); timeout = setTimeout(function() { timeout = null; updateTable(); }, 250); }); } )(); $period_selector.on('change', function() { $.storage.set('shop/reports/whattosell/period', $(this).val()); updateTable(); }); $thead.find(".s-product-reports").on("click", function(event) { event.stopPropagation(); }); $thead.on('click', 'a', function() { $thead.find('.fa-caret-down,.fa-caret-up').remove(); var $a = $(this); var $td = $a.closest('th,td'); $.reports.sortTable($td); $a.append(''); $.storage.set('shop/reports/whattosell/sort_col', $td.index()); }); ( function() { var sort_col = $.storage.get('shop/reports/whattosell/sort_col'); sort_col && $thead.find('>.s-header-row>*').eq(sort_col).find('a').click(); } )(); })(); ``` -------------------------------- ### Initialize Product JavaScript Module Source: https://github.com/webasyst/shop-script/blob/master/themes/clear/product.cart.html Loads the product-specific JavaScript file and initializes the Product module with configuration options like currency, compare price, and SKU-related data. ```javascript ( function($) { $.getScript("{$wa_theme_url}product.js?v{$wa_theme_version}", function() { if (typeof Product === "function") { new Product('#cart-form{if $wa->get('cart')}-dialog{/if}', { currency: {json_encode($currency_info)}, compare_price: {if !empty($product.compare_price)}{shop_currency($product.compare_price, null, null, 0)}{else}0{/if} {if count($product.skus) > 1 or $product.sku_type} ,services: {json_encode($sku_services)} {/if} {if $product.sku_type} ,features: {json_encode($sku_features_selectable)} {/if} }); } }); })(jQuery); ``` -------------------------------- ### Get Product Images Info, List, or Delete Source: https://context7.com/webasyst/shop-script/llms.txt Provides endpoints to list all images for a product, get details of a specific image, or delete an image. Requires product ID for list, image ID for info/delete. Delete uses POST. ```bash curl "https://example.com/api.php/shop.product.images.getList?access_token=TOKEN&product_id=42&format=json" ``` ```bash curl "https://example.com/api.php/shop.product.images.getInfo?access_token=TOKEN&id=7&format=json" ``` ```bash curl -X POST "https://example.com/api.php/shop.product.images.delete?access_token=TOKEN&format=json" -d "id=7" ``` -------------------------------- ### Complete onboarding wizard step with shop.settings.onboard Source: https://context7.com/webasyst/shop-script/llms.txt Advances the onboarding wizard to the next step. This is an admin-only operation and requires a POST request. ```bash curl -X POST "https://example.com/api.php/shop.settings.onboard?access_token=ADMIN_TOKEN&format=json" \ -d "step=welcome" ``` -------------------------------- ### shop.stock.getInfo Source: https://context7.com/webasyst/shop-script/llms.txt Get details of a specific warehouse by its ID. ```APIDOC ## GET shop.stock.getInfo ### Description Retrieves detailed information about a specific warehouse using its unique identifier. ### Method GET ### Endpoint `/api.php/shop.stock.getInfo` ### Parameters #### Query Parameters - **access_token** (string) - Required - API access token. - **id** (integer) - Required - The unique identifier of the warehouse. - **format** (string) - Optional - Response format. Example: `json`. ### Request Example ```bash curl "https://example.com/api.php/shop.stock.getInfo?access_token=TOKEN&id=1&format=json" ``` ``` -------------------------------- ### shop.feature.getInfo Source: https://context7.com/webasyst/shop-script/llms.txt Get details of a specific product feature by its ID. ```APIDOC ## GET shop.feature.getInfo ### Description Retrieves detailed information about a specific product feature using its unique identifier. ### Method GET ### Endpoint `/api.php/shop.feature.getInfo` ### Parameters #### Query Parameters - **access_token** (string) - Required - API access token. - **id** (integer) - Required - The unique identifier of the feature. - **format** (string) - Optional - Response format. Example: `json`. ### Request Example ```bash curl "https://example.com/api.php/shop.feature.getInfo?access_token=TOKEN&id=8&format=json" ``` ``` -------------------------------- ### shop.set.getInfo Source: https://context7.com/webasyst/shop-script/llms.txt Get details of a specific product set by its ID. ```APIDOC ## GET shop.set.getInfo ### Description Retrieves detailed information about a specific product set. ### Method GET ### Endpoint `/api.php/shop.set.getInfo` ### Parameters #### Query Parameters - **access_token** (string) - Required - API access token. - **id** (string) - Required - The identifier of the product set. - **format** (string) - Optional - Response format. Example: `json`. ### Request Example ```bash curl "https://example.com/api.php/shop.set.getInfo?access_token=TOKEN&id=bestsellers&format=json" ``` ``` -------------------------------- ### Initialize Product Tooltips Source: https://github.com/webasyst/shop-script/blob/master/templates/layouts/BackendProductsEditSection.html Initializes tooltips for product navigation and product name using JSON-encoded data. ```javascript ( function($) { var tooltips = {$_tooltips|json_encode}; $.each(tooltips, function(i, tooltip) { $.wa.new.Tooltip(tooltip); }); })(jQuery); ``` -------------------------------- ### Initialize Product View and Dialog Templates Source: https://github.com/webasyst/shop-script/blob/master/templates/actions/prod/ProdSku.html Sets up product view types, defines SKU properties, and captures various dialog templates using the Smarty capture function for later inclusion. ```smarty {strip} {$_settings_url = "{$wa_app_url}?action=settings#/typefeat/"} {if !empty($product["type_id"])} {$_settings_url = "{$_settings_url}{$product["type_id"]}/"} {/if} {$_sprite_url = "`$wa_url`wa-apps/shop/img/backend/products/product/icons.svg?v=`$wa->version()`"} {$_view_types = [ "thin" => [ "id" => "thin", "html" => "", "render_skus" => false, "expanded_sku" => false ], "half" => [ "id" => "half", "html" => "", "render_skus" => true, "expanded_sku" => false ], "full" => [ "id" => "full", "html" => "", "render_skus" => true, "expanded_sku" => true ] ]} {$_active_view_type_id = "full"} {$_active_view_type = $_view_types[$_active_view_type_id]} {$formatted_product["view_types"] = $_view_types} {$formatted_product["view_type_id"] = $_active_view_type["id"]} {foreach $formatted_product.skus as $_sku_index => $_sku} {$formatted_product.skus[$_sku_index]["expanded"] = $_active_view_type["expanded_sku"]} {$formatted_product.skus[$_sku_index]["render_skus"] = $_active_view_type["render_skus"]} {/foreach} {* ШАБЛОНЫ *} {$_templates = []} {capture assign="_feature_select_dialog"}{include file="./dialogs/feature_select.html" inline}{/capture} {$_templates["dialog_feature_select"] = $_feature_select_dialog} {capture assign="_sku_delete_dialog"}{include file="./dialogs/sku_delete_dialog.html" inline}{/capture} {$_templates["dialog_sku_delete"] = $_sku_delete_dialog} {capture assign="_sku_delete_photo"}{include file="./dialogs/sku_delete_photo.html" inline}{/capture} {$_templates["dialog_sku_delete_photo"] = $_sku_delete_photo} {capture assign="_photo_manager_dialog"}{include file="./ProdSkuImageDialog.html" inline}{/capture} {$_templates["dialog_photo_manager"] = $_photo_manager_dialog} {capture assign="_mass_sku_generation"}{include file="./dialogs/mass_sku_generation.html" inline}{/capture} {$_templates["dialog_mass_sku_generation"] = $_mass_sku_generation} {* Диалог показывающий какие значения характеристики используются в модификациях *} {capture assign="_feature_used_values"}{include file="./dialogs/feature_used_values.html" inline}{/capture} {$_templates["dialog_feature_used_values"] = $_feature_used_values} {capture assign="_minimal_mode_message"}{include file="./dialogs/minimal_mode_message.html" inline}{/capture} {$_templates["dialog_minimal_mode_message"] = $_minimal_mode_message} {capture assign="_locked_mode_message"}{include file="./dialogs/locked_mode_message.html" inline}{/capture} {$_templates["dialog_locked_mode_message"] = $_locked_mode_message} {* КОМПОНЕНТЫ *} {* Они могут добавляться внутри шаблонов через globals. Не удалять. *} {$_components = []} {capture assign="_component_fractional_section"}{include file="./components/component_fractional_section.html" inline}{/capture} {$_components["component-fractional-section"] = $_component_fractional_section|strip} {$_globals_components = $wa->globals("components")} {if !empty($_globals_components)} {$_components = array_merge($_components, $_globals_components)} {/if} {* LOCALE *} {$_locales = [ "file_type" => _w("Unsupported image type. Use PNG, GIF, WEBP and JPEG image files only."), "sku_required" => _w("An SKU code is required for grouping."), "stock_title" => _w("The quantity on this virtual stock is the sum of quantities on physical stocks — %s. You can change the list of stocks in “Settings” section."), "total_sku_mods" => _w("Total: %s."), "not_defined" => _w("Not defined"), "main_sku_visibility" => _w("The main SKU variant cannot be hidden. Either select another variant as main or enable visibility in the storefront for the main variant."), "sku_generation_sku_forms" => [ _w("%d SKU with %s each.", "%d SKUs with %s each.", 1, false), _w("%d SKU with %s each.", "%d SKUs with %s each.", 2, false), _w("%d SKU with %s each.", "%d SKUs with %s each.", 5, false) ], "sku_generation_sku_mod_forms" => [ _w("%d variant", "%d variants", 1, false), _w("%d variant", "%d variants", 2, false), _w("%d variant", "%d variants", 5, false) ], "features_hidden_on_front_forms" => [ _w("%d product variant is not displayed in the storefront because of an error.", "%d product variants are not displayed in the storefront because of an error.", 1, false), _w("%d product variant is not displayed in the storefront because of an error.", "%d product variants are not displayed in the storefront because of an error.", 2, false), _w("%d product variant is not displayed in the storefront because of an error.", "%d product variants are not displayed in the storefront because of an error.", 5, false) ], "value_invalid" => _w("Invalid value"), "value_required" => _w("This field is required.") ]} {$_globals_locales = $wa->globals("locales")} {if !empty($_globals_locales)} {$_locales = array ``` -------------------------------- ### shop.dashboard.salesTotal Source: https://context7.com/webasyst/shop-script/llms.txt Get aggregated sales totals for a specified time period. ```APIDOC ## GET shop.dashboard.salesTotal ### Description Retrieves aggregated sales totals for a specified time period. ### Method GET ### Endpoint `/api.php/shop.dashboard.salesTotal` ### Parameters #### Query Parameters - **access_token** (string) - Required - API access token. - **period** (integer) - Optional - Time period in seconds. Example: `2592000` (30 days). - **format** (string) - Optional - Response format. Example: `json`. ### Request Example ```bash curl "https://example.com/api.php/shop.dashboard.salesTotal?access_token=TOKEN&period=2592000&format=json" ``` ``` -------------------------------- ### shop.dashboard.customers Source: https://context7.com/webasyst/shop-script/llms.txt Get customer acquisition statistics for a specified time period. ```APIDOC ## GET shop.dashboard.customers ### Description Retrieves customer acquisition statistics for a given time period. ### Method GET ### Endpoint `/api.php/shop.dashboard.customers` ### Parameters #### Query Parameters - **access_token** (string) - Required - API access token. - **period** (integer) - Optional - Time period in seconds. Example: `2592000` (30 days). - **format** (string) - Optional - Response format. Example: `json`. ### Request Example ```bash curl "https://example.com/api.php/shop.dashboard.customers?access_token=TOKEN&period=2592000&format=json" ``` ``` -------------------------------- ### Initialize Product Images with Options Source: https://github.com/webasyst/shop-script/blob/master/templates/actions/product/ProductImages.html Initializes the product image manager with product ID, placeholder, image data, and configuration for 2x image support. Includes a handler for drag-and-drop sorting. ```javascript $.product_images.init({ product_id: '{$product_id}', placeholder: '{$placeholder}', images: {json_encode(array_values($images))}, count: {count($images)}, enable_2x: {if $wa->shop->config('enable_2x')}true{else}false{/if}, // handler triggered after drag-n-drop sort onSort: function(id, before_id) { // update product profile image list var product_view_images_list = $('#s-product-view .s-product-image-crops'); var item = product_view_images_list.find('li[data-image-id=' + id + ']'); if (before_id) { product_view_images_list.find('li[data-image-id=' + before_id + ']').before(item); } else { product_view_images_list.append(item); } // update images for sku settings blocks var sku_settings_blocks = $('#shop-productprofile .js-sku-settings'); sku_settings_blocks.each(function() { var self = $(this); var sku_id = self.attr('data-id'); var image_crops = self.find('.s-product-image-crops'); var item = image_crops.find('li[data-image-id=' + id + ']'); if (before_id) { image_crops.find('li[data-image-id=' + before_id + ']').before(item); } else { image_crops.append(item); } }); } }); ``` -------------------------------- ### Get Coupon Details Source: https://context7.com/webasyst/shop-script/llms.txt Retrieves details for a specific coupon using its ID. ```bash curl "https://example.com/api.php/shop.coupon.getInfo?access_token=TOKEN&id=5&format=json" ``` -------------------------------- ### Initialize Promo Dialog Source: https://github.com/webasyst/shop-script/blob/master/templates/actions/prod/main/dialogs/products.associate_promo.html Configures the product association dialog with a specific redirect pattern. ```JavaScript ( function($) { var $dialog = $("#js-products-associate-promo-dialog").removeAttr("id"), dialog = $dialog.data("dialog"); dialog.options.ready.done( function() { dialog.options.initDialog($dialog, dialog, { "redirect_pattern": "{$wa_app_url}marketing/promo/%id%/?options[action]=associate&options[products_hash]={$products_hash|escape}" }); }); })(jQuery); ``` -------------------------------- ### shop.type.getInfo Source: https://context7.com/webasyst/shop-script/llms.txt Get details of a specific product type, including its associated features. ```APIDOC ## GET shop.type.getInfo ### Description Retrieves detailed information about a specific product type, including the features associated with it. ### Method GET ### Endpoint `/api.php/shop.type.getInfo` ### Parameters #### Query Parameters - **access_token** (string) - Required - API access token. - **id** (integer) - Required - The unique identifier of the product type. - **format** (string) - Optional - Response format. Example: `json`. ### Request Example ```bash curl "https://example.com/api.php/shop.type.getInfo?access_token=TOKEN&id=1&format=json" ``` ``` -------------------------------- ### Load Product Page Assets and Initialize Source: https://github.com/webasyst/shop-script/blob/master/templates/layouts/BackendProductsEditSection.html Loads required JavaScript sources and initializes the product page interface with context and configuration. ```javascript ( function($) { var sources = [{ id: "wa-shop-products-main-sidebar-js", type: "js", uri: "{$wa_app_static_url}js/backend/products/main/sidebar.js?v={$wa->version()}" },{ id: "wa-shop-products-product-sidebar-js", type: "js", uri: "{$wa_app_static_url}js/backend/products/product/sidebar.js?v={$wa->version()}" },{ id: "wa-shop-products-product-js", type: "js", uri: "{$wa_app_static_url}js/backend/products/product/product.js?v={$wa->version()}" }]; $.wa.loadSources(sources).done( function() { $.wa_shop_products.init.initProductPage({ $wrapper: $("#js-product-page"), context: {$context|json_encode}, product_uri: "{$wa_app_url|escape}products/{$product.id|escape}/", product_id: "{$product.id|escape}", templates: {$_templates|json_encode}, urls: { "product_delete": "{$wa_app_url}?module=products&action=deleteList", "product_delete_dialog": "{$wa_app_url}?module=prod&action=productDeleteDialog" }, sidebar_toggle_class: "visible-mobile-sidebar" }); }); $.wa.title.set({$product.name|default:_w('New product')|json_encode}); $('.s-button-back').on('click', function (event) { event.preventDefault(); history.back(); }); })(jQuery); ``` -------------------------------- ### Initialize Product Block Variables Source: https://github.com/webasyst/shop-script/blob/master/lib/classes/blockpage/templates/ProductSaleWidget.html Sets up initial block identifiers and CSS classes for the product sale block. ```smarty {$block_id = $data->getId()} {$static_main = "site-block-product-sale rw f-w"} {$anchor_id = $data->data['id']|default:0} ``` -------------------------------- ### shop.product.sales Source: https://context7.com/webasyst/shop-script/llms.txt Get sales statistics for a specific product within a given period. ```APIDOC ## shop.product.sales — Get sales statistics for a product ### Description Retrieves sales statistics for a given product. ### Method GET ### Endpoint /api.php/shop.product.sales ### Parameters #### Query Parameters - **access_token** (string) - Required - API access token. - **id** (integer) - Required - The ID of the product. - **period** (integer) - Required - The time period in seconds for which to retrieve sales statistics. - **format** (string) - Optional - The desired response format (e.g., json). ``` -------------------------------- ### Render Regional Settings Source: https://github.com/webasyst/shop-script/blob/master/templates/actions/backend/BackendWelcome.html Iterates through available countries and currencies for the initial store setup. ```Smarty {foreach $countries as $country} {$country.name|escape} {/foreach} {foreach $currencies as $currency} {$currency.code} — {_w($currency.title)} {/foreach} ``` -------------------------------- ### Display Plugin Logo Source: https://github.com/webasyst/shop-script/blob/master/templates/actions/settings/SettingsShipping.html Conditionally renders the plugin logo or image if the plugin is installed. ```smarty {if empty($plugin.installed)} {else} {if !empty($plugin.logo)} ![]({$plugin.logo}) {elseif !empty($plugin.img)} ![]({$plugin.img}) {/if} {/if} ``` -------------------------------- ### Initialize Product List and UI Source: https://github.com/webasyst/shop-script/blob/master/templates/actions/products/Products.html Sets the document title, localizes strings, and initializes the product list component with collection parameters and UI settings. ```javascript {$title = $title|cat:" — ":{$wa->accountName(false)}} document.title = '{$title|escape:'javascript'}'; $.wa.locale = $.extend($.wa.locale || {}, { 'Inline editing is available only for products with a single SKU': "[`Inline editing is available only for products with a single SKU`]", 'Insufficient access rights': "[`Insufficient access rights`]" }); $.product_list.init({ marketing_url: {"`$wa_app_url`marketing/"|json_encode}, view: '{$view}', collection_hash: {json_encode($collection_hash)}, collection_param: '{$collection_param}', sort: '{$sort}', order: '{$order}', products: {json_encode($products)}, total_count: {$total_count}, category_count: {if $info && $info['hash'] == 'category' && $info['type'] == shopCategoryModel::TYPE_STATIC && !$info['include_sub_categories']}{$info['count']}{else}null{/if}, edit: '{$wa->get("edit")}', sortable: {if $manual && $sort == 'sort'}true{else}false{/if}, enable_2x: {if $wa->shop->config('enable_2x')}true{else}false{/if}, text: {$text|default:''|json_encode}, primary_currency: {$primary_currency|json_encode}, {* use_product_currency: {if $use_product_currency}true{else}false{/if}, currencies: {$currencies|json_encode}, *} stocks: {$stocks|json_encode}, {if $lazy_loading} lazy_loading: { auto: true, count: {$count} } {else} page: {$page} {/if} }); $(".js-dropdown-menu").waDropdown({ hover: false }); ``` -------------------------------- ### Invoke stock editor form Source: https://github.com/webasyst/shop-script/blob/master/templates/actions/settings/SettingsStock.html Examples of calling the stock_editor_form function with different parameters. ```smarty {stock_editor_form stock=$stock substocks=ifset($stock.substocks)} ``` ```smarty {stock_editor_form} ``` ```smarty {stock_editor_form substocks=[]} ``` -------------------------------- ### Initialize Shipping Configuration and State Source: https://github.com/webasyst/shop-script/blob/master/templates/actions/frontend/order/form/region.html Sets up initial variables for shipping configuration, error handling, and location selection logic. ```smarty {strip} {$_config = $config.shipping} {$_system_address_field_names = $config->getSystemAddressFieldNames()} {$_errors = []} {if !empty($error_step_id) && $error_step_id === "region"}{$_errors = $errors}{/if} {$_countries = []} {if !empty($region.countries)}{$_countries = $region.countries}{/if} {$_active_location = null} {$_active_county = null} {$_active_region = null} {if isset($region.selected_values.location_id)} {foreach $region.locations as $_location} {if $_location.id == $region.selected_values.location_id} {$_active_location = $_location} {/if} {/foreach} {if empty($_active_location)} {$_active_location = reset($region.locations)} {/if} {/if} {$_is_default_mode = true} {$_is_minimal_mode = false} {if $config.shipping.mode == shopCheckoutConfig::SHIPPING_MODE_TYPE_MINIMUM} {$_is_default_mode = false} {$_is_minimal_mode = true} {/if} {$_is_country_required = true} {$_is_region_required = true} {$_is_city_required = true} {$_is_zip_required = true} ``` -------------------------------- ### Get Warehouse Details - shop.stock.getInfo Source: https://context7.com/webasyst/shop-script/llms.txt Fetches detailed information about a specific warehouse, identified by its ID. ```bash curl "https://example.com/api.php/shop.stock.getInfo?access_token=TOKEN&id=1&format=json" ``` -------------------------------- ### Initialize Product View Script Source: https://github.com/webasyst/shop-script/blob/master/themes/default/product.cart.html Loads the product JavaScript file and initializes the Product class. Configures options for product display, image handling, pricing, and SKUs. ```javascript ( function($) { $.getScript("{$wa_theme_url}product.js?v{$wa_theme_version}", function() { if (typeof Product === "function") { new Product('#cart-form{if $wa->get('cart')}-dialog{/if}', { product_topbar: $('.js-product-topbar'), is_dialog: {$_is_dialog|json_encode}, images: {if !empty($_is_dialog)}{$_images|json_encode}{else}[]{/if}, compare_price: {if !empty($product.compare_price)}{shop_currency($product.compare_price, null, null, 0)}{else}0{/if}, currency: {json_encode($currency_info)}, skus: {$product.skus|json_encode} {if count($product.skus) > 1 or $product.sku_type} ,services: {json_encode($sku_services)} {/if} {if $product.sku_type} ,features: {json_encode($sku_features_selectable)} {/if} }); } }); })(jQuery); ``` -------------------------------- ### Get Full Order Details Source: https://context7.com/webasyst/shop-script/llms.txt Retrieves comprehensive details for a specific order using its ID. ```bash curl "https://example.com/api.php/shop.order.getInfo?access_token=TOKEN&id=1001&format=json" # Response: # { # "status": "ok", # "response": { # "id": 1001, "state_id": "processing", "total": "49.98", "currency": "USD", # "paid_datetime": "2024-06-01 11:00:00", # "items": [...], "params": {...}, "contact": {...} # } # } ``` -------------------------------- ### Get Ancestor Chain for a Category Source: https://context7.com/webasyst/shop-script/llms.txt Retrieves the parent category chain for a given category ID. ```bash curl "https://example.com/api.php/shop.category.getParents?access_token=TOKEN&id=3&format=json" ``` -------------------------------- ### Get Single Category Info Source: https://context7.com/webasyst/shop-script/llms.txt Retrieves detailed information for a specific category using its ID. ```bash curl "https://example.com/api.php/shop.category.getInfo?access_token=TOKEN&id=3&format=json" ``` -------------------------------- ### Initialize Product SEO JavaScript Source: https://github.com/webasyst/shop-script/blob/master/templates/actions/prod/ProdSeo.html Loads required JavaScript dependencies and initializes the product SEO section using the Webasyst framework. ```javascript ( function($) { var sources = [{ id: "vue-js", type: "js", uri: "{$wa_app_static_url}js/backend/vue/{if $wa->debug()}vue.global.js{else}vue.global.prod.js{/if}?v={$wa->version()}" }, { id: "wa-shop-products-product-seo-js", type: "js", uri: "{$wa_app_static_url}js/backend/products/product/product.seo.js?v={$wa->version()}" }]; $.wa.loadSources(sources).then(init); function init() { $.wa_shop_products.init.initProductSeoSection({ $wrapper: $("#js-product-seo-section-wrapper"), components: {$_components|json_encode}, templates: {$_templates|json_encode}, tooltips: {$_tooltips|json_encode}, locales: {$_locales|json_encode}, urls: { "save": "{$wa_app_url}?module=prod&action=saveSeo", "add_product_image": "{$wa_app_url}?module=prod&action=imageUpload", "change_image_description": "{$wa_app_url}?module=prod&action=saveImageDetails" }, product: {$formatted_product|json_encode}, social: {$social|json_encode} }); $(document).trigger("wa_product_section_change", "product-seo"); } })(jQuery); ```