Last year at WooThemes, we decided to create a small contest among WooThemes employees called “Blogging for Benjamin”. The aim was to write a blog post every single day during one month, and that was great! This year, Bryce and Barry decided to called it “Blogging for Hippo” (Hippo will be the mascot for the next WooCommerce main version). So, everyday I’ll be posting a new article, until december 24th, if I can
Here is a quick snippet that I wanted to do for a long time. The aim is to allow you to create custom URLs to access products page with a specific tab active. By default, when you access a product page, the “description tab” is active by default, but with this snippet you can open the reviews tab (for example) directly from the URL. Useful isn’t it?
To use is it, simply add the tab name after a #, for example: http://mysite.com/my-product-name#reviews
To be able to use this method, simply paste the following code in the file called functions.php in your theme folder:
And guess what? It works no matter the permalinks structure is
Here is the result:
In some cases, you can see that your wp_options table is growing too fast and is becoming huge because of WooCommerce. If so, you can see that the sql table is full of _wc_session_xxx and _wc_session_expires_xxx entries. These can happen because of two things:
- Cron tasks aren’t working on your site
- A bot is crawling your site and creates sessions on the fly
Hopefully, in the latest WooCommerce versions there’s a tool to delete these sessions:
But sometimes, the database is so big, that the process fails because of the PHP max execution time, or because of a lack of memory. In that case you can use the following MySQL query directly in phpMyAdmin:
DELETE FROM wp_options WHERE option_name LIKE '_wc_session_%' OR option_name LIKE '_wc_session_expires_%'
And finally, to avoid the wp_options to become so big, make sure that cron aren’t disabled on your site, to do so check if your install does NOT contain this line of code:
If so, remove it.
One last thing, if you want, you can add the following code to the .htaccess file to avoid bots to create sessions while crawling your site:
User-agent: * Disallow: /*add-to-cart=*
Just a quick post to let you know that I was interviewed by WPmarmite a few days ago. Pretty happy with the result, so thank you Alex for taking the time to asked me questions about WooThemes, WooCommerce and CodeCanyon!
You can view the video here.
WooCommerce Product Vendors is an awesome extension that adds to WooCommerce many features to help you create a whole marketplace like any Envato marketplaces (CodeCanyon, ThemeForest, GraphicRiver etc…), or Creative Market.
Today I’d like to share a little snippet that allows you to display vendors details within the “vendor” tab on the product page. By default the tab content is populated by vendor’s fields, but you can add more. For example to display the commission value use the following code:
Pretty easy right?
The final result: