```
--------------------------------
### Include Home Video Snippet (HTML)
Source: https://docs.nuvemshop.com.br/help/video-pagina-inicial
Demonstrates how to include the previously defined 'home-video.tpl' snippet into the main homepage template ('templates/home.tpl'). This integrates the video functionality into the store's layout.
```HTML
{% include 'snipplets/home/home-video.tpl' %}
```
--------------------------------
### Asynchronous CSS Loading Example
Source: https://docs.nuvemshop.com.br/help/static
Demonstrates how to load CSS files asynchronously using a JavaScript function `loadCSS`. It includes examples for Font Awesome and a custom stylesheet, referencing Twig template syntax for asset URLs.
```html
```
--------------------------------
### Nuvemshop Variant Change Handler
Source: https://docs.nuvemshop.com.br/help/informao-de-meios-de-pagamento-e-parcelas-jqnuvem
JavaScript function to update product details, including price, installments, labels, and call-to-action elements, when a product variant is changed. It handles DOM manipulation and integrates with Nuvemshop's installment data.
```javascript
{# /* // Change variant */ #}
{# Updates price, installments, labels and CTA on variant change #}
function changeVariant(variant){
jQueryNuvem(".js-product-detail .js-shipping-calculator-response").hide();
jQueryNuvem("#shipping-variant-id").val(variant.id);
var parent = jQueryNuvem("body");
if (variant.element){
parent = jQueryNuvem(variant.element);
}
var sku = parent.find('#sku');
if(sku.length) {
sku.text(variant.sku).show();
}
var installment_helper = function($element, amount, price){
$element.find('.js-installment-amount').text(amount);
$element.find('.js-installment-price').attr("data-value", price);
$element.find('.js-installment-price').text(LS.currency.display_short + parseFloat(price).toLocaleString('de-DE', { minimumFractionDigits: 2 }));
if(variant.price_short && Math.abs(variant.price_number - price * amount) < 1) {
$element.find('.js-installment-total-price').text((variant.price_short).toLocaleString('de-DE', { minimumFractionDigits: 2 }));
} else {
$element.find('.js-installment-total-price').text(LS.currency.display_short + (price * amount).toLocaleString('de-DE', { minimumFractionDigits: 2 }));
}
};
if (variant.installments_data) {
var variant_installments = JSON.parse(variant.installments_data);
var max_installments_without_interests = [0,0];
var max_installments_with_interests = [0,0];
for (let payment_method in variant_installments) {
let installments = variant_installments[payment_method];
for (let number_of_installment in installments) {
let installment_data = installments[number_of_installment];
max_installments_without_interests = get_max_installments_without_interests(number_of_installment, installment_data, max_installments_without_interests);
max_installments_with_interests = get_max_installments_with_interests(number_of_installment, installment_data, max_installments_with_interests);
var installment_container_selector = '#installment_' + payment_method.replace(" ", "_") + '_' + number_of_installment;
if(!parent.hasClass("js-quickshop-container")){
installment_helper(jQueryNuvem(installment_container_selector), number_of_installment, installment_data.installment_value.toFixed(2));
}
}
}
var $installments_container = jQueryNuvem(variant.element + ' .js-max-installments-container .js-max-installments');
var $installments_modal_link = jQueryNuvem(variant.element + ' #btn-installments');
var $payments_module = jQueryNuvem(variant.element + ' .js-product-payments-container');
```
--------------------------------
### Include Filters Component
Source: https://docs.nuvemshop.com.br/help/componentes-privados
Example of how to include the filters component in a template, specifying various configuration options for its behavior and appearance.
```template
{{ component(
'filters/filters',{
accordion: true,
parent_category_link: false,
applied_filters_badge: true,
container_classes: {
filters_container: "visible-when-content-ready",
},
accordion_classes: {
title_container: "row no-gutters align-items-center",
title_col: "col my-1 pr-3 d-flex align-items-center",
title: "h6 font-body font-weight-bold mb-0",
actions_col: "col-auto my-1",
title_icon: "icon-inline svg-icon-text font-big mr-1"
},
filter_classes: {
list: "list-unstyled my-3",
list_item: "mb-2",
list_link: "font-small",
badge: "h6 font-small ml-1",
show_more_link: "d-inline-block btn-link font-small mt-1",
checkbox_last: "m-0",
price_group: 'price-filter-container filter-accordion',
price_title: 'h6 font-weight-bold mb-4',
price_submit: 'btn btn-default d-inline-block',
applying_feedback_message: 'h5 mr-2',
applying_feedback_icon: 'icon-inline h5 icon-spin svg-icon-text'
},
accordion_show_svg_id: 'plus',
accordion_hide_svg_id: 'minus',
applying_feedback_svg_id: 'spinner-third'
})
}}
```
--------------------------------
### Configuration Settings
Source: https://docs.nuvemshop.com.br/help/variacoes-sem-estoque
Defines settings for the product variant display feature. It includes a title for the section and a checkbox to enable the 'show as buttons' functionality.
```ini
[title]
title = Variantes del producto
[checkbox]
name = bullet_variants
description = Mostrar como botones
```
--------------------------------
### Shipping Options Selection Prompt
Source: https://docs.nuvemshop.com.br/help/calculadora-de-frete
Informs the user that they will be able to select from available shipping options before completing their purchase. This guides the checkout process.
```es
Vas a poder elegir alguna de las siguientes opciones antes de finalizar la compra:
```
```pt
Você pode escolher uma das seguintes opções antes de finalizar a compra
```
```en
You will be able to choose some of the following options before ending the purchase
```
```es_mx
Podrás elegir alguna de las siguientes opciones antes de finalizar la compra:
```
--------------------------------
### Quick Shop Snippet
Source: https://docs.nuvemshop.com.br/help/snipplets
Implements a quick shop popup for products displayed in a list. It uses a modal structure with placeholders for product details like name, price, and image. Requires the `settings.quick_shop` to be enabled.
```twig
{% if settings.quick_shop %}
{% embed "snipplets/modal.tpl" with{modal_id: 'quickshop-modal', modal_class: 'quickshop text-center', modal_position: 'bottom modal-bottom-sheet', modal_transition: 'slide', modal_header: true, modal_footer: true, modal_width: 'centered modal-docked-md modal-docked-md-centered', modal_mobile_full_screen: 'true' } %}
{% block modal_body %}
{# Image is hidden but present so it can be used on cart notifiaction #}
{% endblock %}
{% endembed %}
{% endif %}
```
--------------------------------
### Set Default Product Quantity
Source: https://docs.nuvemshop.com.br/help/quantidade-de-produtos-por-pagina
Define o valor padrão para a quantidade de produtos por página no arquivo defaults.txt.
```config
category_quantity_products = 12
```
--------------------------------
### Embed Custom Cart Input
Source: https://docs.nuvemshop.com.br/help/campos-personalizados-no-carrinho
Example of embedding the form input snippet to add a custom field (e.g., 'Dedicatoria') to the shopping cart in Nuvemshop.
```twig
{# Custom cart inputs #}
{% embed "snipplets/forms/form-input.tpl" with{text_area: true, input_name: 'custom[Dedicatoria]', input_label_text: 'Dedicatoria' | translate }
{% endembed %}
```
--------------------------------
### jQuery Removal Warning
Source: https://docs.nuvemshop.com.br/help/imagem-do-detalhe-do-produto-jq-nuvem
Alerts developers that the jQuery library will be removed from Nuvemshop stores starting January 30, 2023, making the '$' function unavailable.
```text
A partir do dia 30 de janeiro de 2023, a biblioteca jQuery será removida do código de nossas lojas, portanto, a função "$" não poderá ser utilizada.
```
--------------------------------
### JavaScript Options and Localization System
Source: https://docs.nuvemshop.com.br/help/imagem-do-detalhe-do-produto-jq-nuvem
Provides a robust system for managing configuration options, including nested properties and localization support. The `option` method retrieves values, potentially executing functions, while `localize` formats strings using provided data.
```javascript
var O=function(){function t(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};o(this,t),this.options=k(!0,{},e),this.plugins=[],this.events={};for(var i=0,n=["on","once"];i
2?o-2:0),s=2;s1&&void 0!==arguments[1]?arguments[1]:[];return t=(t=String(t).replace(/\{\{(\w+).?(\w+)?\}\}/g,(function(t,n,o){var a="";o?a=e.option("".concat(n[0]+n.toLowerCase().substring(1),".l10n.").concat(o)):n&&(a=e.option("l10n.".concat(n))),a||(a=t);for(var s=0;s -1;
}));
return e ? e.index : null;
}
```
--------------------------------
### Feature Configuration (settings.txt)
Source: https://docs.nuvemshop.com.br/help/ltimo-produto-em-estoque-jq-nuvem
Configura um checkbox e um campo de texto para ativar e personalizar a funcionalidade 'Último produto em estoque' na seção de Detalhe do Produto.
```config
title
title = Último producto en stock
checkbox
name = last_product
description = Mostrar un mensaje para incentivar la compra cuando quede la última unidad de un producto
i18n_input
description = Mensaje
name = last_product_text
```