WC_Meta_Box_Product_Data::persist_external_product_stock_data
Persist the stock data enforced by the external product class.
External product setters normalize stock values while the existing product data is read. The submitted values therefore match the in-memory values and are not detected as changes, leaving stale stock meta, lookup, and visibility data behind unless they are synchronized explicitly.
Метод класса: WC_Meta_Box_Product_Data{}
Хуков нет.
Возвращает
null. Ничего (null).
Использование
$result = WC_Meta_Box_Product_Data::persist_external_product_stock_data( $product ): void;
- $product(WC_Product) (обязательный)
- External product object.
Код WC_Meta_Box_Product_Data::persist_external_product_stock_data() WC Meta Box Product Data::persist external product stock data WC 11.3.0
private static function persist_external_product_stock_data( WC_Product $product ): void {
update_post_meta( $product->get_id(), '_manage_stock', 'no' );
update_post_meta( $product->get_id(), '_stock_status', ProductStockStatus::IN_STOCK );
update_post_meta( $product->get_id(), '_backorders', 'no' );
wp_remove_object_terms( $product->get_id(), ProductStockStatus::OUT_OF_STOCK, 'product_visibility' );
/**
* Product data store.
*
* @var WC_Data_Store $data_store
*/
$data_store = $product->get_data_store();
if ( $data_store->has_callable( 'refresh_product_lookup_table' ) ) {
// @phpstan-ignore-next-line method.notFound (Guarded by has_callable() and called via __call() on the underlying product data store instance.)
$data_store->refresh_product_lookup_table( $product->get_id() );
}
}