• Resolved alx359

    (@alx359)


    I’m using a Woocommerce feature named Quick View (QV), which opens single products from the product catalog in a modal window via Ajax.

    The QV feature isn’t being handled by PP out of the box, and other similar plugins I’ve tested so far (e.g. Flying Images, Statically). What’s mostly lacking are the phast-optimized images being referred in the HTML of the Ajax output, to avoid the browser fetching them again unoptimized during the QV of each product.

    Thanks to the kind addition of phastpress_optimize_snippet in 1.102. update, have managed to address the issue in PP. The code below targets YITH QuickView, but should work for other QV’s as well (also tested on QV of the Flatsome theme), as many seem to share the same pattern of loading their templates via Ajax.

    
    // added in functions.php
    // Inject custom hook to allow modifying the HTML content before Ajax output
    add_action( 'woocommerce_after_template_part', 'qv_after_template_part' ); 
    function qv_after_template_part( $template_name ) { 
        if( $template_name == 'yith-quick-view-content.php'           // YITH QV 
         || $template_name == 'content-single-product-lightbox.php' ) // Flatsome QV
    
            do_action('my_action_product_quick_view_ajax_html');
    }
    // Rewrite HTML content inside QV with optimizations
    add_action( 'my_action_product_quick_view_ajax_html', 'pp_qv_optimize' );
    function pp_qv_optimize() {
        if( !function_exists('phastpress_optimize_snippet') ) 
            return;
        
        // capture & clear QV's buffer, already containing the template data
        $buffer = ob_get_clean();
        // create a new QV buffer entry point, to be retrieved and cleared in QV itself
        ob_start();
        
        echo html_entity_decode( phastpress_optimize_snippet( $buffer ) );
        //error_log( var_export( ob_get_contents(), true ) );
    }
Viewing 2 replies - 1 through 2 (of 2 total)
  • Plugin Author Albert Peschar

    (@kiboit)

    Hi @alx359,

    Cool! I’ve added a fix for this to PhastPress 1.106.

    To make this more robust I’ve taken a slightly different approach and hook into the admin-ajax.php handling code, to add PhastPress’ output buffer handler in case the AJAX hook is in a list.

    So far, it’s only configured for YITH WooCommerce Quick View, but other AJAX endpoints can be added as well in future.

    –Albert

    Thread Starter alx359

    (@alx359)

    Hi Albert,
    That’s great. To confirm that all the added new functionality appears to be working fine my end. Thanks so much!

Viewing 2 replies - 1 through 2 (of 2 total)

The topic ‘[FIX] Quick View compatibility’ is closed to new replies.