Huge Holiday Sale Handmade Authentic Faceted Gems Earrings
require(['jquery', 'Magento_Customer/js/customer-data'], function($, customerData) {
const productGrid = $('#product-card-grid');
const sortBySelect = $('#sorter');
const dirInput = $('#sort-dir');
const arrowSpan = $('#sort-arrow');
const sortToggle = $('#sort-toggle');
const productCards = productGrid.children('.product-card').toArray();
function updateArrowClass(dir) {
sortToggle.removeClass('sort-asc sort-desc');
if (dir === 'asc') {
sortToggle.addClass('sort-asc');
arrowSpan.text('↑ ASC');
} else {
sortToggle.addClass('sort-desc');
arrowSpan.text('↓ DESC');
}
}
function sortProducts(sortBy, sortDir) {
productCards.sort(function(a, b) {
let aValue, bValue;
if (sortBy === 'name') {
aValue = $(a).find('.product-name').text().toLowerCase();
bValue = $(b).find('.product-name').text().toLowerCase();
return sortDir === 'asc' ? aValue.localeCompare(bValue) : bValue.localeCompare(aValue);
} else if (sortBy === 'price') {
const priceRegex = /\$([\d,\.]+)/;
aValue = $(a).find('.now-price').text().match(priceRegex);
bValue = $(b).find('.now-price').text().match(priceRegex);
aValue = aValue ? parseFloat(aValue[1].replace(/,/g, '')) : 0;
bValue = bValue ? parseFloat(bValue[1].replace(/,/g, '')) : 0;
return sortDir === 'asc' ? aValue - bValue : bValue - aValue;
} else {
return 0;
}
});
productGrid.empty();
productCards.forEach(card => productGrid.append(card));
}
sortBySelect.on('change', function() {
const sortBy = sortBySelect.val();
const dir = dirInput.val();
sortProducts(sortBy, dir);
});
sortToggle.on('click', function(e) {
e.preventDefault();
const newDir = dirInput.val() === 'asc' ? 'desc' : 'asc';
dirInput.val(newDir);
updateArrowClass(newDir);
const sortBy = sortBySelect.val();
sortProducts(sortBy, newDir);
});
updateArrowClass(dirInput.val());
$('.product-listing-wrapper').on('submit', '.ajax-add-to-cart', function(e) {
e.preventDefault();
e.stopPropagation();
const $form = $(this);
const formData = $form.serialize();
$.ajax({
url: 'https://www.easternserenity.com/checkout/cart/add/',
type: 'POST',
data: formData,
success: function(res) {
customerData.reload(['cart'], true);
alert('Product added to cart!');
},
error: function(xhr) {
alert('Failed to add product to cart');
console.error(xhr.responseText);
}
});
});
});
Customer Reviews
- NK571
prodImageContainers = document.querySelectorAll(".product-image-container-7830"); for (var i = 0; i < prodImageContainers.length; i++) { prodImageContainers[i].style.width = "78px"; } prodImageContainersWrappers = document.querySelectorAll( ".product-image-container-7830 span.product-image-wrapper" ); for (var i = 0; i < prodImageContainersWrappers.length; i++) { prodImageContainersWrappers[i].style.paddingBottom = "100%"; } Beautiful and even better than the picture. Won't be my last order. - MarDee
prodImageContainers = document.querySelectorAll(".product-image-container-4681"); for (var i = 0; i < prodImageContainers.length; i++) { prodImageContainers[i].style.width = "78px"; } prodImageContainersWrappers = document.querySelectorAll( ".product-image-container-4681 span.product-image-wrapper" ); for (var i = 0; i < prodImageContainersWrappers.length; i++) { prodImageContainersWrappers[i].style.paddingBottom = "100%"; } Lively and elegant blend of color. - CCR33
prodImageContainers = document.querySelectorAll(".product-image-container-8758"); for (var i = 0; i < prodImageContainers.length; i++) { prodImageContainers[i].style.width = "78px"; } prodImageContainersWrappers = document.querySelectorAll( ".product-image-container-8758 span.product-image-wrapper" ); for (var i = 0; i < prodImageContainersWrappers.length; i++) { prodImageContainersWrappers[i].style.paddingBottom = "100%"; } Great size and price with a lot of choices for Christmas gifts. - ml
prodImageContainers = document.querySelectorAll(".product-image-container-10301"); for (var i = 0; i < prodImageContainers.length; i++) { prodImageContainers[i].style.width = "78px"; } prodImageContainersWrappers = document.querySelectorAll( ".product-image-container-10301 span.product-image-wrapper" ); for (var i = 0; i < prodImageContainersWrappers.length; i++) { prodImageContainersWrappers[i].style.paddingBottom = "100%"; } nice silver, smaller than expected... View morenice silver, smaller than expected - BSull
prodImageContainers = document.querySelectorAll(".product-image-container-11729"); for (var i = 0; i < prodImageContainers.length; i++) { prodImageContainers[i].style.width = "78px"; } prodImageContainersWrappers = document.querySelectorAll( ".product-image-container-11729 span.product-image-wrapper" ); for (var i = 0; i < prodImageContainersWrappers.length; i++) { prodImageContainersWrappers[i].style.paddingBottom = "100%"; } Cute, well-made, for a good price... View moreCute, well-made, for a good price. - Adrianne M.
prodImageContainers = document.querySelectorAll(".product-image-container-6779"); for (var i = 0; i < prodImageContainers.length; i++) { prodImageContainers[i].style.width = "78px"; } prodImageContainersWrappers = document.querySelectorAll( ".product-image-container-6779 span.product-image-wrapper" ); for (var i = 0; i < prodImageContainersWrappers.length; i++) { prodImageContainersWrappers[i].style.paddingBottom = "100%"; } I was looking for a chain alternative for my pendants and this fit the bill perfectly. It's a great... View moreI was looking for a chain alternative for my pendants and this fit the bill perfectly. It's a great length, the clasp is solid and it looks great with whatever pendant I wear it with. Thank you Eastern Serenity! - Adrianne M.
prodImageContainers = document.querySelectorAll(".product-image-container-8058"); for (var i = 0; i < prodImageContainers.length; i++) { prodImageContainers[i].style.width = "78px"; } prodImageContainersWrappers = document.querySelectorAll( ".product-image-container-8058 span.product-image-wrapper" ); for (var i = 0; i < prodImageContainersWrappers.length; i++) { prodImageContainersWrappers[i].style.paddingBottom = "100%"; } I ordered the silver silklook cord and it is simply stunning. It is beautiful and soft to look at, ... View moreI ordered the silver silklook cord and it is simply stunning. It is beautiful and soft to look at, lending itself to day and evening wear. I'm very happy I made this purchase. - Adrianne M.
prodImageContainers = document.querySelectorAll(".product-image-container-2047"); for (var i = 0; i < prodImageContainers.length; i++) { prodImageContainers[i].style.width = "78px"; } prodImageContainersWrappers = document.querySelectorAll( ".product-image-container-2047 span.product-image-wrapper" ); for (var i = 0; i < prodImageContainersWrappers.length; i++) { prodImageContainersWrappers[i].style.paddingBottom = "100%"; } This was much more striking in person than on the screen. I can wear it with or without a pendant ... View moreThis was much more striking in person than on the screen. I can wear it with or without a pendant and it's still beautiful. - Sunshine
prodImageContainers = document.querySelectorAll(".product-image-container-4645"); for (var i = 0; i < prodImageContainers.length; i++) { prodImageContainers[i].style.width = "78px"; } prodImageContainersWrappers = document.querySelectorAll( ".product-image-container-4645 span.product-image-wrapper" ); for (var i = 0; i < prodImageContainersWrappers.length; i++) { prodImageContainersWrappers[i].style.paddingBottom = "100%"; } These earrings are really beautiful... View moreThese earrings are really beautiful!!! - Northeast
prodImageContainers = document.querySelectorAll(".product-image-container-11744"); for (var i = 0; i < prodImageContainers.length; i++) { prodImageContainers[i].style.width = "78px"; } prodImageContainersWrappers = document.querySelectorAll( ".product-image-container-11744 span.product-image-wrapper" ); for (var i = 0; i < prodImageContainersWrappers.length; i++) { prodImageContainersWrappers[i].style.paddingBottom = "100%"; } Beautiful ring! I'll probably buy more companion pieces. Very happy... View moreBeautiful ring! I'll probably buy more companion pieces. Very happy.+ - SDi
prodImageContainers = document.querySelectorAll(".product-image-container-11002"); for (var i = 0; i < prodImageContainers.length; i++) { prodImageContainers[i].style.width = "78px"; } prodImageContainersWrappers = document.querySelectorAll( ".product-image-container-11002 span.product-image-wrapper" ); for (var i = 0; i < prodImageContainersWrappers.length; i++) { prodImageContainersWrappers[i].style.paddingBottom = "100%"; } I really love my jumpsuit. Can’t wait to wear it. - JVish
prodImageContainers = document.querySelectorAll(".product-image-container-4131"); for (var i = 0; i < prodImageContainers.length; i++) { prodImageContainers[i].style.width = "78px"; } prodImageContainersWrappers = document.querySelectorAll( ".product-image-container-4131 span.product-image-wrapper" ); for (var i = 0; i < prodImageContainersWrappers.length; i++) { prodImageContainersWrappers[i].style.paddingBottom = "100%"; } I ordered this and a few other items. It took a while, but worth the wait. Meanwhile, I received a... View moreI ordered this and a few other items. It took a while, but worth the wait. Meanwhile, I received a thank you note and apology from your team. What a pleasant surprise of a business you all are! Your clothing is delightful! Thank you for your thoughtfulness and consideration. I plan to order again. JV