אנימשתמש בתבנית Woodmart ובProducts grid שלהם. אני רוצה שזה שהקוד יבדוק כל מוצר מה מוגדר…
- User
אנימשתמש בתבנית Woodmart ובProducts grid שלהם. אני רוצה שזה שהקוד יבדוק כל מוצר מה מוגדר בMETA BOX שלו שיציג את הVALUE. לאחר שהוא שולף שיציג את זה במקום 11111
document.addEventListener('DOMContentLoaded', function () { const productElements = document.querySelectorAll('.product-element-bottom');
productElements.forEach(function (element) { let childNode = element.firstChild; if (childNode.nodeType === Node.TEXT_NODE && childNode.nodeValue.trim() === "11111") { // Get the product ID const productId = element.closest('.product').getAttribute('data-product-id'); // Get the value from your meta box for this product const desiredValue = getMetaBoxValue(productId); // Replace getMetaBoxValue(productId) with your actual function or method to retrieve the meta box value for this product element.removeChild(childNode); if (desiredValue) { element.appendChild(document.createTextNode(desiredValue)); } else { element.appendChild(document.createTextNode('Meta box value not found')); } } });});
function getMetaBoxValue(productId) { // Implement your logic to retrieve the value from the meta box for this product // For example, you can use jQuery to fetch the value const metaBoxValue = jQuery('#product-brand-image-' + productId).val(); // Replace '#product-brand-image-' + productId with the actual selector for your meta box for this product return metaBoxValue !== undefined ? metaBoxValue : null; }
- Assistant