How to Force a Plugin to Claim Compatibility with WooCommerce HPOS

If you want to try WooCommerce HPOS in your website and it says some plugins are incompatible with HPOS, then you should check those plugins’ code first.

First make sure their codes don’t contain “update_post_meta or get_post_meta for orders. (for products it is ok). If they have, it can cause a problem.

If you are sure that the incompatible plugin has nothing to do with HPOS and doesn’t affect order processing, then you can claim it is compatible – without modifying its source code.

Open your theme’s functions.php and place such a block there:

Continue reading “How to Force a Plugin to Claim Compatibility with WooCommerce HPOS”

How to Clean POSTMETA Data of Old Orders After Switching to WooCommerce HPOS

Old Order Deletion Illustration

As of today there is no official guide for this simple need. If you have old orders more than 1000, you are right if you want to get rid of old orders – just to fasten your website.

So i decided to write my own script and apply to my web store with 30K order history.

Step1: I activated HPOS in dual-mode (aka safe mode).

Step2: 1 day passed and i disabled legacy mode and kept HPOS only

Step3: 1 more day passed and i deleted the oldest 5 orders from wp_postmeta.

Step4: Everything looked good, and i did the same for all orders.

Warning: You should take a backup before applying this code:

Continue reading “How to Clean POSTMETA Data of Old Orders After Switching to WooCommerce HPOS”

Allow your root user to use SFTP with one simple change

In most of modern Sever providers such as DigitalOcean, Hetzner root users are not able to login to the server using SFTP.

Yes, adding MATCH USER vlock can solve the problem, but for an auth with password, not with public key.

To enable our root user to login to our server with public key, we just need to add this single line to our ssd_config.

Continue reading “Allow your root user to use SFTP with one simple change”

Unlock ChatGPT Plus with non-US bank cards

If you want to get ChatGPT Plus and get such errors like “Your card was declined. Please try a different card” or “try debit card” – then you might try this way below.

I am sure it is a temporary problem and OpenAI will solve the issue in the future.

But for now, to get chatgpt 4 the only way is getting PLUS plan, so the method can be useful for you.

As you noticed the payment is provided by Stripe +

Continue reading “Unlock ChatGPT Plus with non-US bank cards”

Allow SFTP root access to the Linux Server – just for your own IP address

If you want to access your Linux server using SFTP and a root user, by default it can be disabled. Due to security reasons most server-providers disable that by default.

So, you can enable it yourself. But as it is not secure, you need to add some restrictions.

Such as, adding this feature only for your own static IP.

So let’s do that. Open your server’s sshd_config file by using this command.

nano /etc/ssh/sshd_config

Under the line Subsystem sftp /usr/lib/openssh/sftp-server you can paste 3 new lines.

Here is how it should look like:

Subsystem sftp  /usr/lib/openssh/sftp-server
Match Address
PasswordAuthentication yes
PermitRootLogin yes

Replace with your own static IP address.

Then save and restart SSH by using

service ssh restart

That’s all. Now you can access to your server via SFTP, as a root user if you are connected to internet with your own static IP.

All other users will not be able to connect of course.

Set Incremental SKU-s to your WooCommerce products

When you have products with no SKU and you would like to set Incremental SKU numbers for them directly in the website – then this snippet will help you.

$base_sku = 100;
$args = array(
'post_type' => 'product',
'post_status' => 'publish',
'meta_query' => array(
'key' => '_sku',
'compare' => 'NOT EXISTS'
$query = new WP_Query($args);
while ($query->have_posts()) {
$product_id = get_the_ID();
$sku = $base_sku++;
update_post_meta($product_id, '_sku', "SK_".$sku);
die("DONE. You can remove this code from your website!");

That’s it. Now just run yourwebsitecom/?set_sku=1 once and done!

The code will create SK_100, SK_101, … SKU-s for your website.

If you want to create SKU-s for variation as well, we can improve our code and get this snippet below:

Continue reading “Set Incremental SKU-s to your WooCommerce products”

Rename existing WordPress Attachments files, titles

Rename wp media object

If you change your website name, or you have to change some strings in existing imagedata of your website, we need to do the following steps:

Step 1: Fetch all attachments

Step 2: Rename all corresponding uploaded files

Step 3: update attachment data so that new files would be recognized by WP

Step 4: Update title, description data as well.

Here is a snippet which implements all 4 steps above.

Continue reading “Rename existing WordPress Attachments files, titles”