Answer the question
In order to leave comments, you need to log in
Why is product metadata not saved?
Hello everyone!
I want to massively change product descriptions, but the result of the update_post_meta execution is not written to the database.
What's wrong?
add_action('admin_init', 'replace_products');
function replace_products(){
$prod = wc_get_product('2425274161');
$id = $prod->get_id();
$description = $prod->get_description('edit');
$search_string = 'Субпродукты и рубец';
$new_description = str_replace($search_string, 'рубец', $description);
update_post_meta($id, 'description', $new_description, $description);
}
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question