Полагаю, я видел похожий код, я новичок во всем и пытаюсь понять, как можно реализовать его и добавить в свой файл function.php. Код, который я видел, был приведен ниже, и я подумал, что можно использовать замену «переменная» на «внешняя», чтобы это работало для меня,
Код: Выделить всё
/**
* Change product type.
*
* @param int $product_id - The product id.
* @param string $new_product_type - The new product type
*/
// Get the correct product classname from the new product type
$product_classname = WC_Product_Factory::get_product_classname( $product_id, $new_product_type );
// Get the new product object from the correct classname
$new_product = new $product_classname( $product_id );
// Save product to database and sync caches
$new_product->save();
Может быть, объединить вышеизложенное с приведенным ниже :
Код: Выделить всё
function woo_set_type_function(){
$product_id = 18; //your product ID
wp_remove_object_terms( $product_id, 'simple', 'product_type' );
wp_set_object_terms( $product_id, 'external', 'product_type', true );
}
add_action('init', 'woo_set_type_function');
Подробнее здесь: https://stackoverflow.com/questions/793 ... -instead-o
Мобильная версия