Untitled

webwizards avatar
webwizards
Plain Text
09/13/2025 2:41 AM
1.7 KB
18
Indexable
Never
function b2bking_pdf_button_handler_script() {
    if (is_account_page() || (function_exists('is_woocommerce') && is_woocommerce())) {
        ?>
        <script type="text/javascript">
        jQuery(document).ready(function($) {
            $('body').off('click', '.b2bking_offer_download');
            
            $('body').on('click', '.b2bking_offer_download', function(e) {
                var clickedButton = $(this);
                var offerContainer = clickedButton.closest('.b2bking_myaccount_individual_offer_container');
                
                if (offerContainer.length) {
                    var offerTitleElement = offerContainer.find('.b2bking_myaccount_individual_offer_top');
                    
                    if (offerTitleElement.length) {
                        var offerTitle = offerTitleElement.text().trim();
                        
                        if (typeof window.b2bking_display_settings !== 'undefined') {
                            window.b2bking_display_settings.offer_details = 'Offer Details: ' + offerTitle
                        } else {
                            window.b2bking_display_settings = {
                                offer_details: 'Offer Details: ' + offerTitle
                            };
                        }
                    }
                }
                
                setTimeout(function() {
                    clickedButton.trigger('pdf_generation_ready');
                    
                    var offerId = clickedButton.val();
                    if (offerId) {
                        
                    }
                }, 50);
            });
        });
        </script>
        <?php
    }
}
add_action('wp_footer', 'b2bking_pdf_button_handler_script');
Editor is loading...
Leave a Comment