### Product Image Gallery Initialization Source: https://github.com/webasyst/dummy-theme-shop/blob/master/dummy/product.html Initializes the swipebox image gallery plugin for product images. This script is loaded asynchronously and then initializes the ProductPhotos functionality. ```javascript ( function($) { $.getScript("{$wa_active_theme_url}plugins/swipebox/js/jquery.swipebox.min.js?v{$wa_theme_version}", function() { new ProductPhotos(); }); })(jQuery); ``` -------------------------------- ### Webasyst Frontend Shipping API Source: https://github.com/webasyst/dummy-theme-shop/blob/master/dummy/checkout.shipping.html This section documents the Webasyst frontend shipping API endpoint used for retrieving and updating shipping method details. It supports both POST requests with form data for address changes and GET requests for fetching external shipping method rates. The API returns shipping options, rates, and error messages in JSON format. ```APIDOC Endpoint: /frontend/shipping Description: Handles shipping method calculations and updates based on customer address and selected options. Methods: 1. POST /frontend/shipping - **Purpose**: Updates shipping options and rates based on submitted form data (e.g., address changes). - **Request Body**: Serialized form data containing customer and order details. - **Parameters**: Includes customer address fields (e.g., `customer_X_name`, `customer_X_city`, etc.) and selected shipping IDs (`shipping_id`). - **Response**: JSON object containing updated shipping data. - `data`: An object where keys are shipping method IDs and values are either: - An array of rate objects if multiple rates are available for a method: - `id`: Rate identifier. - `name`: Display name of the rate. - `rate`: Formatted shipping cost. - `comment`: Optional comment for the rate. - `est_delivery`: Estimated delivery time. - A string message if an error occurred for that shipping method. - A single rate object if only one rate is available. - Example Response Structure (Multiple Rates): ```json { "data": { "shipping_method_id_1": [ { "id": "rate_1_id", "name": "Standard Shipping", "rate": "$5.00", "comment": "Delivers in 3-5 business days", "est_delivery": "3-5 business days" }, { "id": "rate_2_id", "name": "Express Shipping", "rate": "$15.00", "comment": "Delivers in 1-2 business days", "est_delivery": "1-2 business days" } ] } } ``` - Example Response Structure (Single Rate): ```json { "data": { "shipping_method_id_2": [ { "id": "rate_3_id", "name": "Local Pickup", "rate": "$0.00", "est_delivery": "Same day" } ] } } ``` - Example Response Structure (Error): ```json { "data": { "shipping_method_id_3": "Error: Cannot ship to this destination." } } ``` 2. GET /frontend/shipping - **Purpose**: Fetches rates for specified external shipping methods. - **Query Parameters**: - `shipping_id`: An array of shipping method IDs for which to fetch rates. - **Response**: JSON object containing shipping data for the requested IDs. - `data`: An object where keys are shipping method IDs and values are rate data (similar to POST response). - Example Request: ``` GET /frontend/shipping?shipping_id[]=1&shipping_id[]=5 ``` - Example Response: ```json { "data": { "1": [ { "id": "rate_a_id", "name": "International Standard", "rate": "$25.00" } ], "5": "Error: Service unavailable." } } ``` Related Functions: - `responseCallback(shipping_id, data)`: JavaScript function that processes the API responses and updates the UI accordingly. ``` -------------------------------- ### Product Initialization Script Source: https://github.com/webasyst/dummy-theme-shop/blob/master/dummy/product.cart.html Initializes the product JavaScript component using jQuery. It loads a specific script and passes product configuration options like dialog status, currency, services, and features. ```javascript ( function($) { $.getScript("{$wa_theme_url}js/product.js?v{$wa_theme_version}", function() { var $form = $("#s-product-form"), options = { is_dialog: {if $\_is_dialog}true{else}false{/if}, currency: {json_encode($currency_info)}, services: {if count($product.skus) > 1 or $product.sku_type}{json_encode($sku_services)}{else}false{/if}, features: {if $product.sku_type}{json_encode($sku_features_selectable)}{else}false{/if} }; new Product($form, options); }); })(jQuery); {/strip} ``` -------------------------------- ### JavaScript: Initialize Product Features and Lazy Loading Source: https://github.com/webasyst/dummy-theme-shop/blob/master/dummy/products.html Initializes the product display component using jQuery and the `waShop` library. It sets up comparison functionality and conditionally enables lazy loading for pagination based on theme settings. ```javascript ( function($) { var $products = $("#s-products-{$_uniq_ident}"); waShop.products = new Products({ $wrapper: $products, compare: { url: "{$wa->getUrl("/frontend/compare")}", title: "[`Compare selected products`]" } }); var initLazyLoading = {if isset($pages_count) && $pages_count > 1 && $theme_settings.pagination == "lazyloading"}true{else}false{/if}; if (initLazyLoading) { waShop.lazyLoading = new LazyLoading({ $wrapper: $products, names: { list: ".s-products-list", items: ".s-product-wrapper", paging: ".s-paging-wrapper" } }); } $products.removeAttr("id"); })(jQuery); ``` -------------------------------- ### Checkout JavaScript Initialization Source: https://github.com/webasyst/dummy-theme-shop/blob/master/dummy/checkout.html This snippet demonstrates how to load the checkout JavaScript file and initialize the Checkout class using jQuery. It ensures the script is loaded asynchronously and the Checkout object is instantiated with the correct DOM element. ```javascript ( function($) { $.getScript("{$wa_theme_url}js/checkout.js", function() { new Checkout({ $wrapper: $(".s-checkout-page") }); }); })(jQuery); ``` -------------------------------- ### SKU Listing for Schema.org Source: https://github.com/webasyst/dummy-theme-shop/blob/master/dummy/product.cart.html Iterates through product SKUs to prepare data for Schema.org markup. It checks SKU availability and stock counts, marking them as available or out of stock. ```smarty {* list all SKUs for Schema.org markup *} {foreach $product.skus as $sku} {$sku_available = $product.status && $sku.available && ($wa->shop->settings('ignore_stock_count') || $sku.count === null || $sku.count > 0)} {if $sku.name}{/if} {if (!($sku.count === null) && $sku.count <= 0)} {else} {/if} {/foreach} ``` -------------------------------- ### Display Product Reviews and User Interaction Logic Source: https://github.com/webasyst/dummy-theme-shop/blob/master/dummy/reviews.html This snippet outlines the core logic for displaying product reviews, including conditional rendering based on user authentication status and review availability. It handles user login/signup prompts, displays user information, and iterates through reviews, including nested comments. ```smarty {$wa->title(sprintf('[`%s reviews`]', $product.name))} {$current_user_id = $wa->userId()} {function review_reviews} {$depth=-1} {foreach $reviews as $review} {if $review.depth < $depth} {$loop=($depth-$review.depth)} {section name="end-review" loop=$loop} {/section} {$depth=$review.depth} {/if} {if $review.depth == $depth} {/if} {if $review.depth > $depth} {$depth=$review.depth} {/if} {include file="review.html" inline reply_allowed=$reply_allowed single_view=true review=$review} {/foreach} {section name="end-review" loop=$depth} {/section} {/function} {sprintf('[`%s reviews`]', $product.name|escape)} ===================================================== {if empty($current_user_id) && $require_authorization} {sprintf( '[`To add a review please [sign up](%s) or [login](%s)`]', $wa->signupUrl(), $wa->loginUrl()) } {else} {if !empty($current_user_id)} **![]({$wa->user()->getPhoto(20)}){$wa->user('name')}** [(`log out`)](?logout) {else} {if $auth_adapters} * [`Guest`](#) {foreach $auth_adapters as $adapter} {$adapter_id = $adapter->getId()} * [![]({$adapter->getIcon()}){$adapter->getName()}]({$adapter->getCallbackUrl(0)}&app=shop{if !$require_authorization}&guest=1{/if}) {/foreach} {/if} {if !empty($auth_adapters[$current_auth_source])} {$adapter = $auth_adapters[$current_auth_source]} [`Your name`] **![]({$adapter->getIcon()}){$current_auth.name|escape}** [(`log out`)](?logout) {/if} {/if} #### [`Rate product`] {for $i = 1 to 5} {/for} {if $request_captcha && empty($current_user_id)} {$wa->captcha()} {/if} [`cancel`](javascript:void(0);) {/if} {if count($reviews) > 0} ### {_w('%d review for ','%d reviews for ', $reviews_count)|cat:$product.name|escape} {foreach $reviews as $review} {include file="review.html" reply_allowed=$reply_allowed inline} {if !empty($review.comments)} {review_reviews reviews=$review.comments} {else} {/if} {/foreach} {else} [`Be the first to write a review of this product!`] {/if} ``` -------------------------------- ### Service Display Source: https://github.com/webasyst/dummy-theme-shop/blob/master/dummy/product.cart.html Renders additional product services, including their names and prices. It handles services with and without variants, displaying prices accordingly. ```smarty {if $services} {* services *} {foreach $services as $s} {$s.name|escape} {if $s.price && !isset($s.variants)}(+{shop_currency_html($s.price, $s.currency)}){/if} {if isset($s.variants)} {foreach $s.variants as $v} {$v.name|escape} (+{shop_currency($v.price, $s.currency)}) {/foreach} {else} {/if} {/foreach} {/if} ``` -------------------------------- ### Render Pages List Recursively Source: https://github.com/webasyst/dummy-theme-shop/blob/master/dummy/sidebar.html Defines and uses a recursive function `renderNavItem` to display a hierarchical list of pages. It highlights the currently selected page. ```Webasyst {\* Display pages list *} {function renderNavItem page=[]} {$\_is_selected = ( strlen($page.url) > 1 && $wa->currentUrl()|strstr:$page.url )} * [{$page.name}]({$page.url}) {if !empty($page.childs)} {foreach $page.childs as $subpage} {renderNavItem page=$subpage} {/foreach}{/if} {/function} {$\_pages = $wa->shop->pages()} {if !empty($\_pages)} {foreach $\_pages as $page} {renderNavItem page=$page} {/foreach} {/if} ``` -------------------------------- ### Checkout Page Template Logic Source: https://github.com/webasyst/dummy-theme-shop/blob/master/dummy/checkout.html This template logic handles the dynamic rendering of the checkout page. It manages the display of checkout steps, determining their status (done, next, current) and generating appropriate links. It also displays the order total and includes conditional logic for authentication and step-specific content. ```template {strip} {$\_is_success = ( $checkout_current_step == "success" )} {if !$\_is_success} [\`Checkout\`] ---------------- {/if} {if isset($checkout_steps)} {foreach $checkout_steps as $step_id => $s} {$_item_class = "is-done"} {$_link_href = "{$wa->getUrl('/frontend/checkout')}{$step_id}"} {if !empty($\_after_current)} {$_item_class = "is-next"} {$_link_href = "javascript:void(0);"} {/if} {if $step_id == $checkout_current_step} {$\_after_current = true} {$_item_class = "is-current"} {$_link_href = "javascript:void(0);"} {/if}* [{$s.name}]({$_link_href}) {/foreach} {/if} {$_cart_total = $wa->shop->cart->total()} {if $_cart_total > 0} [\`Order total\`]: {shop_currency_html($_cart_total, true)} {/if} {if isset($checkout_steps)} {$_steps_count = count($checkout_steps)} {$_current_step_index = array_search($checkout_current_step, array_keys($checkout_steps))} {$_is_first = ( $_current_step_index == 0 )} {$_is_last = ( $_current_step_index == ($_steps_count - 1) )} {/if} {if !empty($\_is_first) && $wa->isAuthEnabled()} {include file="checkout.auth.html" inline} {/if} {include file="checkout.\`$checkout_current_step\`.html"} {if !$\_is_success} {/if} ``` -------------------------------- ### Display Promotional Cards and Products Source: https://github.com/webasyst/dummy-theme-shop/blob/master/dummy/home.html This snippet demonstrates how to fetch and display promotional cards and product sets on the shop's homepage. It includes logic to hide the sidebar, iterate through promotional items, and conditionally include a product list template. ```smarty {$wa->globals("hideSidebar", true)} {* SLIDER *} {include file="home.slider.html" inline} {* PROMOCARDS *} {$promocards = $wa->shop->promos()} {if !empty($promocards)} {foreach $promocards as $promo} [{if !empty($promo.title)} ##### {$promo.title|escape} {/if} {if !empty($promo.body)} {$promo.body|escape} {/if}]({$promo.link|escape}) {/foreach} {/if} {* @event frontend_homepage.%plugin_id% *} {foreach $frontend_homepage as $_}{$_}{/foreach} {* PROMOS PRODUCT LIST *} {$_promos = $wa->shop->productSet('promo')} {if !empty($_promos)} {include file="./products.html" products=$_promos} {/if} ``` -------------------------------- ### User Authentication and Profile Links Source: https://github.com/webasyst/dummy-theme-shop/blob/master/dummy/header.html Manages user authentication status and displays relevant links. It checks if authentication is enabled, conditionally applies a background style based on user photo, and shows 'My profile' or 'Login' links along with a 'Personal area' link. ```Templating {if $wa->isAuthEnabled()} user()->isAuth()}style="background-image: url('{$wa->user()->getPhoto2x(20)}');"{/if}> {if $wa->user()->isAuth()}[\`My profile\`]{else}[\`Login\`]{/if} [\`Personal area\`] []({$wa->getUrl('/frontend/myProfile')}) {/if} ``` -------------------------------- ### Frontend Footer Template Logic Source: https://github.com/webasyst/dummy-theme-shop/blob/master/dummy/footer.html This snippet demonstrates the core logic for the frontend footer in a Webasyst theme. It includes event handling for frontend hooks, dynamic rendering of footer content, copyright year and account name display, a link to the shop's provider, and conditional currency display based on the number of available currencies. It utilizes Smarty templating syntax. ```smarty {strip} {* @event frontend_footer.%plugin_id% *} {foreach $frontend_footer as $_}{$_}{/foreach} © {time()|wa_datetime:"Y"} [{$wa->accountName()}]({$wa_url}) [`[Ecommerce software](http://www.shop-script.com/) by Webasyst`] {if count($currencies) > 1} {$currency = $wa->shop->currency()} {foreach $currencies as $c_code => $c} {$c.title} {/foreach} {/if} {/strip} ``` -------------------------------- ### Product Display Logic Source: https://github.com/webasyst/dummy-theme-shop/blob/master/dummy/product.cart.html Handles the display of product name, image, and summary. It conditionally shows the product image if the display is a dialog and truncates the summary text. ```smarty {strip} {$\_is_dialog = $wa->get('cart')} #### {sprintf('[`Buy %s`]', $product.name|escape)} {if $\_is_dialog} {$\_is_dialog = $wa->get('cart')} {$wa->shop->productImgHtml($product, '96x96', [ 'itemprop' => 'image', 'id' => 'product-image', 'alt' => $product.name|escape ])} {/if} {if $product.summary} {$product.summary|truncate:512} {/if} ``` -------------------------------- ### Shopping Cart Summary Source: https://github.com/webasyst/dummy-theme-shop/blob/master/dummy/header.html Displays a summary of the shopping cart, including the total price and item count. It fetches cart details using `$wa->shop->cart->total()` and `$wa->shop->cart->count()`. The price is formatted using `wa_currency_html`, defaulting to 'Empty' if no items are in the cart. ```Templating {if $wa->shop} {$\_cart_total = $wa->shop->cart->total()} {$\_cart_count = $wa->shop->cart->count()} {$\_price_text = "[\`Empty\`]"} {if !empty($\_cart_total)} {$\_price_text = wa_currency_html($\_cart_total, $wa->shop->currency())} {/if} 0 [\`Compare\`] []({$wa->getUrl('shop/frontend/compare')}) {if !empty($\_cart_count)}{$\_cart_count}{/if} [\`Cart\`] {$\_price_text} []({$wa->getUrl('shop/frontend/cart')}) {/if} ``` -------------------------------- ### Webasyst Template Sorting Logic Source: https://github.com/webasyst/dummy-theme-shop/blob/master/dummy/products.sorting.html This snippet demonstrates the Webasyst template engine logic for defining and applying product sorting. It initializes sortable fields, determines the active sort order, and generates dynamic links for sorting options. ```webasyst {strip} {$sort_fields = [ 'name' => '[`Name`]', 'price' => '[`Price`]', 'total_sales' => '[`Bestsellers`]', 'rating' => '[`Customer rating`]', 'create_datetime' => '[`Date added`]', 'stock' => '[`In stock`]' ]} {if !isset($active_sort)} {$active_sort = $wa->get('sort', 'create_datetime')} {/if} [`Sorting`]: {$sort_fields[$active_sort]} {if !empty($category) && !$category.sort_products} * [[`New & Popular`]]({$wa->currentUrl(0, 1)}) {/if} {foreach $sort_fields as $sort => $name} * {$wa->shop->sortUrl($sort, $name, $active_sort)} {if $wa->get('sort') == $sort} {$wa->title( $wa->title()|cat:' — '|cat:$name)} {/if} {/foreach} {/strip} ``` -------------------------------- ### Product Display Logic Source: https://github.com/webasyst/dummy-theme-shop/blob/master/dummy/search.html Handles the display of products based on availability. If no products are found, it displays a 'No products were found.' message. Otherwise, it includes the './products.html' template. ```Webasyst Template {$title} ======== {* @event frontend_search.%plugin_id% *} {foreach $frontend_search as $_}{$_}{/foreach} {if !$products} [`No products were found.`] {else} {include file="./products.html" inline} {/if} {/strip} ``` -------------------------------- ### Price Display Source: https://github.com/webasyst/dummy-theme-shop/blob/master/dummy/product.cart.html Displays the product's current price and optionally a comparison price (strike-through price). Uses shop currency formatting. ```smarty {* price *} {if $product.compare_price > 0} {shop_currency_html($product.compare_price)} {/if} {shop_currency_html($product.price)} ``` -------------------------------- ### Smarty: Display Product List with Details Source: https://github.com/webasyst/dummy-theme-shop/blob/master/dummy/products.html Iterates through products, rendering details such as name, image, summary, price, stock status, rating, and action buttons. It handles different display types and conditional logic for availability and promotions. ```smarty {strip} {if !empty($products)} {$add2cart_label = '[`Buy`]'} {if $wa->shop->cart->total() > 0} {$add2cart_label = '[`Add to cart`'} {/if} {if !empty($theme_settings.list_features)} {$features = $wa->shop->features($products)} {/if} {$_types = ["thumbs" => "thumbs-view", "table" => "table-view"]} {$_type = $_types["thumbs"]} {if !empty($type)} {$_type = $_types[$type]} {else} {$_settings_type = $theme_settings.related_view_type} {if !empty($_settings_type) && $_settings_type == "table"} {$_type = $_types["table"]} {/if} {/if} {$_uniq_ident = rand(0, 1000)} {if !empty($sorting)} {include file="./products.sorting.html" inline} {/if} {foreach $products as $product} {$available = $wa->shop->settings('ignore_stock_count') || $product.count === null || $product.count > 0} {$badge_html = $wa->shop->badgeHtml($product.badge)} {$_product_image_src = $wa->shop->productImgUrl($product, "200")} {if !$_product_image_src} {$_product_image_src = "$wa_theme_url"img/dummy200.png"} {/if}* [![{$product.name}]({$_product_image_src})]({$product.frontend_url} "{$product.name}") ##### [{$product.name}]({$product.frontend_url} "{$product.name}") {if $product.summary} {strip_tags($product.summary)|truncate:100} {/if} {if $available} 1}data-url="{$product.frontend_url}{if strpos($product.frontend_url, '?')}&{else}?{/if}cart=1"{/if} method="post" action="{$wa->getUrl('/frontendCart/add')}"> {/if} {if $available} {shop_currency_html($product.price)} {if $product.compare_price > 0} {shop_currency_html($product.compare_price)} {/if} {else} {shop_currency_html($product.price)} **{if $wa->shop->settings('ignore_stock_count')}[`Pre-order only`]{else}[`Out of stock`]{/if}** {/if} {if $product.rating > 0} {$wa->shop->ratingHtml($product.rating, 16)} {$product.rating_count} [`Review's`] {else} No review's {/if} {if empty($hide_buttons)} {if empty($disable_compare)} [](javascript:void(0); "[`Compare`]"){/if} {if $available} {/if} {/if} {if $available} {/if} {if !empty($badge_html)} {$badge_html} {/if} {/foreach} {if isset($pages_count) && $pages_count > 1} {wa_pagination total=$pages_count attrs=[`class` => "s-paging-list"]} {/if} {/strip} ``` -------------------------------- ### Display Shop Categories Source: https://github.com/webasyst/dummy-theme-shop/blob/master/dummy/header.html Retrieves and displays a list of shop categories. It first fetches all categories using `$wa->shop->categories()` and then iterates through them, creating a link for each category name. The display is conditional on categories being available. ```Templating {$\_catalogs = $wa->shop->categories(0, 0, false)} {if !empty($\_catalogs)} [\`Catalog\`]({$wa_app_url}) {foreach $\_catalogs as $cat_item}* [{$cat_item.name}]({$cat_item.url}) {/foreach} {/if} ``` -------------------------------- ### Affiliate Bonus Calculation and Display Source: https://github.com/webasyst/dummy-theme-shop/blob/master/dummy/my.affiliate.html Calculates and formats the affiliate bonus, prepending a '+' sign if the bonus is non-negative, and displays it to the user. ```Webasyst Template {$balance = round($customer.affiliate_bonus, 2)|wa_format_number:false} {if $customer.affiliate_bonus >= 0}{$balance = '+'|cat:$balance}{/if} {`Your current affiliate bonus: **%s**`|sprintf:$balance} ``` -------------------------------- ### Webasyst Templating Logic Source: https://github.com/webasyst/dummy-theme-shop/blob/master/dummy/head.html This snippet demonstrates conditional rendering and variable output within the Webasyst templating engine. It includes checks for action states, additional styles, and iterates through frontend head events. The syntax suggests a PHP-based templating system. ```templating {strip} {\* CSS *} {if !empty($action) && ( $action == "default" )} {/if} {\* PLUGINS *} {\* JS *} {\* @event frontend_head.%plugin_id% *} {foreach $frontend_head as $_}{$_}{/foreach} {/strip} ``` -------------------------------- ### Display Customer Review Source: https://github.com/webasyst/dummy-theme-shop/blob/master/dummy/review.html Renders a customer review with dynamic content. It includes conditional display of the review title, star rating based on the review's rate, author name with optional site link, and the review text. A 'reply' link is shown if replies are allowed. ```webasyst-template {strip} #### {if $review.title}{$review.title}{/if} {if !$review.parent_id && !empty($review.rate)} {$rate = round($review.rate)} {for $i = 1 to 5} {$icon_class = "star"} {if ($rate < $i)} {$icon_class = "star-empty"} {/if} {/for} {/if} {if empty($review.site)} {$review.author.name} {else} [{$review.author.name}]({$review.site}) {/if} {if ifempty($review.author.is_user) > 0} {$wa->shop->settings('name')} {/if} {$review.datetime|wa_datetime:"humandatetime"} {if $review.text} {$review.text} {/if} {if $reply_allowed} {$_link_href = "javascript:void(0);"} {if isset($reply_link)} {$_link_href = $reply_link} {/if} [[`reply`]]({$_link_href}) {/if} {/strip} ``` -------------------------------- ### Create Permanent User Account Toggle Source: https://github.com/webasyst/dummy-theme-shop/blob/master/dummy/checkout.contactinfo.html Provides an option for customers to create a permanent user account during checkout. Includes logic to sync email and login fields. ```javascript var e = $("input[name=\"customer[email]\"]"); if (e.length) { e.on('keyup', function () { if ($("#create-user-div").is(':visible')) { $('#create-user-div input[name="login"]').val($(this).val()); } }); $('#create-user-div input[name="login"]').on('keyup', function () { e.val( $(this).val() ); }) } $("#create-user").change(function () { if ($(this).is(':checked')) { $("#create-user-div").show().find('input').removeAttr('disabled'); var l = $(this).closest('form').find('input[name="customer[email]"]'); if (l.length && l.val()) { $('#create-user-div input[name="login"]').val(l.val()); } } else { $("#create-user-div").hide().find('input').attr('disabled', 'disabled').val(''); } }).change(); ``` -------------------------------- ### Affiliate History Display Source: https://github.com/webasyst/dummy-theme-shop/blob/master/dummy/my.affiliate.html Iterates through the affiliate history, displaying transaction details like date, order reference, comment, amounts, and the resulting balance. ```Webasyst Template {if !empty($affiliate_history)} {foreach $affiliate_history as $h} {$h.create_datetime|wa_date:'humandatetime'} {if $h.order_id && !empty($h.order_url)} [Order {$wa->shop->orderId($h.order_id)}]({$h.order_url}) {if $h.comment} {$h.comment|escape} {/if} {else} {if $h.comment} {$h.comment|escape} {/if} {/if} {if $h.amount > 0} {round($h.amount,2)|wa_format_number:false} {/if} {if $h.amount < 0} {round(abs($h.amount),2)|wa_format_number:false} {/if} {round($h.balance,2)|wa_format_number:false} {/foreach} {else} You have no affiliate history yet. {/if} ``` -------------------------------- ### Category and Product Listing Template Source: https://github.com/webasyst/dummy-theme-shop/blob/master/dummy/category.html This Smarty template snippet demonstrates dynamic category name display, event handling, and conditional rendering of product lists. It includes logic to show products or a 'No products here' message, and supports sorting parameters. ```Smarty {$category.name|escape} ======================= {* @event frontend_category.%plugin_id% *} {foreach $frontend_category as $_}{$_}{/foreach} {*PRODUCT-LIST*} {if !empty($products)} {include file="./products.html" sorting=!empty($category.params.enable_sorting)} {else} [`No products here`] {/if} ``` -------------------------------- ### Selectable Features (Inline) Source: https://github.com/webasyst/dummy-theme-shop/blob/master/dummy/product.cart.html Renders selectable product features inline, typically for color or other attributes. It iterates through features and their values, creating links for each option. ```smarty {if $theme_settings.selectable_features_control == 'inline'} {foreach $features_selectable as $f} {foreach $f.values as $v_id => $v} {if !isset($default_sku_features[$f.id])}{$default_sku_features[$f.id]=$v_id}{/if} [{if $f.type == 'color'} {strip_tags($v)} {else} {$v} {/if}](javascript:void(0);) {/foreach} {/foreach} ``` -------------------------------- ### Smarty Template for Displaying Shipping Methods Source: https://github.com/webasyst/dummy-theme-shop/blob/master/dummy/checkout.shipping.html This snippet demonstrates how shipping methods are iterated and displayed using Smarty templating. It includes logic for showing method names, logos, rates, descriptions, comments, estimated delivery, and handling errors or external loading states. It also collects IDs of shipping methods that require external loading. ```smarty {$external_methods = []} {foreach $checkout_shipping_methods as $m} * ### {if !empty($m.logo)} ![]({$m.logo}) {/if} {$m.name|escape} {if empty($m.error) && !empty($m.rates)} {if count($m.rates) > 1} {foreach $m.rates as $rate_id => $r} {$r.name} ({shop_currency($r.rate, $r.currency)}) {/foreach} {else} {/if} {/if} {if $m.description} {$m.description} {/if} {if empty($m.error)} {if !empty($m.comment)}{$m.comment}{/if} [`Price`]: {if $m.rate !== null} {shop_currency_html($m.rate, $m.currency)} {elseif $m.external} {$external_methods[] = $m.id} [`Loading...`] {/if} [`Estimated delivery`]: {$m.est_delivery} {else} [`Price`]: [`Estimated delivery`]: {$m.error} {/if} {if !empty($m.form)} {$m.form->html(null, true, true)} {/if} {if !empty($m.custom_html)} {$m.custom_html} {/if} {foreachelse} * _[`Oops! We are sorry, but **we can not ship this order to your selected destination**. Checkout can not be completed.`]_ {/foreach} ``` -------------------------------- ### Flat SKU List Display Source: https://github.com/webasyst/dummy-theme-shop/blob/master/dummy/product.cart.html Handles the display of products with multiple SKUs in a flat list format. It shows SKU name, identifier, price, and stock status for each SKU. ```smarty {else} {* FLAT SKU LIST selling mode *} {$product_available = false} {if count($product.skus) > 1} {foreach $product.skus as $sku} {$sku_available = $product.status && $sku.available && ($wa->shop->settings('ignore_stock_count') || $sku.count === null || $sku.count > 0)} {$sku.name|escape} {if $sku.sku}{$sku.sku|escape}{/if} {shop_currency_html($sku.price, $product.currency)} {if (!($sku.count === null) && $sku.count <= 0)} {else} {/if} {$product_available = $product_available or $sku_available} {/foreach} {else} {* in case there is only one SKU, don't display the selector *} {$sku = $product.skus[$product.sku_id]} {if $sku.sku}{$sku.sku|escape}{/if} {if $sku.name}{/if} {if !$sku.available} _[`This product is not available for purchase`]_ {elseif !$wa->shop->settings('ignore_stock_count') && !($sku.count === null || $sku.count > 0)} **{if $wa->shop->settings('ignore_stock_count')}[`Pre-order only`]{else}[`Out of stock`]{/if}** {else} {/if} {$product_available = $product.status && $sku.available && ($wa->shop->settings('ignore_stock_count') || $sku.count === null || $sku.count > 0)} {/if} {/if} ```