Remove Jigoshop CSS
-
Sorry not having much joy here – tried this but not working?
Trying to remove Jigoshop eCommerce styles for custom theme. Can you advise where I’m going wrong?
//REMOVE JIGOSHOP CSS add_action('wp_head','jigo_remove_action', 10); function jigo_remove_action() { remove_action('wp_head', 'jigoshop.shop'); } remove_action('jigoshop.shop', 10);
-
Hi
You’re removing an action, which usually would be fine, but we’re using a class for it now – it would look more like:
add_action("wp_enqueue_scripts", function(){Styles::remove("jigoshop.shop");},100);The ‘100’ is there because you want to remove the style after it has been added.
I know this is a slight divergence from the approach that’s used in WordPress itself – but in matters of performance it’s a blast 🙂
Sorry still having problems getting this working…
The new version pulls in 5 separate stylesheets so I’d like to concatenate them in to one single for efficiency reasons.
Ok, so you’re basically trying to remove the .css files, and then add all of them again, but concatenated?
You’d need to do the above for each script you want to remove, so
Styles::remove([stylesheet name without the .css extension]);I’ve been trying to implement this and I really can’t seem to understand what exactly I’m supposed to be doing. I don’t understand the inner workings of WordPress or JigoShop and it seems a bit much to have to do all the required reading when before this was a toggle button.
What exactly should I be adding?
Which file? (My theme’s functions.php?)
Where in that file?Just so I’m clear: in JigoShop 1.x there was the option to disable JigoShop’s built-in CSS. I had that enabled. That option is missing. I need to turn of JigoShop’s CSS so my theme works properly.
From what I can tell the idea is to call JigoShop 2.x’s Styles helper (/src/Jigoshop/Helper/Styles.php ) and use its remove function to get rid of the relevant stylesheets.
However when I attempt to add something like this to the top of a theme’s functions.php file:
add_action("wp_enqueue_scripts", function(){Styles::remove("jigoshop.shop.list-css");},100);I get this:
Fatal error: Uncaught Error: Class 'Styles' not found in /var/www/foxbox/wp-content/themes/twentyfifteen/functions.php on line 3 ( ! ) Error: Class 'Styles' not found in /var/www/foxbox/wp-content/themes/twentyfifteen/functions.php on line 3
Perhaps I’m not supposed to put this code in the theme’s functions.php file?
Putting it at the bottom gets the same result as putting it at the top.
It’s kind of amazing that migrating hundreds of products and orders went smoothly but getting my old theme working is what’s keeping my shop closed. Strangely it also only shows five products per page, despite being set to show 30 in the JigoShop settings. Not sure what’s going on there but if that’s still a problem after fixing this one I’ll create a separate topic.
\Jigoshop\Helper\Styles, not just Styles 🙂
Right-o, well that changes the error into something more understandable 😀
So the code I was using looks like this:
add_action("wp_enqueue_scripts", function(){\Jigoshop\Helper\Styles::remove("jigoshop.shop.list-css");},100);As far as I can tell an additional argument after “jigoshop.shop.list-css” is optional. Styles.php disagrees!
Fatal error: Uncaught ArgumentCountError: Too few arguments to function Jigoshop\Helper\Styles::remove(), 1 passed in /var/www/foxbox/wp-content/themes/twentyfifteen/functions.php on line 3 and exactly 2 expected in /var/www/foxbox/wp-content/plugins/jigoshop-ecommerce/src/Jigoshop/Helper/Styles.php on line 88ArgumentCountError: Too few arguments to function Jigoshop\Helper\Styles::remove(), 1 passed in /var/www/foxbox/wp-content/themes/twentyfifteen/functions.php on line 3 and exactly 2 expected in /var/www/foxbox/wp-content/plugins/jigoshop-ecommerce/src/Jigoshop/Helper/Styles.php on line 88
However if I add a blank option it doesn’t crash:
add_action("wp_enqueue_scripts", function(){\Jigoshop\Helper\Styles::remove("jigoshop.shop.list-css","");},100);Except the format of the style to remove isn’t quite right. A bit of experimentation led to this:
add_action("wp_enqueue_scripts", function(){\Jigoshop\Helper\Styles::remove("jigoshop.shop.list","");},100); add_action("wp_enqueue_scripts", function(){\Jigoshop\Helper\Styles::remove("jigoshop.shop","");},100); add_action("wp_enqueue_scripts", function(){\Jigoshop\Helper\Styles::remove("jigoshop.shop.product","");},100); add_action("wp_enqueue_scripts", function(){\Jigoshop\Helper\Styles::remove("jigoshop.shop.related_products","");},100); add_action("wp_enqueue_scripts", function(){\Jigoshop\Helper\Styles::remove("jigoshop.shop.checkout","");},100); add_action("wp_enqueue_scripts", function(){\Jigoshop\Helper\Styles::remove("jigoshop.shop.cart","");},100);Added at the bottom of my theme’s functions.php file.
It looks like specifying the stylesheets is unnecessary.
add_action("wp_enqueue_scripts", function(){\Jigoshop\Helper\Styles::remove("jigoshop.shop","");},100);Seems to have the same effect.
However the style doesn’t apply like it used to because many elements have different classes.
E.g. the Add to cart button used to be:
class="button"
It’s now:
class="btn btn-primary btn-block"I’m guessing there’s no way to change that back so I don’t need to play “hunt the changes”?
Not really, sorry.
Right-o! Thanks for being honest with me 🙂
Removing the style this way also removes other CSS stuff JigoShop would normally load from its vendors directory:
wp-content/plugins/jigoshop-ecommerce/assets/css/vendors/Without the contents of select2.css various drop-down menus break quite spectacularly. Notable examples include the cart shipping calculator and the checkout.
I added the contents of select2.css to my theme’s style.css and this immediately fixed many of the issues I was having.
Several other CSS files in that folder may also be required depending on what your shop uses.
The topic ‘Remove Jigoshop CSS’ is closed to new replies.