WooCommerce incorrect out of stock error on checkout

It took me a few hours, to debug the cause of an out of stock error for a Woocommerce site.

The product variation had stock available. When performing a checkout it cause an error that the product didn't have enough stock.

I finally figured out what causes this problem:

Woocommerce tries to reserve a product via the function
'reserve_stock_for_product' (woocommerce/src/Checkout/Helpers/ReserveStock.php)

This method joins several tables: wp_wc_reserved_stock and wp_post_meta.

In my case the tables had different storage engines. wc_reserved_stock had a INNODB storage engine. wp_post_meta was MyISAM.

This fails with this particular INSERT query. Because it cannot joins these tables in a single transaction.

So don't mix table engines!!

(Which happen when you migrate an old site to a new server with a different default storage enginge)

Adding Syntax Highlighting to WordPress

I Just added syntax highlighting to WordPress. As a development blog I must be able to show some descent code samples!

I tried the pugin wp-syntax http://wordpress.org/extend/plugins/wp-syntax/, but adding a <pre> element requires me to go to the code pane and editor the code there. (And make me type every special char like & as &)
With this syntax highlighting I'm not very happy because it places the highlighting above a black background.

Another highliger codesnippet-20 Is capable of editing in design time. I just need to place the code between:

Code text

You can even change the style setting in an options tab of Wordpres
To enable this, just:

There's just one problem... TinyMCE removes my spaces !! An using a style "white-space: pre" gives me to many newlines because the highlighting adds newlines....


Well I will look at this later.

Btw. I also found a DokuWiki syntax plugin for WordPress... That sounds promising, I use dokuwiki for my internal wiki, and this wiki contains a lot of code snippets!