WordPress.org

Support

Support » Plugins and Hacks » WooCommerce » [Resolved] Replacing woocommerce lightbox

[Resolved] Replacing woocommerce lightbox

Viewing 9 replies - 1 through 9 (of 9 total)
  • Plugin Author Mike Jolley

    @mikejolley

    You need to first disable our lightbox and save settings and then add some JS code to your theme I believe, to trigger your custom lightbox when one of our images are clicked. You’ll need to check foobox docs to see how this is done and what code you need.

    Thanks. I’m in contact with FooBox team. Let’s see if we can address this issue.

    Tip for Despachotres:

    You can disable/replace the current (prettyphoto) lightbox in plugins/woocommerce/woocommerce.php by adjusting the lines following this line

    if ( $lightbox_en && ( is_product() || ( ! empty( $post->post_content ) && strstr( $post->post_content, '[product_page' ) ) ) ) {

    I know I know, don’t adjust the core code… In which case you can do the same thing using code in your theme’s functions.php.

    Very nearly what I need!

    Can anyone recommend what would need to be added to functions.php to disable prettyphoto?

    Hi @pipdlg,

    I have unchecked the “Enable Lightbox” in Woocommerce configuration (general settings page). Then, you have to target the images to show up with your lightbox plugin.

    In my case, with Foobox, in WordPress single install it just works after deactivating lightbox in Woocommerce. In multisite, I have to address the “.images” class for the plugin to catch it. This is something the developers of Foobox (http://getfoobox.com) addressed very fast.

    Hope it helps.

    Did a bit more digging and managed to piece together the following:

    add_action( 'wp_print_scripts', 'my_deregister_javascript', 100 );
    
    function my_deregister_javascript() {
    	wp_deregister_script( 'prettyPhoto' );
    	wp_deregister_script( 'prettyPhoto-init' );
    	wp_deregister_script( 'woocommerce_prettyPhoto_css' );
    }

    I think that’ll do it? not sure if there is anything else which needs deregistering.

    Just noticed that the last one should in fact be wp_deregister_style

    add_action( 'wp_print_scripts', 'my_deregister_javascript', 100 );
    
    function my_deregister_javascript() {
    	wp_deregister_script( 'prettyPhoto' );
    	wp_deregister_script( 'prettyPhoto-init' );
    	wp_deregister_style( 'woocommerce_prettyPhoto_css' );
    }

    …OK I think I’ve got it now!

    Please correct me if this is wrong?

    //DISABLE WOOCOMMERCE PRETTY PHOTO SCRIPTS
    add_action( 'wp_print_scripts', 'my_deregister_javascript', 100 );
    
    function my_deregister_javascript() {
    	wp_deregister_script( 'prettyPhoto' );
    	wp_deregister_script( 'prettyPhoto-init' );
    }
    
    //DISABLE WOOCOMMERCE PRETTY PHOTO STYLE
    add_action( 'wp_print_styles', 'my_deregister_styles', 100 );
    
    function my_deregister_styles() {
    	wp_deregister_style( 'woocommerce_prettyPhoto_css' );
    }

    Just noticed your reply @despachotres

    Did NOT realise there was an option to disable lightbox in the UI! That would haev saved me some time here.

    ha, thanks 🙂

Viewing 9 replies - 1 through 9 (of 9 total)
  • The topic ‘[Resolved] Replacing woocommerce lightbox’ is closed to new replies.
Skip to toolbar