Implementation Action: Out of stock
-
Hello everyone,
I have integrated this function out of necessity in your plugin and it works correctly, but I would prefer it to be available in the next updates, I am attaching the code of the changes I made:
display_expiry_fields()
'options' => array( '' => __( 'Nothing', 'product-expiry-for-woocommerce' ), 'draft' => __( 'Make it Draft', 'product-expiry-for-woocommerce' ), 'out' => __( 'Out of stock', 'woocommerce' ), ),
schedule_action()
elseif ($woo_expiry_action != '' && $woo_expiry_action == 'out') { // 1. Updating the stock quantity update_post_meta( $post_id, '_stock', 0); // 2. Updating the stock quantity update_post_meta( $post_id, '_stock_status', wc_clean( 'outofstock' ) ); // 3. Updating post term relationship wp_set_post_terms( $post_id, 'outofstock', 'product_visibility', true ); // And finally (optionally if needed) //wc_delete_product_transients( $post_id ); // Clear/refresh the variation cache }
Thank you.
Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
- The topic ‘Implementation Action: Out of stock’ is closed to new replies.