Files
season/sections/testimonials.liquid
T
2026-10-09 23:02:05 -06:00

372 lines
14 KiB
Plaintext

{% liquid
if section.settings.heading != blank
assign heading = section.settings.heading
else
assign heading = 'testimonials.heading' | t
endif
if section.settings.subheading != blank
assign subheading = section.settings.subheading
else
assign subheading = 'testimonials.subheading' | t
endif
%}
<section
class="testimonials full-width"
id="Testimonials-{{ section.id }}"
data-testimonials
data-cart-add-url="{{ routes.cart_add_url }}.js"
data-checkout-url="{{ routes.root_url }}checkout"
>
<img
class="testimonials__blob"
src="{{ 'testimonials-blob.avif' | asset_url }}"
alt=""
width="434"
height="486"
loading="lazy"
decoding="async"
>
<div class="testimonials__header">
<h2 class="testimonials__heading">{{ heading | escape }}</h2>
{% if subheading != blank %}
<p class="testimonials__subheading">{{ subheading | escape }}</p>
{% endif %}
</div>
{% if section.blocks.size > 0 %}
<div class="testimonials__stage">
<div class="testimonials__copy">
{% for block in section.blocks %}
<div
class="testimonials__slide"
data-slide
{{ block.shopify_attributes }}
{% unless forloop.first %}hidden{% endunless %}
>
<div class="testimonials__meta">
<div class="testimonials__stars" role="img" aria-label="{{ 'testimonials.rating' | t: rating: block.settings.rating }}">
{% for index in (1..5) %}
<span class="testimonials__star{% if index > block.settings.rating %} is-off{% endif %}" aria-hidden="true">
<svg width="15" height="15" viewBox="0 0 10 10" fill="none" xmlns="http://www.w3.org/2000/svg">
<path d="M7.69531 9.39111C7.62954 9.39136 7.56536 9.37086 7.51191 9.33251L5 7.51142L2.48809 9.33251C2.43442 9.37144 2.36977 9.39228 2.30347 9.39204C2.23718 9.3918 2.17268 9.37048 2.1193 9.33117C2.06592 9.29186 2.02642 9.23659 2.00652 9.17335C1.98662 9.11011 1.98735 9.04218 2.00859 8.97939L2.98828 6.07763L0.449219 4.33642C0.394221 4.29874 0.352712 4.24447 0.330756 4.18153C0.3088 4.11858 0.307549 4.05027 0.327184 3.98656C0.34682 3.92285 0.386313 3.86709 0.439895 3.82743C0.493476 3.78777 0.558336 3.76628 0.625 3.7661H3.75742L4.70273 0.856925C4.7231 0.794117 4.76283 0.739373 4.81624 0.700546C4.86964 0.66172 4.93397 0.640807 5 0.640807C5.06603 0.640807 5.13036 0.66172 5.18376 0.700546C5.23717 0.739373 5.2769 0.794117 5.29727 0.856925L6.24258 3.76708H9.375C9.44175 3.76705 9.50675 3.78839 9.56049 3.82797C9.61423 3.86756 9.65389 3.92331 9.67365 3.98707C9.69341 4.05082 9.69223 4.11923 9.6703 4.18227C9.64837 4.24531 9.60682 4.29967 9.55176 4.33739L7.01172 6.07763L7.99082 8.97861C8.00668 9.02557 8.01115 9.07564 8.00384 9.12467C7.99653 9.17371 7.97766 9.2203 7.94879 9.2606C7.91992 9.3009 7.88188 9.33375 7.8378 9.35644C7.79373 9.37913 7.74489 9.39102 7.69531 9.39111Z" fill="currentColor"/>
</svg>
</span>
{% endfor %}
</div>
{% if block.settings.author != blank %}
<p class="testimonials__author">{{ block.settings.author | escape }}</p>
{% endif %}
</div>
{% if block.settings.quote != blank %}
<p class="testimonials__quote">{{ block.settings.quote | escape }}</p>
{% endif %}
</div>
{% endfor %}
<div class="testimonials__nav">
<button class="testimonials__arrow" type="button" data-prev aria-label="{{ 'testimonials.previous' | t }}">
<span class="testimonials__arrow-icon" aria-hidden="true">
<svg width="20" height="20" viewBox="0 0 20 20" fill="none" xmlns="http://www.w3.org/2000/svg">
<path d="M4.375 9.53125L10 3.90625L15.625 9.53125M10 4.6875V16.0938" stroke="black" stroke-linecap="round" stroke-linejoin="round"/>
</svg>
</span>
</button>
<button class="testimonials__arrow" type="button" data-next aria-label="{{ 'testimonials.next' | t }}">
<span class="testimonials__arrow-icon testimonials__arrow-icon--next" aria-hidden="true">
<svg width="20" height="20" viewBox="0 0 20 20" fill="none" xmlns="http://www.w3.org/2000/svg">
<path d="M4.375 9.53125L10 3.90625L15.625 9.53125M10 4.6875V16.0938" stroke="black" stroke-linecap="round" stroke-linejoin="round"/>
</svg>
</span>
</button>
</div>
</div>
<div class="testimonials__products">
{% for block in section.blocks %}
{% liquid
assign slide_product = block.settings.product
assign variant = blank
assign card_image = blank
assign hover_image = blank
assign subtitle = blank
assign show_compare = false
if slide_product != blank
assign variant = slide_product.selected_or_first_available_variant
assign card_image = slide_product.featured_image
for image in slide_product.images offset: 1 limit: 1
assign hover_image = image
endfor
assign subtitle = slide_product.metafields.custom.subtitulo.value | default: slide_product.metafields.custom.subtitulo
if subtitle == blank
assign subtitle = slide_product.metafields.custom.subtitle.value | default: slide_product.metafields.custom.subtitle
endif
if subtitle == blank
assign subtitle = slide_product.metafields.custom.presentacion.value | default: slide_product.metafields.custom.presentacion
endif
if subtitle == blank and variant.title != 'Default Title'
assign subtitle = variant.title
endif
if variant.compare_at_price > variant.price
assign show_compare = true
endif
endif
%}
<div class="testimonials__product" data-product {% unless forloop.first %}hidden{% endunless %}>
{% if slide_product != blank %}
<div class="testimonials__media">
<a class="testimonials__media-link" href="{{ slide_product.url }}">
{% if card_image %}
{{
card_image
| image_url: width: 900
| image_tag:
alt: slide_product.title,
widths: '300, 450, 700, 900',
sizes: '(max-width: 1024px) 70px, 450px',
class: 'testimonials__image',
loading: 'lazy'
}}
{% endif %}
{% if hover_image != blank %}
{{
hover_image
| image_url: width: 900
| image_tag:
alt: '',
widths: '300, 450, 700, 900',
sizes: '(max-width: 1024px) 70px, 450px',
class: 'testimonials__image testimonials__image--hover',
loading: 'lazy'
}}
{% endif %}
</a>
{% if variant != blank %}
<form class="testimonials__actions testimonials__form" action="{{ routes.cart_add_url }}" method="post">
<input type="hidden" name="id" value="{{ variant.id }}">
<input type="hidden" name="quantity" value="1">
<button
class="testimonials__bag"
type="submit"
{% unless variant.available %}disabled{% endunless %}
aria-label="{{ 'testimonials.add_to_cart' | t: product: slide_product.title }}"
>
<img src="{{ 'testimonials-bag.svg' | asset_url }}" alt="" width="25" height="25"
loading="lazy"
decoding="async"
>
</button>
<button
class="testimonials__buy"
type="submit"
data-buy
{% unless variant.available %}disabled{% endunless %}
>
{% if variant.available %}
{{ 'testimonials.buy' | t }}
{% else %}
{{ 'testimonials.sold_out' | t }}
{% endif %}
</button>
</form>
{% endif %}
</div>
<div class="testimonials__info">
<a class="testimonials__title" href="{{ slide_product.url }}">{{ slide_product.title | escape }}</a>
{% if subtitle != blank %}
<p class="testimonials__subtitle">{{ subtitle | escape }}</p>
{% endif %}
<p class="testimonials__prices">
<span class="testimonials__price">{{ variant.price | money_without_trailing_zeros }}</span>
{% if show_compare %}
<s class="testimonials__compare">{{ variant.compare_at_price | money_without_trailing_zeros }}</s>
{% endif %}
</p>
</div>
{% endif %}
</div>
{% endfor %}
</div>
</div>
{% endif %}
</section>
{% javascript %}
(() => {
const setCartCount = (count) => {
const link = document.querySelector('.header__cart');
if (!link || count < 1) return;
let badge = link.querySelector('[data-cart-count]');
if (!badge) {
badge = document.createElement('span');
badge.className = 'absolute right-0 top-0 flex h-4 min-w-4 items-center justify-center rounded-full bg-brand-mint px-[3px] text-[10px] font-medium leading-none text-black';
badge.setAttribute('data-cart-count', '');
link.appendChild(badge);
}
badge.textContent = String(count);
};
const boot = (root) => {
if (root.dataset.ready === 'true') return;
root.dataset.ready = 'true';
const slides = [...root.querySelectorAll('[data-slide]')];
const products = [...root.querySelectorAll('[data-product]')];
const prev = root.querySelector('[data-prev]');
const next = root.querySelector('[data-next]');
let index = 0;
const paint = () => {
slides.forEach((slide, slideIndex) => {
slide.hidden = slideIndex !== index;
});
products.forEach((product, productIndex) => {
product.hidden = productIndex !== index;
});
if (prev) prev.disabled = index <= 0;
if (next) next.disabled = index >= slides.length - 1;
};
if (prev) {
prev.addEventListener('click', () => {
if (index <= 0) return;
index -= 1;
paint();
});
}
if (next) {
next.addEventListener('click', () => {
if (index >= slides.length - 1) return;
index += 1;
paint();
});
}
paint();
};
const bootAll = (scope) => {
scope.querySelectorAll('[data-testimonials]').forEach(boot);
};
bootAll(document);
document.addEventListener('shopify:section:load', (event) => {
bootAll(event.target);
});
if (!window.__seasonTestimonials) {
window.__seasonTestimonials = true;
document.addEventListener('submit', async (event) => {
const form = event.target;
if (!(form instanceof HTMLFormElement) || !form.classList.contains('testimonials__form')) return;
const root = form.closest('[data-testimonials]');
if (!root) return;
event.preventDefault();
const button = event.submitter;
if (button) button.disabled = true;
try {
const response = await fetch(root.dataset.cartAddUrl, {
method: 'POST',
headers: { 'Content-Type': 'application/json', Accept: 'application/json' },
body: JSON.stringify({
id: form.querySelector('[name="id"]').value,
quantity: 1,
}),
});
const data = await response.json();
if (response.ok) {
if (button && button.hasAttribute('data-buy') && root.dataset.checkoutUrl) {
window.location.href = root.dataset.checkoutUrl;
return;
}
const cart = await fetch('/cart.js').then((result) => result.json());
setCartCount(cart.item_count);
} else if (data.description) {
window.alert(data.description);
}
} catch (error) {
window.alert(error.message);
} finally {
if (button) button.disabled = false;
}
});
}
})();
{% endjavascript %}
{% schema %}
{
"name": "t:testimonials.name",
"tag": "section",
"class": "testimonials-section",
"disabled_on": {
"groups": ["header", "footer"]
},
"settings": [
{
"type": "text",
"id": "heading",
"label": "t:testimonials.heading",
"default": "Confianza que se construye con cada rutina"
},
{
"type": "text",
"id": "subheading",
"label": "t:testimonials.subheading",
"default": "+1,500 pieles ya encontraron su rutina Seasons"
}
],
"blocks": [
{
"type": "review",
"name": "t:testimonials.review",
"settings": [
{
"type": "textarea",
"id": "quote",
"label": "t:testimonials.quote",
"default": "Tengo piel sensible y atópica y es el único bloqueador que me cae bien, la sensación es increíble y he notado que se disminuyen súper rápido las marcas post acné, lo amo, la verdad 😌💕"
},
{
"type": "text",
"id": "author",
"label": "t:testimonials.author",
"default": "María José"
},
{
"type": "range",
"id": "rating",
"label": "t:testimonials.rating_label",
"min": 1,
"max": 5,
"step": 1,
"default": 5
},
{
"type": "product",
"id": "product",
"label": "t:testimonials.product"
}
]
}
],
"presets": [
{
"name": "t:testimonials.name",
"blocks": [
{ "type": "review" }
]
}
]
}
{% endschema %}