• Resolved cvokk

    (@cvokk)


    Hello,
    for a couple of hours now I am trying to integrate EML with WooCommerce.
    I am using variable product and there is a selector for variation image.

    From their code, the frame to select the image is opened like so:

    // If the media frame already exists, reopen it.
    if ( variable_image_frame ) {
    	variable_image_frame.uploader.uploader.param( 'post_id', setting_variation_image_id );
    	variable_image_frame.open();
    	return;
    } else {
    	wp.media.model.settings.post.id = setting_variation_image_id;
    }
    
    // Create the media frame.
    variable_image_frame = wp.media.frames.variable_image = wp.media({
    	// Set the title of the modal.
    	title: '<?php echo esc_js( __( 'Choose an image', 'woocommerce' ) ); ?>',
    	button: {
    		text: '<?php echo esc_js( __( 'Set variation image', 'woocommerce' ) ); ?>'
    	}
    });
    
    // When an image is selected, run a callback.
    variable_image_frame.on( 'select', function() {
    
    	attachment = variable_image_frame.state().get('selection').first().toJSON();
    
    	setting_variation_image.find( '.upload_image_id' ).val( attachment.id );
    	setting_variation_image.find( '.upload_image_button' ).addClass( 'remove' );
    	setting_variation_image.find( 'img' ).attr( 'src', attachment.url );
    
    	wp.media.model.settings.post.id = wp_media_post_id;
    });
    
    // Finally, open the modal.
    variable_image_frame.open();

    Similar code opens the media frame to select multiple images for the product, this frame is also without EML filters.
    As there may be hundreds of products and variations, the filters are necessary.

    Do you know how to alter the code to open the frame along with the EML filters? I see that in eml-media-uploader.js you extend AttachmentsBrowser but I guess the default media frame invoked by the wp.media() is using some other defaults and so far I wasn’t able to find out how to hook EML filters there.

    Please let me know if you have any advice on this.

    Thank you very much!

    Best regards
    Vit

    https://www.ads-software.com/plugins/enhanced-media-library/

Viewing 7 replies - 1 through 7 (of 7 total)
  • Plugin Author webbistro

    (@webbistro)

    Hello,

    Thank you for your question and information. I will definitely make EML compatible with WooCommerce, but I need a few days to check this and some other bugs (found by my clients and myself) for the new upgrade… I will let you know as soon as it works.

    Happy New Year!

    Nadia

    Thread Starter cvokk

    (@cvokk)

    Thanks!

    Happy New Year!

    Vit

    Thread Starter cvokk

    (@cvokk)

    Hi, is there any progress regarding this issue?
    How can I help?

    Regards
    Vit

    Plugin Author webbistro

    (@webbistro)

    Hello Vit,

    Sorry for delay.

    You have to change WooCommerce code somehow like this:

    // Create the media frame.
    variable_image_frame = wp.media.frames.variable_image = wp.media({
    	// Set the title of the modal.
    	title: '<?php echo esc_js( __( 'Choose an image', 'woocommerce' ) ); ?>',
    	button: {
    		text: '<?php echo esc_js( __( 'Set variation image', 'woocommerce' ) ); ?>'
    	},
    	states : [
    		new wp.media.controller.Library({
    			title: '<?php echo esc_js( __( 'Choose an image', 'woocommerce' ) ); ?>',
    			filterable :	'all'
    		})
    	]
    });

    Source: /wp-includes/js/media-views.js (for example line 1249, 1267).

    It would be nice also if you contacted WooCommerce developers. I can’t add this functionality via EML because I don’t want to change media popup settings of other plugins. Their developers may have reasons to not use filters. EML, by default, extends attachment filters if they are present in fact.

    Nadia

    Thread Starter cvokk

    (@cvokk)

    Perfect, it works now.
    Thank you!

    Vit

    Thread Starter cvokk

    (@cvokk)

    Also sent pull request with those changes on GitHub.

    Regards
    Vit

    Plugin Author webbistro

    (@webbistro)

    Thank you very much, Vit!

Viewing 7 replies - 1 through 7 (of 7 total)
  • The topic ‘WooCommerce integration’ is closed to new replies.