custom/plugins/CogiFreeProducts/src/Resources/views/storefront/page/checkout/cart/index.html.twig line 1

Open in your IDE?
  1. {% sw_extends '@Storefront/storefront/page/checkout/cart/index.html.twig' %}
  2. {% block page_checkout_cart_add_product_and_shipping %}
  3.     {% set extensionFreeProducts = page.extensions['CogiFreeProducts'] %}
  4.     {% set FreeProducts = extensionFreeProducts.get('FreeProducts') %}
  5.     {% set totalPrice = cart_product_prices(context, page.cart, config('CogiFreeProducts.config.cogiFreeProductsCartPriceWithoutPromotions'), config('CogiFreeProducts.config.cogiFreeProductsExcludeFreeShippingProducts')) %}
  6.     {% set break = false %}
  7.     {% set isManufacturerInCart = false %}
  8.     {% set manufacturerPrice = 0 %}
  9.     {% set customerHasFreeProduct = false %}
  10.     {% set isFreeProductInCart = false %}
  11.     {% if config('CogiFreeProducts.config.cogiFreeProductsOneProductPerCustomer') and (config('CogiFreeProducts.config.cogiFreeProductsAutoToCart') == false) %}
  12.         {% set isFreeProductInCart = false %}
  13.         {% for item in page.cart.lineItems %}
  14.             {% if item.extensions["FreeProduct"] %}
  15.                 {% set isFreeProductInCart = true %}
  16.             {% endif %}
  17.         {% endfor %}
  18.         {% if isFreeProductInCart %}
  19.             {% set message = 'CogiFreeProducts.cartInfoChangeFreeProduct'|trans %}
  20.             {% set messageTypeInfo = 'info' %}
  21.             {% sw_include "@Storefront/storefront/utilities/alert.html.twig" with { 'type': messageTypeInfo, 'content': message} %}
  22.         {% endif %}
  23.     {% endif %}
  24.     {% for freeProduct in FreeProducts %}
  25.         {% if freeProduct.manufacturerActive %}
  26.             {% set freeProductManufacturerNames = get_manufacturer_names(context ,freeProduct.productManufacturerIds) %}
  27.         {% endif %}
  28.         {% if freeProduct.categoryActive %}
  29.             {% set freeProductCategoryNames = get_category_names(context, freeProduct.categoryIds) %}
  30.         {% endif %}
  31.         {% for lineItem in page.cart.lineItems %}
  32.             {% for productManufacturerId in freeProduct.productManufacturerIds %}
  33.                 {% if lineItem.payload['manufacturerId'] == productManufacturerId and freeProduct.manufacturerActive %}
  34.                     {% set manufacturerPrice = manufacturerPrice + (lineItem.price.totalPrice * context.currency.factor) %}
  35.                 {% endif %}
  36.             {% endfor %}
  37.         {% endfor %}
  38.         {% if manufacturerPrice > totalPrice %}
  39.             {% set isManufacturerInCart = true %}
  40.         {% endif %}
  41.         {% set isCategoryInCart = false %}
  42.         {% set categoryPrice = 0 %}
  43.         {% for lineItem in page.cart.lineItems %}
  44.             {% for productCategoryId in freeProduct.categoryIds %}
  45.                 {% for categoryId in lineItem.payload['categoryIds'] %}
  46.                     {% if categoryId == productCategoryId and freeProduct.categoryActive %}
  47.                         {% set categoryPrice = categoryPrice + (lineItem.price.totalPrice * context.currency.factor) %}
  48.                     {% endif %}
  49.                 {% endfor %}
  50.             {% endfor %}
  51.         {% endfor %}
  52.         {% if categoryPrice > totalPrice %}
  53.             {% set isCategoryInCart = true %}
  54.         {% endif %}
  55.         {% set isSalesChannel = false %}
  56.         {% for salesChannelId in freeProduct.salesChannelIds %}
  57.             {% if context.salesChannel.id == salesChannelId %}
  58.                 {% set isSalesChannel = true %}
  59.             {% endif %}
  60.         {% endfor %}
  61.         {% if check_customer_has_free_product(context) and config('CogiFreeProducts.config.cogiFreeProductsOneProductPerCustomer') %}
  62.             {% set customerHasFreeProduct = true %}
  63.         {% endif %}
  64.         {% if isSalesChannel and (customerHasFreeProduct != true) and config('CogiFreeProducts.config.cogiFreeProductsCartHint') == false %}
  65.             {% if (freeProduct.cartPrice * context.currency.factor) > manufacturerPrice and break == false and freeProduct.manufacturerActive and isManufacturerInCart == false %}
  66.                 {% set message = 'CogiFreeProducts.cartInfoManufacturer'|trans({'%price%': ((freeProduct.cartPrice * context.currency.factor)|round(2, 'floor') - manufacturerPrice)|currency, '%manufacturerName%': freeProductManufacturerNames })|raw %}
  67.                 {% set messageTypeInfo = 'info' %}
  68.                 {% sw_include "@Storefront/storefront/utilities/alert.html.twig" with { 'type': messageTypeInfo, 'content': message} %}
  69.                 {% set break = true %}
  70.             {% elseif (freeProduct.cartPrice * context.currency.factor) > categoryPrice and break == false and freeProduct.categoryActive and isCategoryInCart == false %}
  71.                 {% set message = 'CogiFreeProducts.cartInfoCategory'|trans({'%price%': ((freeProduct.cartPrice * context.currency.factor)|round(2, 'floor') - categoryPrice)|currency, '%categoryName%': freeProductCategoryNames })|raw %}
  72.                 {% set messageTypeInfo = 'info' %}
  73.                 {% sw_include "@Storefront/storefront/utilities/alert.html.twig" with { 'type': messageTypeInfo, 'content': message} %}
  74.                 {% set break = true %}
  75.             {% elseif (freeProduct.cartPrice * context.currency.factor) > totalPrice and break == false %}
  76.                 {% set message = 'CogiFreeProducts.cartInfo'|trans({'%price%': ((freeProduct.cartPrice * context.currency.factor)|round(2, 'floor') - totalPrice)|currency })|raw %}
  77.                 {% set messageTypeInfo = 'info' %}
  78.                 {% sw_include "@Storefront/storefront/utilities/alert.html.twig" with { 'type': messageTypeInfo, 'content': message} %}
  79.                 {% set break = true %}
  80.             {% endif %}
  81.         {% endif %}
  82.         {% set isManufacturerInCart = false %}
  83.     {% endfor %}
  84.     {{ parent() }}
  85. {% endblock %}
  86. {% block page_checkout_cart_add_promotion %}
  87.     {% set isFreeProduct = false %}
  88.     {% set configPromoCode = config('CogiFreeProducts.config.cogiFreeProductsPromoCode') %}
  89.     {% if configPromoCode == false %}
  90.         {% for item in page.cart.lineItems %}
  91.             {% if item.extensions["FreeProduct"] %}
  92.                 {% set isFreeProduct = true %}
  93.             {% else %}
  94.                 {% set isFreeProduct = false %}
  95.             {% endif %}
  96.         {% endfor %}
  97.     {% endif %}
  98.     {% if isFreeProduct == false %}
  99.         {{ parent() }}
  100.     {% endif %}
  101. {% endblock %}
  102. {% block page_checkout_cart_action_proceed %}
  103.     {{ parent() }}
  104. {% endblock %}