Spree::Product.only_deleted.map(&:really_destroy!)
Hacking
Software development articles
There are 125 posts filed in Hacking (this is page 6 of 25).
Analyze size webpacker bundle
Nice tool to analyze the size of your webpacker stuff.
https://github.com/aholachek/bundle-wizard
npx bundle-wizard www.example.com
Json file processing unix tool
When you to view/edit a large json file on the unix command line you can use the jq
tool
pkg install jq
It can be used to pretty-print json
jq . file.json
Or to perform queries on it. (https://stedolan.github.io/jq/manual/)
WooCommerce clean Orphaned variants
Find the orphaned variants
SELECT * FROM `wp_posts` o
LEFT OUTER JOIN `wp_posts` r
ON o.post_parent = r.ID
WHERE r.id IS null AND o.post_type = 'product_variation'
And delete them
DELETE o FROM `wp_posts` o
LEFT OUTER JOIN `wp_posts` r
ON o.post_parent = r.ID
WHERE r.id IS null AND o.post_type = 'product_variation'
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)