Search
 
SCRIPT & CODE EXAMPLE
 

PHP

woo set_stock_quantity

$out_of_stock_staus = 'outofstock';

// 1. Updating the stock quantity
update_post_meta($product_id, '_stock', 0);

// 2. Updating the stock quantity
update_post_meta( $product_id, '_stock_status', wc_clean( $out_of_stock_staus ) );

// 3. Updating post term relationship
wp_set_post_terms( $product_id, 'outofstock', 'product_visibility', true );

// And finally (optionally if needed)
wc_delete_product_transients( $product_id ); // Clear/refresh the variation cache
Comment

PREVIOUS NEXT
Code Example
Php :: select max id laravel 
Php :: iteration in php 
Php :: yii2 postgresql connection 
Php :: php date from format 
Php :: print array items in php 
Php :: mpdf output 
Php :: php get first key of array 
Php :: how to add an custom error to validater error in laravel 
Php :: use auth automatic login on register 
Php :: php combine arrays 
Php :: php sort multi dimensional array 
Php :: php list directories 
Php :: laravel validation exact string length 
Php :: laravel ckeditor 
Php :: cloudflare country 
Php :: cake php 2.x joins 
Php :: php string underscore into camelcase 
Php :: ubuntu fopen failed to open stream: Permission denied 
Php :: symfony doctrine existing database 
Php :: how to go to another folder in php 
Php :: Theme and plugin editor in wp dashboard missing 
Php :: ajax get request in laravel 
Php :: crul in laravel 
Php :: static modal 
Php :: laravel clone row 
Php :: get featured image id wordpress 
Php :: wpdb num_rows 
Php :: php erase element from array 
Php :: carbon now 
Php :: run seeder in migration laravel 
ADD CONTENT
Topic
Content
Source link
Name
5+5 =