blob: 956d8e54a0288eaa4f78f1fa226ad6036e31be9d [file] [log] [blame]
Anand Doshida858cc2015-02-24 17:50:44 +05301{% macro product_image_square(website_image, css_class="") %}
Rushabh Mehta440650d2016-11-14 13:13:53 +05302<div class="product-image product-image-square
3 {% if not website_image -%} missing-image {%- endif %} {{ css_class }}"
4 {% if website_image -%}
5 style="background-image: url('{{ frappe.utils.quoted(website_image) | abs_url }}');"
6 {%- endif %}>
Anand Doshida858cc2015-02-24 17:50:44 +05307</div>
8{% endmacro %}
9
prssanna11eae6d2021-02-01 20:01:37 +053010{% macro product_image(website_image, css_class="product-image", alt="") %}
Shivam Mishra45a56282020-12-30 15:51:50 +053011 <div class="border text-center rounded {{ css_class }}" style="overflow: hidden;">
Shivam Mishraa0954e62020-08-07 14:34:54 +053012 <img itemprop="image" class="website-image h-100 w-100" alt="{{ alt }}" src="{{ frappe.utils.quoted(website_image or 'no-image.jpg') | abs_url }}">
prssannaeb0e5962020-12-24 11:40:33 +053013 </div>
Rushabh Mehta156ce602015-09-11 18:49:59 +053014{% endmacro %}
pratu16x760fe77c2017-02-13 21:52:43 +053015
16{% macro media_image(website_image, name, css_class="") %}
pratu16x70e94b4b2017-02-14 16:32:48 +053017 <div class="product-image sidebar-image-wrapper {{ css_class }}">
18 {% if not website_image -%}
19 <div class="sidebar-standard-image"> <div class="standard-image" style="background-color: rgb(250, 251, 252);">{{name}}</div> </div>
20 {%- endif %}
prssannaeb0e5962020-12-24 11:40:33 +053021 {% if website_image -%}
pratu16x760fe77c2017-02-13 21:52:43 +053022 <a href="{{ frappe.utils.quoted(website_image) }}">
pratu16x70e94b4b2017-02-14 16:32:48 +053023 <img itemprop="image" src="{{ frappe.utils.quoted(website_image) | abs_url }}"
24 class="img-responsive img-thumbnail sidebar-image" style="min-height:100%; min-width:100%;">
pratu16x760fe77c2017-02-13 21:52:43 +053025 </a>
prssannaeb0e5962020-12-24 11:40:33 +053026 {%- endif %}
27 </div>
pratu16x760fe77c2017-02-13 21:52:43 +053028{% endmacro %}
Faris Ansari5f8b3582019-03-19 11:48:32 +053029
30{% macro render_homepage_section(section) %}
31
32{% if section.section_based_on == 'Custom HTML' and section.section_html %}
33 {{ section.section_html }}
34{% elif section.section_based_on == 'Cards' %}
35<section class="container my-5">
36 <h3>{{ section.name }}</h3>
37
38 <div class="row">
39 {% for card in section.section_cards %}
40 <div class="col-md-{{ section.column_value }} mb-4">
41 <div class="card h-100 justify-content-between">
42 {% if card.image %}
Mohamed Almubarakf7ea3402021-01-28 10:02:13 +030043 <div class="website-image-lazy" data-class="card-img-top h-75" data-src="{{ card.image }}" data-alt="{{ card.title }}"></div>
Faris Ansari5f8b3582019-03-19 11:48:32 +053044 {% endif %}
45 <div class="card-body">
46 <h5 class="card-title">{{ card.title }}</h5>
47 <p class="card-subtitle mb-2 text-muted">{{ card.subtitle or '' }}</p>
Faris Ansarib8eaa3d2019-06-01 20:56:37 +053048 <p class="card-text">{{ card.content or '' | truncate(140, True) }}</p>
Faris Ansari5f8b3582019-03-19 11:48:32 +053049 </div>
50 <div class="card-body flex-grow-0">
51 <a href="{{ card.route }}" class="card-link">{{ _('More details') }}</a>
52 </div>
53 </div>
54 </div>
55 {% endfor %}
56 </div>
57</section>
58{% endif %}
59
prssannaeb0e5962020-12-24 11:40:33 +053060{% endmacro %}
61
marination897c08c2021-05-17 20:44:41 +053062{%- macro item_card(item, is_featured=False, is_full_width=False, align="Left") -%}
prssannaeb0e5962020-12-24 11:40:33 +053063{%- set align_items_class = resolve_class({
64 'align-items-end': align == 'Right',
65 'align-items-center': align == 'Center',
66 'align-items-start': align == 'Left',
67}) -%}
68{%- set col_size = 3 if is_full_width else 4 -%}
marination48b3ce82021-05-13 01:22:05 +053069{%- set title = item.web_item_name or item.item_name or item.item_code -%}
70{%- set title = title[:50] + "..." if title|len > 50 else title -%}
marination4f64d1c2021-03-11 21:24:47 +053071{%- set image = item.website_image or item.image -%}
72{%- set description = item.website_description or item.description-%}
73
prssannaeb0e5962020-12-24 11:40:33 +053074{% if is_featured %}
75<div class="col-sm-{{ col_size*2 }} item-card">
marinationb29c5d62021-05-25 01:35:22 +053076 <div class="card featured-item {{ align_items_class }}" style="height: 360px;">
prssannaeb0e5962020-12-24 11:40:33 +053077 {% if image %}
78 <div class="row no-gutters">
marinationb29c5d62021-05-25 01:35:22 +053079 <div class="col-md-5 ml-4">
prssannaeb0e5962020-12-24 11:40:33 +053080 <img class="card-img" src="{{ image }}" alt="{{ title }}">
81 </div>
82 <div class="col-md-6">
marination897c08c2021-05-17 20:44:41 +053083 {{ item_card_body(title, description, item, is_featured, align) }}
prssannaeb0e5962020-12-24 11:40:33 +053084 </div>
85 </div>
86 {% else %}
87 <div class="col-md-12">
marination897c08c2021-05-17 20:44:41 +053088 {{ item_card_body(title, description, item, is_featured, align) }}
prssannaeb0e5962020-12-24 11:40:33 +053089 </div>
90 {% endif %}
91 </div>
92</div>
93{% else %}
94<div class="col-sm-{{ col_size }} item-card">
marinationb29c5d62021-05-25 01:35:22 +053095 <div class="card {{ align_items_class }}" style="height: 360px;">
prssannaeb0e5962020-12-24 11:40:33 +053096 {% if image %}
marination16b9c8c2021-03-11 10:56:00 +053097 <div class="card-img-container">
marination4f64d1c2021-03-11 21:24:47 +053098 <a href="/{{ item.route or '#' }}" style="text-decoration: none;">
marination16b9c8c2021-03-11 10:56:00 +053099 <img class="card-img" src="{{ image }}" alt="{{ title }}">
100 </a>
101 </div>
prssannab00eb1b2021-01-20 17:52:54 +0530102 {% else %}
marination4f64d1c2021-03-11 21:24:47 +0530103 <a href="/{{ item.route or '#' }}" style="text-decoration: none;">
marination16b9c8c2021-03-11 10:56:00 +0530104 <div class="card-img-top no-image">
105 {{ frappe.utils.get_abbr(title) }}
106 </div>
107 </a>
prssannaeb0e5962020-12-24 11:40:33 +0530108 {% endif %}
marination897c08c2021-05-17 20:44:41 +0530109 {{ item_card_body(title, description, item, is_featured, align) }}
prssannaeb0e5962020-12-24 11:40:33 +0530110 </div>
111</div>
112{% endif %}
113{%- endmacro -%}
114
marination897c08c2021-05-17 20:44:41 +0530115{%- macro item_card_body(title, description, item, is_featured, align) -%}
prssannaeb0e5962020-12-24 11:40:33 +0530116{%- set align_class = resolve_class({
117 'text-right': align == 'Right',
118 'text-center': align == 'Center' and not is_featured,
119 'text-left': align == 'Left' or is_featured,
120}) -%}
marination16b9c8c2021-03-11 10:56:00 +0530121<div class="card-body {{ align_class }}" style="width:100%">
marinationb29c5d62021-05-25 01:35:22 +0530122 <div class="mt-4">
marination4f64d1c2021-03-11 21:24:47 +0530123 <a href="/{{ item.route or '#' }}">
marination48b3ce82021-05-13 01:22:05 +0530124 <div class="product-title">
125 {{ title or '' }}
marination48b3ce82021-05-13 01:22:05 +0530126 </div>
marination16b9c8c2021-03-11 10:56:00 +0530127 </a>
marination16b9c8c2021-03-11 10:56:00 +0530128 </div>
prssannaeb0e5962020-12-24 11:40:33 +0530129 {% if is_featured %}
marinationb29c5d62021-05-25 01:35:22 +0530130 <div class="product-description ellipsis text-muted" style="white-space: normal;">
131 {{ description or '' }}
132 </div>
marination60261852021-04-13 00:39:26 +0530133 {% else %}
134 <div class="product-category">{{ item.item_group or '' }}</div>
prssannaeb0e5962020-12-24 11:40:33 +0530135 {% endif %}
136</div>
Ankush Menat4551d7d2021-08-19 13:41:10 +0530137{%- endmacro -%}
marination59514402021-03-16 00:05:53 +0530138
139
140{%- macro wishlist_card(item, settings) %}
marinationaca3c8f2021-06-08 19:40:26 +0530141{%- set title = item.item_name or item.item_code -%}
142{%- set title = title[:50] + "..." if title|len > 50 else title -%}
marination60261852021-04-13 00:39:26 +0530143<div class="col-sm-3 wishlist-card">
marination24c89672021-06-08 22:14:20 +0530144 <div class="card text-center" style="height: 100%">
marinationaca3c8f2021-06-08 19:40:26 +0530145 <div class="card-img-container">
146 <a href="/{{ item.route or '#' }}" style="text-decoration: none;">
147 {% if item.image %}
marination59514402021-03-16 00:05:53 +0530148 <img class="card-img" src="{{ item.image }}" alt="{{ title }}">
marinationaca3c8f2021-06-08 19:40:26 +0530149 {% else %}
150 <div class="card-img-top no-image">
151 {{ frappe.utils.get_abbr(title) }}
152 </div>
153 {% endif %}
154 </a>
155 <div class="remove-wish" data-item-code="{{ item.item_code }}">
156 <span style="padding-bottom: 2px;">
157 <svg class="icon sm remove-wish-icon" style="margin-bottom: 4px; margin-left: 0.5px;">
158 <use class="close" href="#icon-close"></use>
159 </svg>
160 </span>
marination59514402021-03-16 00:05:53 +0530161 </div>
marinationaca3c8f2021-06-08 19:40:26 +0530162 </div>
marination59514402021-03-16 00:05:53 +0530163
164 {{ wishlist_card_body(item, settings) }}
marination59514402021-03-16 00:05:53 +0530165 </div>
166</div>
167{%- endmacro -%}
168
169{%- macro wishlist_card_body(item, settings) %}
marination25ffafa2021-03-22 16:17:59 +0530170<div class="card-body text-center" style="width: 100%;">
marination59514402021-03-16 00:05:53 +0530171 <div style="margin-top: 16px;">
172 <div class="product-title">{{ item.item_name or item.item_code or ''}}</div>
173 </div>
marination60261852021-04-13 00:39:26 +0530174 <div class="product-price">
175 {{ item.formatted_price or '' }}
176
177 {% if item.get("formatted_mrp") %}
178 <small class="ml-1 text-muted">
179 <s>{{ item.formatted_mrp }}</s>
180 </small>
181 <small class="ml-1" style="color: #F47A7A; font-weight: 500;">
182 {{ item.discount }} OFF
183 </small>
184 {% endif %}
185 </div>
marination59514402021-03-16 00:05:53 +0530186
187 {% if (item.available and settings.show_stock_availability) or (not settings.show_stock_availability) %}
marination60261852021-04-13 00:39:26 +0530188 <!-- Show move to cart button if in stock or if showing stock availability is disabled -->
189 <button data-item-code="{{ item.item_code}}" class="btn btn-add-to-cart w-100 wishlist-cart-not-added mt-2">
190 <span class="mr-2">
191 <svg class="icon icon-md">
192 <use href="#icon-assets"></use>
193 </svg>
194 </span>
195 {{ _("Move to Cart") }}
196 </button>
marination59514402021-03-16 00:05:53 +0530197 {% else %}
marination60261852021-04-13 00:39:26 +0530198 <div class="mt-4" style="color: #F47A7A; width: 100%;">
199 {{ _("Not in Stock") }}
200 </div>
marination59514402021-03-16 00:05:53 +0530201 {% endif %}
202</div>
203{%- endmacro -%}
marinationb15ff572021-03-25 11:52:50 +0530204
205{%- macro ratings_with_title(avg_rating, title, size, rating_header_class) -%}
206<div style="display: flex;">
207 <div class="rating">
208 {% for i in range(1,6) %}
209 {% set fill_class = 'star-click' if i <= avg_rating else '' %}
210 <svg class="icon icon-{{ size }} {{ fill_class }}">
211 <use href="#icon-star"></use>
212 </svg>
213 {% endfor %}
214 </div>
215 <p class="ml-4 {{ rating_header_class }}">
216 <span>{{ title }}</span>
217 </p>
218</div>
219{%- endmacro -%}
marinationc8423052021-04-07 23:49:04 +0530220
221{%- macro ratings_summary(reviews, reviews_per_rating, average_rating, average_whole_rating)-%}
222<!-- Ratings Summary -->
223<h2 class="reviews-header">
224 {{ _("Customer Ratings") }}
225</h2>
226
227{% if reviews %}
228 {% set rating_title = frappe.utils.cstr(average_rating) + " " + _("out of 5") %}
229 {{ ratings_with_title(average_whole_rating, rating_title, "lg", "rating-summary-title") }}
230{% endif %}
231
232<!-- Rating Progress Bars -->
233<div class="rating-progress-bar-section">
234 {% for percent in reviews_per_rating %}
235 <div class="mt-4 col-sm-4 small rating-bar-title">
236 {{ loop.index }} star
237 </div>
238 <div class="row">
239 <div class="col-md-7">
240 <div class="progress rating-progress-bar" title="{{ percent }} % of reviews are {{ loop.index }} star">
241 <div class="progress-bar" role="progressbar"
242 aria-valuenow="{{ percent }}"
243 aria-valuemin="0" aria-valuemax="100"
244 style="width: {{ percent }}%; background-color: var(--text-on-green);">
245 </div>
246 </div>
247 </div>
248 <div class="col-sm-1 small">
249 {{ percent }}%
250 </div>
251 </div>
252 {% endfor %}
253</div>
254{%- endmacro -%}
255
256{%- macro user_review(reviews)-%}
257<!-- User Reviews -->
258<div class="user-reviews">
259 {% for review in reviews %}
260 <div class="mb-3 review">
261 {{ ratings_with_title(review.rating, _(review.review_title), "md", "user-review-title") }}
262
263 <div class="review-signature">
264 <span class="reviewer">{{ _(review.customer) }}</span>
265 <span>{{ review.published_on }}</span>
266 </div>
267 <div class="product-description mb-4 mt-4">
268 <p>
269 {{ _(review.comment) }}
270 </p>
271 </div>
272 </div>
273 {% endfor %}
274</div>
275{%- endmacro -%}
marination1d949142021-04-20 21:54:52 +0530276
277{%- macro field_filter_section(filters)-%}
278{% for field_filter in filters %}
279 {%- set item_field = field_filter[0] %}
280 {%- set values = field_filter[1] %}
281 <div class="mb-4 filter-block pb-5">
282 <div class="filter-label mb-3">{{ item_field.label }}</div>
283
284 {% if values | len > 20 %}
285 <!-- show inline filter if values more than 20 -->
286 <input type="text" class="form-control form-control-sm mb-2 product-filter-filter"/>
287 {% endif %}
288
289 {% if values %}
290 <div class="filter-options">
291 {% for value in values %}
292 <div class="checkbox" data-value="{{ value }}">
293 <label for="{{value}}">
294 <input type="checkbox"
295 class="product-filter field-filter"
296 id="{{value}}"
297 data-filter-name="{{ item_field.fieldname }}"
marination24c89672021-06-08 22:14:20 +0530298 data-filter-value="{{ value }}"
299 style="width: 14px !important">
marination1d949142021-04-20 21:54:52 +0530300 <span class="label-area">{{ value }}</span>
301 </label>
302 </div>
303 {% endfor %}
304 </div>
305 {% else %}
306 <i class="text-muted">{{ _('No values') }}</i>
307 {% endif %}
308 </div>
309{% endfor %}
310{%- endmacro -%}
311
312{%- macro attribute_filter_section(filters)-%}
313{% for attribute in filters %}
314 <div class="mb-4 filter-block pb-5">
315 <div class="filter-label mb-3">{{ attribute.name}}</div>
316 {% if values | len > 20 %}
317 <!-- show inline filter if values more than 20 -->
318 <input type="text" class="form-control form-control-sm mb-2 product-filter-filter"/>
319 {% endif %}
320
321 {% if attribute.item_attribute_values %}
322 <div class="filter-options">
323 {% for attr_value in attribute.item_attribute_values %}
324 <div class="checkbox">
marination48b3ce82021-05-13 01:22:05 +0530325 <label data-value="{{ attr_value }}">
marination1d949142021-04-20 21:54:52 +0530326 <input type="checkbox"
327 class="product-filter attribute-filter"
328 id="{{attr_value.name}}"
329 data-attribute-name="{{ attribute.name }}"
330 data-attribute-value="{{ attr_value.attribute_value }}"
marination24c89672021-06-08 22:14:20 +0530331 style="width: 14px !important"
marination1d949142021-04-20 21:54:52 +0530332 {% if attr_value.checked %} checked {% endif %}>
333 <span class="label-area">{{ attr_value.attribute_value }}</span>
334 </label>
335 </div>
336 {% endfor %}
337 </div>
338 {% else %}
339 <i class="text-muted">{{ _('No values') }}</i>
340 {% endif %}
341 </div>
342{% endfor %}
343{%- endmacro -%}