Skip to content
This repository has been archived by the owner on Sep 16, 2019. It is now read-only.

WooCommerce compatability #40

Closed
standardspace opened this issue May 7, 2014 · 4 comments
Closed

WooCommerce compatability #40

standardspace opened this issue May 7, 2014 · 4 comments

Comments

@standardspace
Copy link

Hi,
Apologies, this is plugin related so feel free to ignore.
Activating WooCommerce causes the off-canvas navigation to become unresponsive ie. Clicking on the burger icon no longer triggers the slide in.
Here's a screenshot from Chrome Dev Tools
screen shot 2014-05-07 at 16 22 23

Any ideas?

@olefredrik
Copy link
Owner

Hi,
This is most likely a jQuery issue. FoundationPress loads a newer version of jQuery (currently version 2.1.1) than the one that comes with WordPress.

This is the jQuery reference in when the WooCommerce plugin is disabled:
<script type='text/javascript' src='http://foundationpress/wp-content/themes/FoundationPress/js/jquery/dist/jquery.min.js'></script>

When you enable the plugin, the reference above is replaced with:
<script type='text/javascript' src='http://foundationpress/wp-includes/js/jquery/jquery.js'></script>

I am unsure of compatibility between WooCommerce and newer versions of jQuery. But if it is supported, I expect that there are ways in which you can limit what WooCommerce to do in relation to the enqueuing of scripts.

@standardspace
Copy link
Author

Thanks,
I've hacked the WooCommerce class-wc-frontend-scripts.php to remove the jQuery call and that seems to do the trick. Just need to come up with a better way of overriding now.

@tsmith0511
Copy link

What exactly did you edit in class-wc-frontend-scripts.php? I'm getting errors on the custom jquery I've added to my site when woocommerce is enabled. I've tried to load my custom scripts on all pages except for woocommerce pages but am having no luck:

function my_scripts() {
if ( !is_page( 'woocommerce' ) ) {
wp_enqueue_script( 'extra-js-header', get_stylesheet_directory_uri() . '/js/extra_header.js' , array( 'jquery' ), '1.0.0', false );
wp_enqueue_script( 'extra-js-footer', get_stylesheet_directory_uri() . '/js/extra_footer.js' , array( 'jquery' ), '1.0.0', true );
}
}
wp_enqueue_script('extra-js-header');
wp_enqueue_script('extra-js-footer');
add_action('wp_enqueue_scripts', 'my_scripts');

Do you either have a solution to this approach? Or can yo provide me the code you removed from class-wc-frontend-scripts.php or a better way of overriding it?

Thanks!

@zitrusblau
Copy link

Well, it's actually even simpler to be done.

WooCommerce does a version check in class-wc-frontend-scripts.php (function check_jquery()) whether the enqueued jquery core script is at least at version 1.8. If not, it uses the one shipped w/ woocommerce.

Now, to fix it just change the version on the script enqueuing part of your foundation theme, like in /library/enqueue-scripts.php and use the version string from /js/vendor/jquery.js (i.e. '2.1.1')

@olefredrik you should use those version strings anyway.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants