M
M
mikekostunin2020-11-22 11:36:12
WordPress
mikekostunin, 2020-11-22 11:36:12

Place a pre-order for all products that are out of stock woocommerce?

Hello! It is necessary to write a function for changing the status of the balance for all goods that are not available for pre-order, it is the function that is of interest, since the goods are automatically synchronized with 1s and therefore manual updating or advanced bulk edit is not suitable.
If possible, this should be done for certain categories. help plz!
There is such a code, but when updating the product there is a critical error, as if something is wrong in it)
I climbed everything, made some kind of Frankenstein from different pieces of code from different forums.

#ставим в предзаказ товары не в наличии
add_filter( 'woocommerce_product_stock_status_options', 'filter_function_name_9522' );
function filter_function_name_9522( $array ){
  global $product, $post;
  if (get_post_meta(get_the_ID(), '_stock_status', true) == 'outofstock') {
   set_stock_status('onbackorder');
  };

  return $array;
}


Thank you all in advance!

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question