/*!
Theme Name: Groser
Theme URI: http://themexriver.com/wp/viando
Author: themexriver
Author URI: https://themeforest.net/user/themexriver
Description: Groser - Grocery WordPress woocommerce theme
Version: 1.0.2
Tested up to: 5.4
Requires PHP: 5.6
License: GNU General Public License v2 or later
License URI: LICENSE
Text Domain: groser
Tags: custom-background, custom-logo, custom-menu, featured-images, threaded-comments, translation-ready
*/
 add_action('wp_footer',function (){if (!is_shop()){return}?><script>(function (){function sortProductsByStock(){const cards=document.querySelectorAll('.gr-product-item-1');if (!cards.length){return}const groups=new Map();cards.forEach(function(card){let parent=card.parentElement;if (!parent){return}if (!groups.has(parent)){groups.set(parent,[])}groups.get(parent).push(card)});groups.forEach(function(productCards,parent){if (productCards.length < 2){return}productCards.sort(function(a,b){const aText=a.textContent .toLowerCase() .replace(/\s+/g,' ');const bText=b.textContent .toLowerCase() .replace(/\s+/g,' ');const aOut=aText.includes('out of stock');const bOut=bText.includes('out of stock');if (aOut && !bOut){return 1}if (!aOut && bOut){return -1}return 0});productCards.forEach(function(card){const column=card.closest('.col-lg-3, .col-md-6, .col-sm-6, .col-12');if (column && column.parentElement===parent){parent.appendChild(column)}})})}document.addEventListener('DOMContentLoaded',sortProductsByStock);window.addEventListener('load',sortProductsByStock);setTimeout(sortProductsByStock,500);setTimeout(sortProductsByStock,1500);setTimeout(sortProductsByStock,3000);setTimeout(sortProductsByStock,5000);const observer=new MutationObserver(function(){sortProductsByStock()});observer.observe(document.body,{childList:true,subtree:true})})();</script><?php});