Sign In

Latest Deals

document.addEventListener('DOMContentLoaded', function() {
    // Select all buttons that should trigger the coupon data population.
    // Replace '.your-coupon-button-class' with the actual CSS class you gave your button in Elementor.
    const couponButtons = document.querySelectorAll('.your-coupon-button-class'); 

    couponButtons.forEach(button => {
        button.addEventListener('click', function(event) {
            event.preventDefault(); // Prevents the button's default action (e.g., submitting the form prematurely)

            const card = this.closest('.coupon-card');
            if (card) {
                const data = card.querySelector('.coupon-data');
                const form = card.querySelector('form');

                if (data && form) {
                    // Pulling only the product title for testing
                    const productTitle = data.dataset.productTitle;
                    
                    // Assuming your Gravity Forms hidden field for the product title has the name "input_1"
                    // You must verify this in your Gravity Forms field settings.
                    const hiddenField = form.querySelector('input[name="input_1"]');
                    
                    if (hiddenField) {
                        hiddenField.value = productTitle;
                        console.log('Product title set to:', hiddenField.value); // For debugging: check the browser console
                    }
                }
            }
        });
    });
});

Thanks for your interest

Your Digital Loyalty Cards on the Way

Please fill out this form to sign up for the 256Local Newsletter 

Product has been added

No products in the cart.

Explore Food Items