{% if product.productBundle %}
{% set items = product.productBundle.productBundleItems %}
{% set bundle = true %}
{% else %}
{% set items = variants %}
{% set bundle = false %}
{% endif %}
<div id="sylius-variants-details" data-bundle="{{ bundle }}" data-unavailable-text="{{ 'sylius.ui.unavailable'|trans }}">
{% set defaultTexts = "let defaultTexts = [];" %}
{% for item in items %}
{% if bundle %}
{% set variant = item.productVariant %}
{% set itemId = item.id %}
{% else %}
{% set variant = item %}
{% set itemId = 0 %}
{% endif %}
<div class="variant-description" data-description="{{ variant.description|replace({'\"': '\''}) }}"
data-code="{{ variant.code|replace({'\"': '\''}) }}"
data-tracked="{% if variant.tracked %}1{% else %}0{% endif %}"
data-onHand="{{ variant.onHand }}"
data-onHold="{{ variant.onHold }}"
data-variantId="{{ variant.id }}"
data-variantName="{{ variant.product.name }}"
{% if variant.model is not null %}
data-modelId="{{ variant.model.id }}"
{% if variant.model.advanced %}
data-advanced="1"
{% else %}
data-advanced="0"
{% endif %}
{% else %}
data-modelId="0"
data-advanced="0"
{% endif %}
data-itemId="{{ itemId }}"
data-stock-family="{{ variant.stockFamily ? variant.stockFamily.onHand : "null" }}"
data-minimal-quantity="{{ variant.minimalQuantity ? variant.minimalQuantity : "null" }}"
data-stock-family-has="{{ variant.stockFamily ? 1 : 0 }}"
data-stock-family-onHand="{{ variant.stockFamily ? variant.stockFamily.onHand : "null" }}"
data-stock-family-onHold="{{ variant.stockFamily ? variant.stockFamily.onHold : "null" }}"
data-bundle="{{ bundle }}"
{% if bundle %}
{% set inStock = true %}
{% if not sylius_inventory_is_available(product.variants.first) and app_count_available_variants(product) < 2 %}
{% set inStock = false %}
{% endif %}
data-bundle-instock ="{{ inStock }}"
data-bundle-quantity="{{ item.quantity }}"
data-product-bundle="{{ item.productBundle.id }}"
data-bundle-tracked="{{ item.productBundle.product.variants.0.tracked ? : "0" }}"
data-bundle-onhand="{{ item.productBundle.product.variants.0.onHand }}"
data-bundle-onhold="{{ item.productBundle.product.variants.0.onHold }}"
{% endif %}
{% for option in variant.optionValues %}data-{{ option.option.code }}="{{ option.code|replace({'\"': '\''}) }}"{% endfor %}
{% if variant.model is not null %}
data-model='{
"modelId" : "{{ variant.model.id }}",
"variantId" : "{{ variant.id }}",
"itemId" : "{{ itemId }}",
"isDigitalProduct" : {{ product.isDigitalProduct ? 1 : 0 }},
"modelName" : "{{ variant.model.name }}",
"width" : {{ variant.model.width }},
"height" : {{ variant.model.height }},
"printZoneWidthPx" : {{ variant.model.printZoneWidthPx }},
"printZoneHeightPx" : {{ variant.model.printZoneHeightPx }},
"printZoneCoordinatesX" : {{ variant.model.printZoneCoordinatesX }},
"printZoneCoordinatesY" : {{ variant.model.printZoneCoordinatesY }},
"productVariantId" : "{{ variant.model.productVariant.id }}",
"watermarkOnCartRendering" : {{ variant.model.watermarkOnCartRendering ? "true" : "false" }},
"advanced" : {{ variant.model.advanced ? "true" : "false" }},
"textPersonalisation" : {{ variant.model.textPersonalisation ? "true" : "false" }},
"freeConfiguration" : {{ variant.model.freeConfiguration ? "true" : "false" }},
"enableText" : {{ 'text' in variant.model.type ? "true" : "false" }},
"enableImageUpload" : {{ 'image_upload' in variant.model.type ? "true" : "false" }},
"enableImageLibrary" : {{ 'image_library' in variant.model.type ? "true" : "false" }},
"printFormat" : "{{ variant.model.printFormat }}",
{% if variant.model.freeConfiguration %}
"allowedTypes" : [{}
{% set i = 0 %}
{% for t in variant.model.type %}
,{
"{{ i }}" : "{{ t }}"
}
{% set i = i + 1 %}
{% endfor %}
],
{% endif %}
{% set count = 0 %}
"fonts" : [
{% for font in variant.model.fonts %}
{% set count = count + 1 %}
{{ count == 1 ? "" : "," }}{
"fontName" : "{{ font.name }}",
"filePath" : "{{ font.filePath }}"
}
{% endfor %}
],
{% if variant.model.defaultFont is not null %}
"defaultTextFont" : {
"fontName" : "{{ variant.model.defaultFont.name }}",
"filePath" : "{{ variant.model.defaultFont.filePath }}"
},
{% else %}
"defaultTextFont" : null,
{% endif %}
{% set count = 0 %}
"fontColors": [
{% for color in variant.model.fontColors %}
{% set count = count + 1 %}
{{ count == 1 ? "" : "," }}{
"colorName" : "{{ color.getTranslation.metaTitle }}",
"hexadecimal" : "{{ color.hexadecimal }}"
}
{% endfor %}
],
{% if variant.model.defaultFontColor is not null %}
"defaultTextFontColor" : {
"colorName" : "{{ variant.model.defaultFontColor ? variant.model.defaultFontColor.getTranslation.metaTitle : "null" }}",
"hexadecimal" : "{{ variant.model.defaultFontColor.hexadecimal }}"
},
{% else %}
"defaultTextFontColor" : null,
{% endif %}
{% set count = 0 %}
"strokeColors": [
{% for color in variant.model.strokeColors %}
{% set count = count + 1 %}
{{ count == 1 ? "" : "," }}{
"colorName" : "{{ color.getTranslation.metaTitle }}",
"hexadecimal" : "{{ color.hexadecimal }}"
}
{% endfor %}
],
{% if variant.model.defaultStrokeColor is not null %}
"defaultStrokeColor" : {
"colorName" : "{{ variant.model.defaultStrokeColor ? variant.model.defaultStrokeColor.getTranslation.metaTitle : "null" }}",
"hexadecimal" : "{{ variant.model.defaultStrokeColor.hexadecimal }}"
},
{% else %}
"defaultStrokeColor" : null,
{% endif %}
{% set count = 0 %}
"shadowColors": [
{% for color in variant.model.shadowColors %}
{% set count = count + 1 %}
{{ count == 1 ? "" : "," }}{
"colorName" : "{{ color.getTranslation.metaTitle }}",
"hexadecimal" : "{{ color.hexadecimal }}"
}
{% endfor %}
],
{% if variant.model.defaultShadowColor is not null %}
"defaultShadowColor" : {
"colorName" : "{{ variant.model.defaultShadowColor ? variant.model.defaultShadowColor.getTranslation.metaTitle : "null" }}",
"hexadecimal" : "{{ variant.model.defaultShadowColor.hexadecimal }}"
},
{% else %}
"defaultShadowColor" : null,
{% endif %}
{% set count = 0 %}
"libraries": [
{% for library in variant.model.libraries %}
{% set count = count + 1 %}
{{ count == 1 ? "" : "," }}{
"id" : "{{ library.id }}",
"darkBackground" : {{ library.darkBackground ? "true" : "false" }},
"name" : "{{ library.name }}",
{% set countFiles = 0 %}
"files": [
{% for file in library.files %}
{% set countFiles = countFiles + 1 %}
{% set scheme = app.request.server.get('REQUEST_SCHEME') %}
{% set host = app.request.server.get('HTTP_HOST') %}
{% set path = file.path|imagine_filter('app_shop_configuration_library_file')|replace({(scheme ~ "://" ~ host ~ "/"): ''}) %}
{{ countFiles == 1 ? "" : "," }}{
"id" : "{{ file.id }}",
"path" : "{{ file.path }}",
"popupPath" : "{{ path|default(file.path) }}"
}
{% endfor %}
]
}
{% endfor %}
]
} '
{% set countElements = 0 %}
{% if variant.model.elements is not null %}
data-elements='[
{% set elementIndex = 0 %}
{% for element in variant.model.elements %}
{% set countElements = countElements + 1 %}
{{ countElements == 1 ? "" : "," }}{
"type" : "{{ element.type }}",
"coordinatesX" : {{ element.coordinatesX }},
"coordinatesY" : {{ element.coordinatesY }},
"height" : {{ element.height }},
"width" : {{ element.width }},
"angle" : {{ element.orientation }},
"allowRotation" : {{ element.allowRotation ? "true" : "false" }},
"allowMovement" : {{ element.allowMovement ? "true" : "false" }},
"mandatory" : {{ element.mandatory ? "true" : "false" }},
"blended" : {{ element.blended ? "true" : "false" }},
"id" : {{ element.id }},
{% if element.defaultTextSize is not null %}
"defaultTextSize" : {{ element.defaultTextSize }},
{% else %}
"defaultTextSize" : null,
{% endif %}
"characterLineLimit" : null,
{% if element.textSizeMin is not null %}
"textSizeMin" : {{ element.textSizeMin }},
{% else %}
"textSizeMin" : null,
{% endif %}
"linesMax" : {{ element.linesMax }},
{% if element.linesMax == 1 %}
"characterLimit" : {{ element.characterLimit ?? "null" }},
"characterLineLimit" : null,
"textSizeMin" : null,
"lineSpace" : null,
"allowLineSpaceChange" : false,
{% elseif element.linesMax > 1 %}
"characterLimit" : null,
"characterLineLimit" : null,
"textSizeMin" : {{ element.textSizeMin ?? "null" }},
"lineSpace" : {{ element.lineSpace ?? "null" }},
"allowLineSpaceChange" : {{ element.allowLineSpaceChange ? "true" : "false" }},
{% else %}
"characterLimit" : null,
"lineSpace" : null,
"allowLineSpaceChange" : false,
{% endif %}
"diameter" : "{{ element.diameter }}",
{% if element.forcePrintColor %}
"forcePrintColor" : true,
{% else %}
"forcePrintColor" : false,
{% endif %}
{% if element.printColor is not null %}
"printColor" : "{{ element.printColor }}",
{% else %}
"printColor" : null,
{% endif %}
"textBold" : {{ element.textBold ? "true" : "false" }},
"textItalic" : {{ element.textItalic ? "true" : "false" }},
"textAlignment" : "{{ element.textAlignment }}",
{% set count = 0 %}
"fonts" : [
{% for font in element.fonts %}
{% set count = count + 1 %}
{{ count == 1 ? "" : "," }}{
"fontName" : "{{ font.name }}",
"filePath" : "{{ font.filePath }}"
}
{% endfor %}
],
{% if element.defaultFont is not null %}
"defaultTextFont" : {
"fontName" : "{{ element.defaultFont.name }}",
"filePath" : "{{ element.defaultFont.filePath }}"
},
{% else %}
"defaultTextFont" : null,
{% endif %}
{% set count = 0 %}
"fontColors": [
{% for color in element.fontColors %}
{% set count = count + 1 %}
{{ count == 1 ? "" : "," }}{
"colorName" : "{{ color.getTranslation.metaTitle }}",
"hexadecimal" : "{{ color.hexadecimal }}"
}
{% endfor %}
],
{% if element.defaultFontColor is not null %}
"defaultTextFontColor" : {
"colorName" : "{{ element.defaultFontColor ? element.defaultFontColor.getTranslation.metaTitle : "null" }}",
"hexadecimal" : "{{ element.defaultFontColor.hexadecimal }}"
},
{% else %}
"defaultTextFontColor" : null,
{% endif %}
{% set count = 0 %}
"strokeColors": [
{% for color in element.strokeColors %}
{% set count = count + 1 %}
{{ count == 1 ? "" : "," }}{
"colorName" : "{{ color.getTranslation.metaTitle }}",
"hexadecimal" : "{{ color.hexadecimal }}"
}
{% endfor %}
],
{% if element.defaultStrokeColor is not null %}
"defaultStrokeColor" : {
"colorName" : "{{ element.defaultStrokeColor ? element.defaultStrokeColor.getTranslation.metaTitle : "null" }}",
"hexadecimal" : "{{ element.defaultStrokeColor.hexadecimal }}"
},
{% else %}
"defaultStrokeColor" : null,
{% endif %}
{% set count = 0 %}
"shadowColors": [
{% for color in element.shadowColors %}
{% set count = count + 1 %}
{{ count == 1 ? "" : "," }}{
"colorName" : "{{ color.getTranslation.metaTitle }}",
"hexadecimal" : "{{ color.hexadecimal }}"
}
{% endfor %}
],
{% if element.defaultShadowColor is not null %}
"defaultShadowColor" : {
"colorName" : "{{ element.defaultShadowColor ? element.defaultShadowColor.getTranslation.metaTitle : "null" }}",
"hexadecimal" : "{{ element.defaultShadowColor.hexadecimal }}"
},
{% else %}
"defaultShadowColor" : null,
{% endif %}
{% set count = 0 %}
"libraries": [
{% for library in element.libraries %}
{% set count = count + 1 %}
{{ count == 1 ? "" : "," }}{
"id" : {{ library.id }},
"darkBackground" : {{ library.darkBackground ? "true" : "false" }},
"name" : "{{ library.name }}",
{% set countFiles = 0 %}
"files": [
{% for file in library.files %}
{% set countFiles = countFiles + 1 %}
{% set scheme = app.request.server.get('REQUEST_SCHEME') %}
{% set host = app.request.server.get('HTTP_HOST') %}
{% set path = file.path|imagine_filter('app_shop_configuration_library_file')|replace({(scheme ~ "://" ~ host ~ "/"): ''}) %}
{{ countFiles == 1 ? "" : "," }}{
"id" : {{ file.id }},
"popupPath" : "{{ path|default(file.path) }}",
"path" : "{{ file.path }}"
}
{% endfor %}
]
}
{% endfor %}
],
{% if element.defaultLibrary is not null %}
{% if element.defaultLibrary.files|length > 0 %}
"defaultLibrary" : "{{ element.defaultLibrary.files.first.path }}",
"defaultLibraryId" : {{ element.defaultLibrary.files.first.id }},
{% else %}
"defaultLibrary" : null,
"defaultLibraryId" : 0,
{% endif %}
{% else %}
"defaultLibrary" : null,
"defaultLibraryId" : 0,
{% endif %}
"elementName" : "{{ element.name | replace({'"': '\\"'}) }}",
"zIndex" : {{ element.level }},
"index": {{ elementIndex }},
"imagePath": "{{ element.imagePath }}",
"imagePathCanva": "{{ element.imagePathCanva }}",
{% set defaultText = element.defaultText %}
{% set defaultTexts = defaultTexts ~ "defaultTexts['" ~ element.id ~ "'] = '" ~ defaultText | replace({"'":"\\'"}) ~ "';" %}
"defaultText" : "{{ defaultText | nl2br | replace({"\n":'', "\r":''}) | replace({"<br />":'\\n'}) }}",
"visibleOnConfigurator": {{ element.visibleOnConfigurator ? "true" : "false" }},
"visibleOnPrint": {{ element.visibleOnPrint ? "true" : "false" }},
"linkedToPrintZone": {{ element.linkedToPrintZone ? "true" : "false" }},
"curvedText": {{ element.curvedText ? "true" : "false" }},
"workflow": {{ element.workflow ? element.workflow.id : 0 }}
}
{% set elementIndex = elementIndex + 1 %}
{% endfor %}
]'
{% endif %}
{% endif %}
></div>
{% endfor %}
<script id="defaultTexts">
{{ defaultTexts | raw | nl2br | replace({"\n":'', "\r":''}) | replace({"<br />":'\\n'}) | raw }}
</script>
</div>