WordPress.org

Ready to get started?Download WordPress

Forums

WooCommerce - excelling eCommerce
[resolved] Replacing woocommerce lightbox (10 posts)

  1. despachotres
    Member
    Posted 1 year ago #

    Hi,

    I have another lightbox (foobox) plugin running in my sites, and woocommerce comes with it's own built-in lightbox functionallity.

    Is there a way to "override" the woocommerce's lightbox feature to use my plugin? (Disabling lightbox in woocommerce doesn't work for this purposes).

    Thanks.

    http://wordpress.org/extend/plugins/woocommerce/

  2. mikejolley
    Member
    Plugin Author

    Posted 1 year ago #

    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.

  3. despachotres
    Member
    Posted 1 year ago #

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

  4. Caroline
    Member
    Posted 1 year ago #

    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.

  5. Phil C
    Member
    Posted 1 year ago #

    Very nearly what I need!

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

  6. despachotres
    Member
    Posted 1 year ago #

    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.

  7. Phil C
    Member
    Posted 1 year ago #

    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.

  8. Phil C
    Member
    Posted 1 year ago #

    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' );
    }
  9. Phil C
    Member
    Posted 1 year ago #

    ...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' );
    }
  10. Phil C
    Member
    Posted 1 year ago #

    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 :)

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic