DiscountBadge
Domainİndirim göstergesi: yüzde ("20% off"), sabit tutar (para birimi ile) veya ücretsiz kargo.
20% off
₺50 off
Free shipping
<%- include('modules/domain/common/discount/DiscountBadge', { discountType: 'PERCENTAGE', discountValue: 20 }) %>
<%- include('modules/domain/common/discount/DiscountBadge', { discountType: 'FIXED', discountValue: 50, currency: 'TRY' }) %>
<%- include('modules/domain/common/discount/DiscountBadge', { discountType: 'FREE_SHIPPING', discountValue: 0 }) %>
10% off
10% off
10% off
<%- include('modules/domain/common/discount/DiscountBadge', { discountType: 'PERCENTAGE', discountValue: 10, size: 'sm' }) %>
<%- include('modules/domain/common/discount/DiscountBadge', { discountType: 'PERCENTAGE', discountValue: 10, size: 'md' }) %>
<%- include('modules/domain/common/discount/DiscountBadge', { discountType: 'PERCENTAGE', discountValue: 10, size: 'lg' }) %>
<%
var _type = (locals.discountType || '').toUpperCase();
var _value = locals.discountValue || 0;
var _currency = locals.currency || 'TRY';
var _size = locals.size || 'md';
var sizeClass = {
sm: 'text-xs px-1.5 py-0.5',
md: 'text-sm px-2 py-0.5',
lg: 'text-base px-2.5 py-1',
}[_size] || 'text-sm px-2 py-0.5';
var label;
if (_type === 'PERCENTAGE') {
label = _value + '% off';
} else if (_type === 'FIXED') {
var formatted = _value.toLocaleString('tr-TR', { style: 'currency', currency: _currency, maximumFractionDigits: 0 });
label = formatted + ' off';
} else {
label = 'Free shipping';
}
%>
<%= label %>