Created
May 10, 2023 21:29
-
-
Save lukecav/b7a83c39d1577c3b8b8bcdbb1fa12b45 to your computer and use it in GitHub Desktop.
Change product tag on stock change in WooCommerce
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function action_woocommerce_low_stock( $wc_get_product ) { | |
// Product set tag id(s), multiple IDs can be added, separated by a comma | |
$wc_get_product->set_tag_ids( array( 'YOUR TAG ID' ) ); | |
// OPTIONAL: Set category ids | |
//$wc_get_product->set_category_ids( array( 39, 2 ) ); | |
// Save | |
$wc_get_product->save(); | |
} | |
add_action( 'woocommerce_low_stock', 'action_woocommerce_low_stock', 10, 1 ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
https://stackoverflow.com/questions/76219364/automatically-change-product-tag-on-stock-change-in-woocommerce