WordPress Codesnippets

woocommerce get all variation skus


This code is used to retrieve all the SKU numbers of product variations with a given product ID. It creates an array of arguments to be passed to the get_posts() WordPress function, which returns an array of product variation IDs which is then iterated through and the SKU numbers are retrieved with the get_post_meta() function and echoed.

Was this code snippet helpful?

Leave a Reply

Your email address will not be published. Required fields are marked *

Programmatically save post

This code creates a WordPress post with the values of the ‘post_title’ and ‘post_content’ variables. It sets the post status to ‘publish’ and the author

Read More »

Create order programmatically

This code creates a new post in the WordPress database with post type ‘shop_order’, post title ‘Order #12345’, post status ‘wc-processing’, and ping status ‘closed’.

Read More »