Access WooCommerce Product Tabs Directly via URL

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

Simple right?

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:

woocommerce-enable-tab

Too many wc_sessions in WooCommerce?

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:

clear-wc-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:

define('DISABLE_WP_CRON', 'true');

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=*

WooCommerce Product Vendors: Display Vendor Details

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.

I have to admit I love that extension built by Hugh, one of my awesome fellows at WooThemes.

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:

product-vendors-fields

4 Million WooCommerce Downloads!

wooconf

As you know I work for WooThemes, the (awesome) company behind WooCommerce, as a full time support technician. And today is a great day because we hit 4 fucking million downloads! Wow! What a milestone right?

Joel wrote a nice post on WooThemes blog to explain how stats went crazy in just a matter of months. I really recommend you to have a look at that post, you will learn how WooCommerce became the most popular e-commerce in the world with about 18% of the marketshare.

Also, I’d like to tell you something. In november, WooThemes will be organizing the WooConf, a WooCommerce related event in San Francisco. And we offer a free ticket to attend this awesome event, including flight and accommodation. To enter the competition and win this free ticket, visit that page.

Still not using WooCommerce? Well, I guess it’s time to change!