Fix for dysfunctional WooCommerce dropdowns by dequeueing selectWoo styles/scripts
authorLaury GvR <laury@gaslightmedia.com>
Thu, 30 Nov 2017 16:47:06 +0000 (11:47 -0500)
committerLaury GvR <laury@gaslightmedia.com>
Thu, 30 Nov 2017 16:47:06 +0000 (11:47 -0500)
functions.php

index 4935ba2..5d751db 100755 (executable)
@@ -314,6 +314,27 @@ function custom_wc_checkout_fields( $fields ) {
 }
 add_filter( 'woocommerce_checkout_fields' , 'custom_wc_checkout_fields' );
 
+/*
+ * The action below is necessary to make select2 work, which is the script used
+ * for dropdown menus on the woocommerce checkout pages. Without it, any version
+ * between 3.2.0 and at least 3.2.5 will have unusable dropdowns on the checkout
+ * pages for iOS devices (iPad, iPhone). It still works fine on OSX (mac).
+ * 
+ * This will need to be included on every WooCommerce site until they fix it, if
+ * they ever do.
+ */
+add_action( 'wp_enqueue_scripts', 'agentwp_dequeue_stylesandscripts', 100 );
+
+function agentwp_dequeue_stylesandscripts() {
+    if ( class_exists( 'woocommerce' ) ) {
+        wp_dequeue_style( 'selectWoo' );
+        wp_deregister_style( 'selectWoo' );
+
+        wp_dequeue_script( 'selectWoo');
+        wp_deregister_script('selectWoo');
+
+   }
+}
 
 // Dissable captch if it has been solved once using session
 // safely start a session