Automatically Apply Points at Checkout

If you have Points to Currency Conversion turned on, you might want to automatically apply all available points at checkout.

To do this, insert the following JavaScript snippet into your website header or footer. The script works both with block-based checkout and standard checkout.

<script>
function wpgAutoApplyPoints() {
    const observer = new MutationObserver(function(mutations) {
        const checkoutUIElement = document.querySelector('.wpgens-points-checkout-ui');
        
        if (checkoutUIElement) {
            const loyaltyButton = checkoutUIElement.querySelector('button.wpgens-loyalty-button');
            
            if (loyaltyButton) {
                setTimeout(() => {
                    if (!loyaltyButton.classList.contains('wpgens-loyalty-remove-discount-btn')) {
                        loyaltyButton.click();
                    }
                }, 200);
                
                observer.disconnect();
                return;
            }
        }
    });
    
    observer.observe(document.body, {
        childList: true,
        subtree: true
    });
    
    setTimeout(() => {
        observer.disconnect();
    }, 10000);
}
document.addEventListener('DOMContentLoaded', wpgAutoApplyPoints);
</script>
Browse our plugins

Lightweight WooCommerce plugins built for speed. No bloat, no frameworks -- just clean code that works.

View all plugins