custom/plugins/TrustedShops/src/Resources/views/storefront/base.html.twig line 1

Open in your IDE?
  1. {% sw_extends '@Storefront/storefront/base.html.twig' %}
  2. {% block base_body_inner %}
  3.     {{ parent() }}
  4.     {% if trustedshops.tsId %}
  5.         {# Trusted Shops Trustbadge - Start #}
  6.         {% if trustedshops.tsTrustbadgeExpertMode %}
  7.             {{ trustedshops.tsExpertTrustbadeCode|replace({'%tsid%': trustedshops.tsId})|raw }}
  8.         {% else %}
  9.             <script type="text/javascript">
  10.                 (function () {
  11.                     var _tsid = '{{ trustedshops.tsId|escape('js') }}';
  12.                     _tsConfig = {
  13.                         'yOffset': '{{ trustedshops.tsTrustbadgeOffsetY|escape('js')|default('0') }}', /* offset from page bottom */
  14.                         'variant': '{{ trustedshops.tsTrustbadgeVariant|escape('js')|default('default') }}', /* reviews, default, custom, custom_reviews */
  15.                         'customElementId': '', /* required for variants custom and custom_reviews */
  16.                         'trustcardDirection': '', /* for custom variants: topRight, topLeft, bottomRight, bottomLeft */
  17.                         'customBadgeWidth': '', /* for custom variants: 40 - 90 (in pixels) */
  18.                         'customBadgeHeight': '', /* for custom variants: 40 - 90 (in pixels) */
  19.                         'disableResponsive': 'false', /* deactivate responsive behaviour */
  20.                         {% if trustedshops.tsTrustbadgeVariant == 'hide' %}
  21.                         'disableTrustbadge': 'true', /* deactivate Trustbadge® */
  22.                         {% else %}
  23.                         'disableTrustbadge': 'false', /* deactivate Trustbadge® */
  24.                         {% endif %}
  25.                         'responsive': {
  26.                             'variant': '', /* floating, custom */
  27.                             'customElementId': '' /* required for variant custom */
  28.                         }
  29.                     };
  30.                     var _ts = document.createElement('script');
  31.                     _ts.type = 'text/javascript';
  32.                     _ts.charset = 'utf-8';
  33.                     _ts.async = true;
  34.                     _ts.src = '//widgets.trustedshops.com/js/' + _tsid + '.js';
  35.                     var __ts = document.getElementsByTagName('script')[0];
  36.                     __ts.parentNode.insertBefore(_ts, __ts);
  37.                 })();
  38.             </script>
  39.         {% endif %}
  40.         {# Trusted Shops Trustbadge - End #}
  41.         {# Trusted Shops Rich Snippets - Start #}
  42.         {#{% if trustedshops.tsRichSnippetsActive %}
  43.             {% if
  44.                 ( controllerName|lower == 'navigation' and controllerAction|lower == 'home' and trustedshops.tsRichSnippetsPageTypeStart ) or
  45.                 ( controllerName|lower == 'navigation' and controllerAction|lower == 'index' and trustedshops.tsRichSnippetsPageTypeCategory ) or
  46.                 ( controllerName|lower == 'product' and trustedshops.tsRichSnippetsPageTypeProduct )
  47.             %}
  48.                 {% if trustedshops.tsRichSnippetsExpertMode %}
  49.                     {% set richSnippetCode = trustedshops.tsExpertRichSnippetsCode %}
  50.                     {% set richSnippetCode = richSnippetCode|replace({'%shopname%': shopware.config.core.basicInformation.shopName}) %}
  51.                     {% set richSnippetCode = richSnippetCode|replace({'%result%': trustedshops.tsShopAvgRating}) %}
  52.                     {% set richSnippetCode = richSnippetCode|replace({'%count%': trustedshops.tsShopRatingCount}) %}
  53.                     {% set richSnippetCode = richSnippetCode|replace({'%max%': '5'}) %}
  54.                     {{ richSnippetCode|raw }}
  55.                 {% else %}
  56.                     <script type="application/ld+json">
  57.                         {
  58.                             "@context": "http://schema.org",
  59.                             "@type": "Organization",
  60.                             "name": "{{ shopware.config.core.basicInformation.shopName|escape('js') }}",
  61.                             "aggregateRating" : {
  62.                                 "@type": "AggregateRating",
  63.                                 "ratingValue" : "{{ trustedshops.tsShopAvgRating|escape('js') }}",
  64.                                 "bestRating" : "5",
  65.                                 "ratingCount" : "{{ trustedshops.tsShopRatingCount|escape('js') }}"
  66.                             }
  67.                         }
  68.                     </script>
  69.                 {% endif %}
  70.             {% endif %}
  71.         {% endif %}#}
  72.         {# Trusted Shops Trustbadge - End #}
  73.     {% endif %}
  74. {% endblock %}
  75. {% block base_body_script %}
  76.     {{ parent() }}
  77.     {# Trusted Shops jQuery Selector - Start #}
  78.     <script type="text/javascript">
  79.         (function() {
  80.             const reviewStickerElementSelector = ".ts-rating.testimonial";
  81.             const productRatingStarsElementSelector = ".ts-rating.productreviewsSummary";
  82.             const productReviewsElementSelector = ".ts-rating.productreviews";
  83.             const reviewStickerParentSelector = "{% if trustedshops.tsReviewStickerExpertMode %}{{ trustedshops.tsExpertReviewStickerJquerySelector|escape('js') }}{% endif %}";
  84.             const productRatingStarsParentSelector = "{% if trustedshops.tsProductRatingStarsExpertMode %}{{ trustedshops.tsExpertProductRatingStarsJquerySelector|escape('js') }}{% endif %}";
  85.             const productReviewsParentSelector = "{% if trustedshops.tsProductReviewsTabExpertMode %}{{ trustedshops.tsExpertProductReviewsTabJquerySelector|escape('js') }}{% endif %}";
  86.             const onJqueryLoaded = function( $ ) {
  87.                 const waitForElement = function( selector, callback ) {
  88.                     const elementChecker = window.setInterval( function() {
  89.                         if( $( selector ).length ) {
  90.                             window.clearInterval( elementChecker );
  91.                             callback.call( $( selector ) );
  92.                         }
  93.                     }, 10 );
  94.                 };
  95.                 if( reviewStickerParentSelector ) {
  96.                     waitForElement( reviewStickerElementSelector, function() {
  97.                         $( reviewStickerParentSelector ).append( this );
  98.                     });
  99.                 }
  100.                 if( productRatingStarsParentSelector ) {
  101.                     waitForElement( productRatingStarsElementSelector, function() {
  102.                         $( productRatingStarsParentSelector ).append( this );
  103.                     });
  104.                 }
  105.                 if( productReviewsParentSelector ) {
  106.                     waitForElement( productReviewsElementSelector, function() {
  107.                         $( productReviewsParentSelector ).append( this );
  108.                     });
  109.                 }
  110.             };
  111.             window.onload = function() {
  112.                 const jqueryChecker = window.setInterval( function() {
  113.                     if( window.jQuery )
  114.                     {
  115.                         window.clearInterval( jqueryChecker );
  116.                         onJqueryLoaded( window.jQuery );
  117.                     }
  118.                 }, 100 );
  119.             };
  120.         })();
  121.     </script>
  122.     {# Trusted Shops jQuery Selector - End #}
  123. {% endblock %}