1 回答

TA貢獻(xiàn)1798條經(jīng)驗(yàn) 獲得超7個(gè)贊
從 WooCommerce 3 開(kāi)始,要更改現(xiàn)有產(chǎn)品的產(chǎn)品類(lèi)型,您可以使用以下命令:
/**
?* 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();
- 1 回答
- 0 關(guān)注
- 157 瀏覽
添加回答
舉報(bào)