在您的问题中,我们不知道您所说的“GRAB”是什么意思……可能是如何设置(或如何获取)产品描述。
设置产品描述有多种方法。
1) 从产品 ID 使用 Wordpress wp_update_post();
wp_update_post( array('ID' => $product_id, 'post_content' => 'This is the <strong>product description</strong> content.') );
2) 从WC_Product 对象使用set_description() 方法
// Get the WC_Product Object instance (optional if needed)
$product = wc_get_product( $product_id );
// Set the description
$product->set_description('This is the <strong>product description</strong> content.');
$product->save(); // Save product data
GET产品描述有多种方法(如in this thread 所述)。
1) 从产品 ID,使用 Wordpress get_post() 函数:
$product_description = get_post( $product_id )->post_content;
2) 从WC_Product 对象使用get_description() 方法
// Get the WC_Product Object instance (optional if needed)
$product = wc_get_product( $product_id );
// Get the product description
$description = $product->get_description();