Skip to main content

Sepette Extra İndirim

Ürün extra indirim#

smarty
{if $P.NUMERIC1 && $P.IS_DISPLAY_PRODUCT == 0}
<div class="col-auto text-content text-center border border-round border-primary fw-semibold extra-format" data-extra="{$P.NUMERIC1}">
{capture assign=PRICE} <strong class="text-primary"><span class="cart-price">{vat price=($P.PRICE_SELL - ($P.PRICE_SELL * $P.NUMERIC1/100)) vat=$P.VAT}</span>{$P.CURRENCY}</strong>{/capture}
{{#extra_cart_desc#}|replace:'%DISCOUNT%':$P.NUMERIC1|replace:"%PRICE%":$PRICE}
</div>
{/if}
{foreach from=$SUB_LIST item=SUB name=variant}
<a id="{$SUB.TYPE_ID}"
...
...
...
data-callback="variantCallback">
<span>{$SUB.TYPE}</span>
</a>
{/foreach}

Varyanta göre indirimin güncellenmesi#

javascript
window["extraDiscount"]=function(el){
let item=el.closest(".product-item, #product-detail"),
dataEl=item.querySelector("[data-extra]"),
cartPriceEl=item.querySelector(".cart-price");
if (!dataEl) return false;
let productPrice=item.querySelector(".product-price"),
discountPercent=parseFloat(dataEl.getAttribute("data-extra")),
oldPrice=T.priceToFloat(productPrice.innerText),
cartPrice=oldPrice-(oldPrice*discountPercent*0.01);
cartPriceEl? cartPriceEl.innerText=T.format(cartPrice) :"";
}
window["variantCallback"]=function(el){
window["extraDiscount"](el)
}
tr.conf language file
extra_cart_desc="Sepette %%DISCOUNT% indirim %PRICE%"