Hi All,
I’m hoping someone can help!?
I’ve got an ACF Taxonomy called Custom Stock Status (custom_stock_status)
It pulls in from a WooCommerce Attribute (taxonomy) called Custom Stock Status (pa_custom-stock-status)
It has a value of Available to Order ( slug available-to-order )
My understanding is I can set that value doing something like:
$term_taxonomy_ids = wp_set_object_terms( $post->ID, 'available-to-order', 'custom_stock_status');
However, I can’t seem to get it to work.
The idea being when a products created, I can use the following code to preset the attribute:
add_action('save_post_product', 'initiate_product', 10, 3);
function initiate_product($postID, $post, $update) {
if (!$update) {
// $update is false if we're creating a new post
$term_taxonomy_ids = wp_set_object_terms( $post->ID, 'available-to-order', 'custom_stock_status');
}
}
Yet it doesn’t work. I’m clearly missing something obvious, so would be grateful of any pointers!
Many thanks