themes/BootstrapTheme/templates/bundles/SyliusShopBundle/Product/Show/_variantsDetails.html.twig line 1

Open in your IDE?
  1. {% if product.productBundle %}
  2.     {% set items = product.productBundle.productBundleItems %}
  3.     {% set bundle = true %}
  4. {% else %}
  5.     {% set items = variants %}
  6.     {% set bundle = false %}
  7. {% endif %}
  8. <div id="sylius-variants-details" data-bundle="{{ bundle }}" data-unavailable-text="{{ 'sylius.ui.unavailable'|trans }}">
  9.     {% set defaultTexts = "let defaultTexts = [];" %}
  10.     {% for item in items %}
  11.         {% if bundle %}
  12.             {% set variant = item.productVariant %}
  13.             {% set itemId = item.id %}
  14.         {% else %}
  15.             {% set variant = item %}
  16.             {% set itemId = 0 %}
  17.         {% endif %}
  18.             <div class="variant-description" data-description="{{ variant.description|replace({'\"': '\''}) }}"
  19.              data-code="{{ variant.code|replace({'\"': '\''}) }}"
  20.              data-tracked="{% if variant.tracked %}1{% else %}0{% endif %}"
  21.              data-onHand="{{ variant.onHand }}"
  22.              data-onHold="{{ variant.onHold }}"
  23.              data-variantId="{{ variant.id }}"
  24.              data-variantName="{{ variant.product.name }}"
  25.              {% if variant.model is not null %}
  26.                   data-modelId="{{ variant.model.id }}"
  27.                  {% if variant.model.advanced %}
  28.                      data-advanced="1"
  29.                  {% else %}
  30.                      data-advanced="0"
  31.                  {% endif %}
  32.              {% else %}
  33.                   data-modelId="0"
  34.                   data-advanced="0"
  35.              {% endif %}
  36.              data-itemId="{{ itemId }}"
  37.              data-stock-family="{{ variant.stockFamily ? variant.stockFamily.onHand : "null" }}"
  38.              data-minimal-quantity="{{ variant.minimalQuantity ? variant.minimalQuantity : "null" }}"
  39.              data-stock-family-has="{{ variant.stockFamily ? 1 : 0 }}"
  40.              data-stock-family-onHand="{{ variant.stockFamily ? variant.stockFamily.onHand : "null" }}"
  41.              data-stock-family-onHold="{{ variant.stockFamily ? variant.stockFamily.onHold : "null" }}"
  42.              data-bundle="{{ bundle }}"
  43.              {% if bundle %}
  44.                  {% set inStock = true %}
  45.                  {% if not sylius_inventory_is_available(product.variants.first) and app_count_available_variants(product) < 2 %}
  46.                      {% set inStock = false %}
  47.                  {% endif %}
  48.                 data-bundle-instock ="{{ inStock }}"
  49.                 data-bundle-quantity="{{ item.quantity }}"
  50.                 data-product-bundle="{{ item.productBundle.id }}"
  51.                 data-bundle-tracked="{{ item.productBundle.product.variants.0.tracked ? : "0" }}"
  52.                 data-bundle-onhand="{{ item.productBundle.product.variants.0.onHand }}"
  53.                 data-bundle-onhold="{{ item.productBundle.product.variants.0.onHold }}"
  54.              {% endif %}
  55.              {% for option in variant.optionValues %}data-{{ option.option.code }}="{{ option.code|replace({'\"': '\''}) }}"{% endfor %}
  56.             {% if variant.model is not null %}
  57.                 data-model='{
  58.                     "modelId" : "{{ variant.model.id }}",
  59.                     "variantId" : "{{ variant.id }}",
  60.                     "itemId" : "{{ itemId }}",
  61.                     "isDigitalProduct" : {{ product.isDigitalProduct ? 1 : 0 }},
  62.                     "modelName" : "{{ variant.model.name }}",
  63.                     "width" : {{ variant.model.width }},
  64.                     "height" : {{ variant.model.height }},
  65.                     "printZoneWidthPx" : {{ variant.model.printZoneWidthPx }},
  66.                     "printZoneHeightPx" : {{ variant.model.printZoneHeightPx }},
  67.                     "printZoneCoordinatesX" : {{ variant.model.printZoneCoordinatesX }},
  68.                     "printZoneCoordinatesY" : {{ variant.model.printZoneCoordinatesY }},
  69.                     "productVariantId" : "{{ variant.model.productVariant.id }}",
  70.                     "watermarkOnCartRendering" : {{ variant.model.watermarkOnCartRendering ? "true" : "false" }},
  71.                     "advanced" : {{ variant.model.advanced ? "true" : "false" }},
  72.                     "textPersonalisation" : {{ variant.model.textPersonalisation ? "true" : "false" }},
  73.                     "freeConfiguration" : {{ variant.model.freeConfiguration ? "true" : "false" }},
  74.                     "enableText" : {{ 'text' in variant.model.type ? "true" : "false" }},
  75.                     "enableImageUpload" : {{ 'image_upload' in variant.model.type ? "true" : "false" }},
  76.                     "enableImageLibrary" : {{ 'image_library' in variant.model.type ? "true" : "false" }},
  77.                     "printFormat" : "{{ variant.model.printFormat }}",
  78.                     {% if variant.model.freeConfiguration %}
  79.                         "allowedTypes" : [{}
  80.                         {% set i = 0 %}
  81.                         {% for t in variant.model.type %}
  82.                             ,{
  83.                             "{{ i }}" : "{{ t }}"
  84.                             }
  85.                             {% set i = i + 1 %}
  86.                         {% endfor %}
  87.                         ],
  88.                     {% endif %}
  89.                     {% set count = 0 %}
  90.                     "fonts" : [
  91.                         {% for font in variant.model.fonts %}
  92.                             {% set count = count + 1 %}
  93.                             {{ count == 1 ? "" : "," }}{
  94.                                 "fontName" : "{{ font.name }}",
  95.                                 "filePath" : "{{ font.filePath }}"
  96.                             }
  97.                         {% endfor %}
  98.                     ],
  99.                     {% if variant.model.defaultFont is not null %}
  100.                         "defaultTextFont" : {
  101.                             "fontName" : "{{ variant.model.defaultFont.name }}",
  102.                             "filePath" : "{{ variant.model.defaultFont.filePath }}"
  103.                         },
  104.                     {% else %}
  105.                         "defaultTextFont" : null,
  106.                     {% endif %}
  107.                     {% set count = 0 %}
  108.                     "fontColors": [
  109.                         {% for color in variant.model.fontColors %}
  110.                             {% set count = count + 1 %}
  111.                             {{ count == 1 ? "" : "," }}{
  112.                                 "colorName" : "{{ color.getTranslation.metaTitle }}",
  113.                                 "hexadecimal" : "{{ color.hexadecimal }}"
  114.                             }
  115.                         {% endfor %}
  116.                     ],
  117.                     {% if variant.model.defaultFontColor is not null %}
  118.                     "defaultTextFontColor" : {
  119.                         "colorName" : "{{ variant.model.defaultFontColor ? variant.model.defaultFontColor.getTranslation.metaTitle : "null" }}",
  120.                         "hexadecimal" : "{{ variant.model.defaultFontColor.hexadecimal }}"
  121.                     },
  122.                     {% else %}
  123.                         "defaultTextFontColor" : null,
  124.                     {% endif %}
  125.                     {% set count = 0 %}
  126.                     "strokeColors": [
  127.                         {% for color in variant.model.strokeColors %}
  128.                             {% set count = count + 1 %}
  129.                             {{ count == 1 ? "" : "," }}{
  130.                                 "colorName" : "{{ color.getTranslation.metaTitle }}",
  131.                                 "hexadecimal" : "{{ color.hexadecimal }}"
  132.                             }
  133.                         {% endfor %}
  134.                     ],
  135.                     {% if variant.model.defaultStrokeColor is not null %}
  136.                     "defaultStrokeColor" : {
  137.                         "colorName" : "{{ variant.model.defaultStrokeColor ? variant.model.defaultStrokeColor.getTranslation.metaTitle : "null" }}",
  138.                         "hexadecimal" : "{{ variant.model.defaultStrokeColor.hexadecimal }}"
  139.                     },
  140.                     {% else %}
  141.                         "defaultStrokeColor" : null,
  142.                     {% endif %}
  143.                     {% set count = 0 %}
  144.                     "shadowColors": [
  145.                         {% for color in variant.model.shadowColors %}
  146.                             {% set count = count + 1 %}
  147.                             {{ count == 1 ? "" : "," }}{
  148.                                 "colorName" : "{{ color.getTranslation.metaTitle }}",
  149.                                 "hexadecimal" : "{{ color.hexadecimal }}"
  150.                             }
  151.                         {% endfor %}
  152.                     ],
  153.                     {% if variant.model.defaultShadowColor is not null %}
  154.                     "defaultShadowColor" : {
  155.                         "colorName" : "{{ variant.model.defaultShadowColor ? variant.model.defaultShadowColor.getTranslation.metaTitle : "null" }}",
  156.                         "hexadecimal" : "{{ variant.model.defaultShadowColor.hexadecimal }}"
  157.                     },
  158.                     {% else %}
  159.                         "defaultShadowColor" : null,
  160.                     {% endif %}
  161.                     {% set count = 0 %}
  162.                     "libraries": [
  163.                         {% for library in variant.model.libraries %}
  164.                             {% set count = count + 1 %}
  165.                             {{ count == 1 ? "" : "," }}{
  166.                                 "id" : "{{ library.id }}",
  167.                                 "darkBackground" : {{ library.darkBackground ? "true" : "false" }},
  168.                                 "name" : "{{ library.name }}",
  169.                                 {% set countFiles = 0 %}
  170.                                 "files": [
  171.                                     {% for file in library.files %}
  172.                                         {% set countFiles = countFiles + 1 %}
  173.                                         {% set scheme = app.request.server.get('REQUEST_SCHEME') %}
  174.                                         {% set host = app.request.server.get('HTTP_HOST') %}
  175.                                         {% set path =  file.path|imagine_filter('app_shop_configuration_library_file')|replace({(scheme ~ "://" ~ host ~ "/"): ''})  %}
  176.                                         {{ countFiles == 1 ? "" : "," }}{
  177.                                             "id" : "{{ file.id }}",
  178.                                             "path" : "{{ file.path }}",
  179.                                             "popupPath" : "{{ path|default(file.path) }}"
  180.                                         }
  181.                                     {% endfor %}
  182.                                 ]
  183.                             }
  184.                         {% endfor %}
  185.                     ]
  186.                 } '
  187.                 {% set countElements = 0 %}
  188.                 {% if variant.model.elements is not null %}
  189.                     data-elements='[
  190.                     {% set elementIndex = 0 %}
  191.                     {% for element in variant.model.elements %}
  192.                         {% set countElements = countElements + 1 %}
  193.                         {{ countElements == 1 ? "" : "," }}{
  194.                         "type" : "{{ element.type }}",
  195.                         "coordinatesX" : {{ element.coordinatesX }},
  196.                         "coordinatesY" : {{ element.coordinatesY }},
  197.                         "height" : {{ element.height }},
  198.                         "width" : {{ element.width }},
  199.                         "angle" : {{ element.orientation }},
  200.                         "allowRotation" : {{ element.allowRotation ? "true" : "false" }},
  201.                         "allowMovement" : {{ element.allowMovement ? "true" : "false" }},
  202.                         "mandatory" : {{ element.mandatory ? "true" : "false" }},
  203.                         "blended" : {{ element.blended ? "true" : "false" }},
  204.                         "id" : {{ element.id }},
  205.                         {% if element.defaultTextSize is not null %}
  206.                             "defaultTextSize" : {{ element.defaultTextSize }},
  207.                         {% else %}
  208.                             "defaultTextSize" : null,
  209.                         {% endif %}
  210.                             "characterLineLimit" : null,
  211.                         {% if element.textSizeMin is not null %}
  212.                             "textSizeMin" : {{ element.textSizeMin }},
  213.                         {% else %}
  214.                             "textSizeMin" : null,
  215.                         {% endif %}
  216.                         "linesMax" : {{ element.linesMax }},
  217.                         {% if element.linesMax == 1 %}
  218.                             "characterLimit" : {{ element.characterLimit ?? "null" }},
  219.                             "characterLineLimit" : null,
  220.                             "textSizeMin" : null,
  221.                             "lineSpace" : null,
  222.                             "allowLineSpaceChange" : false,
  223.                         {% elseif element.linesMax > 1 %}
  224.                             "characterLimit" : null,
  225.                             "characterLineLimit" : null,
  226.                             "textSizeMin" : {{ element.textSizeMin ?? "null" }},
  227.                             "lineSpace" : {{ element.lineSpace ?? "null" }},
  228.                             "allowLineSpaceChange" : {{ element.allowLineSpaceChange ? "true" : "false" }},
  229.                         {% else %}
  230.                             "characterLimit" : null,
  231.                             "lineSpace" : null,
  232.                             "allowLineSpaceChange" : false,
  233.                         {% endif %}
  234.                         "diameter" : "{{ element.diameter }}",
  235.                         {% if element.forcePrintColor %}
  236.                             "forcePrintColor" : true,
  237.                         {% else %}
  238.                             "forcePrintColor" : false,
  239.                         {% endif %}
  240.                         {% if element.printColor is not null %}
  241.                             "printColor" : "{{ element.printColor }}",
  242.                         {% else %}
  243.                             "printColor" : null,
  244.                         {% endif %}
  245.                         "textBold" : {{ element.textBold ? "true" : "false" }},
  246.                         "textItalic" : {{ element.textItalic ? "true" : "false" }},
  247.                         "textAlignment" : "{{ element.textAlignment }}",
  248.                         {% set count = 0 %}
  249.                         "fonts" : [
  250.                         {% for font in element.fonts %}
  251.                             {% set count = count + 1 %}
  252.                             {{ count == 1 ? "" : "," }}{
  253.                                 "fontName" : "{{ font.name }}",
  254.                                 "filePath" : "{{ font.filePath }}"
  255.                             }
  256.                         {% endfor %}
  257.                         ],
  258.                         {% if element.defaultFont is not null %}
  259.                             "defaultTextFont" : {
  260.                                 "fontName" : "{{ element.defaultFont.name }}",
  261.                                 "filePath" : "{{ element.defaultFont.filePath }}"
  262.                             },
  263.                         {% else %}
  264.                             "defaultTextFont" : null,
  265.                         {% endif %}
  266.                         {% set count = 0 %}
  267.                         "fontColors": [
  268.                         {% for color in element.fontColors %}
  269.                             {% set count = count + 1 %}
  270.                             {{ count == 1 ? "" : "," }}{
  271.                                 "colorName" : "{{ color.getTranslation.metaTitle }}",
  272.                                 "hexadecimal" : "{{ color.hexadecimal }}"
  273.                             }
  274.                         {% endfor %}
  275.                         ],
  276.                         {% if element.defaultFontColor is not null %}
  277.                         "defaultTextFontColor" : {
  278.                             "colorName" : "{{ element.defaultFontColor ? element.defaultFontColor.getTranslation.metaTitle : "null" }}",
  279.                             "hexadecimal" : "{{ element.defaultFontColor.hexadecimal }}"
  280.                         },
  281.                         {% else %}
  282.                             "defaultTextFontColor" : null,
  283.                         {% endif %}
  284.                         {% set count = 0 %}
  285.                         "strokeColors": [
  286.                             {% for color in element.strokeColors %}
  287.                                 {% set count = count + 1 %}
  288.                                 {{ count == 1 ? "" : "," }}{
  289.                                     "colorName" : "{{ color.getTranslation.metaTitle }}",
  290.                                     "hexadecimal" : "{{ color.hexadecimal }}"
  291.                                 }
  292.                             {% endfor %}
  293.                         ],
  294.                         {% if element.defaultStrokeColor is not null %}
  295.                         "defaultStrokeColor" : {
  296.                             "colorName" : "{{ element.defaultStrokeColor ? element.defaultStrokeColor.getTranslation.metaTitle : "null" }}",
  297.                             "hexadecimal" : "{{ element.defaultStrokeColor.hexadecimal }}"
  298.                         },
  299.                         {% else %}
  300.                             "defaultStrokeColor" : null,
  301.                         {% endif %}
  302.                         {% set count = 0 %}
  303.                         "shadowColors": [
  304.                             {% for color in element.shadowColors %}
  305.                                 {% set count = count + 1 %}
  306.                                 {{ count == 1 ? "" : "," }}{
  307.                                     "colorName" : "{{ color.getTranslation.metaTitle }}",
  308.                                     "hexadecimal" : "{{ color.hexadecimal }}"
  309.                                 }
  310.                             {% endfor %}
  311.                         ],
  312.                         {% if element.defaultShadowColor is not null %}
  313.                             "defaultShadowColor" : {
  314.                                 "colorName" : "{{ element.defaultShadowColor ? element.defaultShadowColor.getTranslation.metaTitle : "null" }}",
  315.                                 "hexadecimal" : "{{ element.defaultShadowColor.hexadecimal }}"
  316.                             },
  317.                         {% else %}
  318.                             "defaultShadowColor" : null,
  319.                         {% endif %}
  320.                         {% set count = 0 %}
  321.                         "libraries": [
  322.                         {% for library in element.libraries %}
  323.                             {% set count = count + 1 %}
  324.                             {{ count == 1 ? "" : "," }}{
  325.                                 "id" : {{ library.id }},
  326.                                 "darkBackground" : {{ library.darkBackground ? "true" : "false" }},
  327.                                 "name" : "{{ library.name }}",
  328.                                 {% set countFiles = 0 %}
  329.                                 "files": [
  330.                                     {% for file in library.files %}
  331.                                         {% set countFiles = countFiles + 1 %}
  332.                                         {% set scheme = app.request.server.get('REQUEST_SCHEME') %}
  333.                                         {% set host = app.request.server.get('HTTP_HOST') %}
  334.                                         {% set path =  file.path|imagine_filter('app_shop_configuration_library_file')|replace({(scheme ~ "://" ~ host ~ "/"): ''})  %}
  335.                                         {{ countFiles == 1 ? "" : "," }}{
  336.                                              "id" : {{ file.id }},
  337.                                              "popupPath" : "{{ path|default(file.path) }}",
  338.                                              "path" : "{{ file.path }}"
  339.                                         }
  340.                                     {% endfor %}
  341.                                 ]
  342.                             }
  343.                         {% endfor %}
  344.                         ],
  345.                         {% if element.defaultLibrary is not null %}
  346.                             {% if element.defaultLibrary.files|length > 0 %}
  347.                                 "defaultLibrary" : "{{ element.defaultLibrary.files.first.path }}",
  348.                                 "defaultLibraryId" : {{ element.defaultLibrary.files.first.id }},
  349.                             {% else %}
  350.                                 "defaultLibrary" : null,
  351.                                 "defaultLibraryId" : 0,
  352.                             {% endif %}
  353.                         {% else %}
  354.                             "defaultLibrary" : null,
  355.                             "defaultLibraryId" : 0,
  356.                         {% endif %}
  357.                         "elementName" : "{{ element.name | replace({'"': '\\"'}) }}",
  358.                         "zIndex" : {{ element.level }},
  359.                         "index": {{ elementIndex }},
  360.                         "imagePath": "{{ element.imagePath }}",
  361.                         "imagePathCanva": "{{ element.imagePathCanva }}",
  362.                         {% set defaultText = element.defaultText %}
  363.                         {% set defaultTexts = defaultTexts ~ "defaultTexts['" ~ element.id ~ "'] = '" ~ defaultText | replace({"'":"\\'"}) ~ "';" %}
  364.                         "defaultText" : "{{ defaultText | nl2br | replace({"\n":'', "\r":''}) | replace({"<br />":'\\n'}) }}",
  365.                         "visibleOnConfigurator": {{ element.visibleOnConfigurator ? "true" : "false" }},
  366.                         "visibleOnPrint": {{ element.visibleOnPrint ? "true" : "false" }},
  367.                         "linkedToPrintZone": {{ element.linkedToPrintZone ? "true" : "false" }},
  368.                         "curvedText": {{ element.curvedText ? "true" : "false" }},
  369.                         "workflow": {{ element.workflow ? element.workflow.id : 0 }}
  370.                         }
  371.                         {% set elementIndex = elementIndex + 1 %}
  372.                     {% endfor %}
  373.                     ]'
  374.                 {% endif %}
  375.             {% endif %}
  376.         ></div>
  377.     {% endfor %}
  378.     <script id="defaultTexts">
  379.         {{ defaultTexts | raw | nl2br | replace({"\n":'', "\r":''}) | replace({"<br />":'\\n'}) | raw }}
  380.     </script>
  381. </div>