Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TH-183: Coupons with discount type of fixed are displayed as percentage #97

Merged
merged 4 commits into from
Dec 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions themes/aura/assets/cart.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,15 +39,18 @@ async function fetchCoupons() {
const discountText = document.querySelector('.discount-text');
const couponApplied = document.querySelector('.coupon-applied');
const totalPrice = document.querySelector('.item-total-price');
let couponType

if (totalPrice) {
totalPrice.innerText = coupons.total ? `${coupons.total} ${currencyCode}` : '';
}

if (coupons.coupon && coupons.discountedPrice) {
couponApplied.innerHTML = `<span>${CART_PAGE_CONTENT.coupon}: '${coupons.coupon.code}' [${coupons.coupon.value}%] </span>
couponType = coupons.coupon.type === 1 ? '%' : ` ${currencyCode}`;

couponApplied.innerHTML = `<span>${CART_PAGE_CONTENT.coupon}: '${coupons.coupon.code}' [${coupons.coupon.value}${couponType}] </span>
<ion-icon class="close-search" id="remove-coupon" name="close-outline"></ion-icon>`;
discount.innerText = coupons.discountedPrice + ' ' + currencyCode;
discount.innerText = `- ${coupons.discountedPrice} ${currencyCode}`;

const removeCouponElement = document.getElementById("remove-coupon");
if (removeCouponElement) {
Expand Down
7 changes: 5 additions & 2 deletions themes/harmony/assets/cart.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,15 +39,18 @@ async function fetchCoupons() {
const discountText = document.querySelector('.discount-text');
const couponApplied = document.querySelector('.coupon-applied');
const totalPrice = document.querySelector('.item-total-price');
let couponType

if (totalPrice) {
totalPrice.innerText = coupons.total ? `${coupons.total} ${currencyCode}` : '';
}

if (coupons.coupon && coupons.discountedPrice) {
couponApplied.innerHTML = `<span>${CART_PAGE_CONTENT.coupon}: '${coupons.coupon.code}' [${coupons.coupon.value}%] </span>
couponType = coupons.coupon.type === 1 ? '%' : ` ${currencyCode}`;

couponApplied.innerHTML = `<span>${CART_PAGE_CONTENT.coupon}: '${coupons.coupon.code}' [${coupons.coupon.value}${couponType}] </span>
<ion-icon class="close-search" id="remove-coupon" name="close-outline"></ion-icon>`;
discount.innerText = coupons.discountedPrice + ' ' + currencyCode;
discount.innerText = `- ${coupons.discountedPrice} ${currencyCode}`;

const removeCouponElement = document.getElementById("remove-coupon");
if (removeCouponElement) {
Expand Down
16 changes: 9 additions & 7 deletions themes/meraki/assets/cart.css
Original file line number Diff line number Diff line change
Expand Up @@ -247,11 +247,8 @@ body{
font-family:inherit;
border-radius:0;
border-radius:initial;
border:none;
width:auto;
width:initial;
background-color:#F1F1F1;
color:#A4A4A4;
flex-shrink:0;
}
.yc-cart .cart-table .summary-box #summary .coupon-wrapper .yc-btn-secondary .spinner{
Expand All @@ -267,15 +264,20 @@ body{
.yc-cart .cart-table .summary-box #summary .coupon-container{
display:flex;
justify-content:space-between;
padding:15px 24px 0;
padding:0 0 15px;
}
@media (min-width: 768px){
.yc-cart .cart-table .summary-box #summary .coupon-container{
padding:15px 20px 0;
}
}
.yc-cart .cart-table .summary-box #summary .discount-text{
font-weight:700;
font-size:14px;
}
.yc-cart .cart-table .summary-box #summary .discount-price{
font-size:15px;
font-weight:500;
font-size:14px;
font-weight:600;
}
.yc-cart .cart-table .summary-box #summary .coupon-applied{
display:flex;
Expand Down Expand Up @@ -338,7 +340,7 @@ body{
}
@media (min-width: 768px){
.yc-cart .cart-table .summary-box #summary .total-price-wrapper .total-items{
padding:15px 24px 20px 24px;
padding:15px 20px 20px;
}
}
.yc-cart .cart-table .summary-box #summary .total-price-wrapper .total-items *{
Expand Down
7 changes: 5 additions & 2 deletions themes/meraki/assets/cart.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,15 +39,18 @@ async function fetchCoupons() {
const discountText = document.querySelector('.discount-text');
const couponApplied = document.querySelector('.coupon-applied');
const totalPrice = document.querySelector('.item-total-price');
let couponType

if (totalPrice) {
totalPrice.innerText = coupons.total ? `${coupons.total} ${currencyCode}` : '';
}

if (coupons.coupon && coupons.discountedPrice) {
couponApplied.innerHTML = `<span>${CART_PAGE_CONTENT.coupon}: '${coupons.coupon.code}' [${coupons.coupon.value}%] </span>
couponType = coupons.coupon.type === 1 ? '%' : ` ${currencyCode}`;

couponApplied.innerHTML = `<span>${CART_PAGE_CONTENT.coupon}: '${coupons.coupon.code}' [${coupons.coupon.value}${couponType}] </span>
<ion-icon class="close-search" id="remove-coupon" name="close-outline"></ion-icon>`;
discount.innerText = coupons.discountedPrice + ' ' + currencyCode;
discount.innerText = `- ${coupons.discountedPrice} ${currencyCode}`;

const removeCouponElement = document.getElementById("remove-coupon");
if (removeCouponElement) {
Expand Down
6 changes: 3 additions & 3 deletions themes/meraki/sections/main-cart.liquid
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@
<div class='cell mobile-view'>
<div class="product-title">
<span class="product-name">{{ item.name }}</span>
<button
onclick="removeItem('{{ item.id }}', '{{ item.product_variant_id }}')"
<button
onclick="removeItem('{{ item.id }}', '{{ item.product_variant_id }}')"
class='yc-btn-close'
aria-label="close cart"
>
Expand Down Expand Up @@ -90,7 +90,7 @@
class='spinner hidden'
id='loading__coupon'
></span>
<span class="content">{{ 'cart.summary.checkout_cta' | t }}</span>
<span class="content">{{ 'cart.summary.promo_cta' | t }}</span>
</button>
</div>
<div class="coupon-applied"></div>
Expand Down
15 changes: 8 additions & 7 deletions themes/meraki/styles/cart.scss
Original file line number Diff line number Diff line change
Expand Up @@ -258,10 +258,7 @@ body {
.yc-btn-secondary {
font-family: inherit;
border-radius: unset;
border: none;
width: unset;
background-color: #F1F1F1;
color: #A4A4A4;
flex-shrink: 0;

.spinner {
Expand All @@ -280,7 +277,11 @@ body {
.coupon-container {
display: flex;
justify-content: space-between;
padding: 15px 24px 0;
padding: 0 0 15px;

@include breakpoint('md') {
padding: 15px 20px 0;
}
}

.discount-text {
Expand All @@ -289,8 +290,8 @@ body {
}

.discount-price {
font-size: 15px;
font-weight: 500;
font-size: 14px;
font-weight: 600;
}

.coupon-applied {
Expand Down Expand Up @@ -361,7 +362,7 @@ body {
padding: 0 0 26px 0;

@include breakpoint('md') {
padding: 15px 24px 20px 24px;
padding: 15px 20px 20px;
}

& * {
Expand Down