WordPress как на ладони
Недорогой хостинг для сайтов на WordPress: wordpress.jino.ru
функция не описана

WC_Product_Variable_Data_Store_CPT::sync_managed_variation_stock_status() public WC 3.0.0

Stock managed at the parent level - update children being managed by this product. This sync function syncs downwards (from parent to child) when the variable product is saved.

{} Это метод класса: WC_Product_Variable_Data_Store_CPT{}

Хуков нет.

Возвращает

Null. Ничего.

Использование

$WC_Product_Variable_Data_Store_CPT = new WC_Product_Variable_Data_Store_CPT();
$WC_Product_Variable_Data_Store_CPT->sync_managed_variation_stock_status( $product );
$product(WC_Product) (обязательный) (передается по ссылке — &)
Product object.

Список изменений

С версии 3.0.0 Введена.

Код WC_Product_Variable_Data_Store_CPT::sync_managed_variation_stock_status() WC 4.7.0

<?php
public function sync_managed_variation_stock_status( &$product ) {
	global $wpdb;

	if ( $product->get_manage_stock() ) {
		$children = $product->get_children();
		$changed  = false;

		if ( $children ) {
			$status           = $product->get_stock_status();
			$format           = array_fill( 0, count( $children ), '%d' );
			$query_in         = '(' . implode( ',', $format ) . ')';
			$managed_children = array_unique( $wpdb->get_col( $wpdb->prepare( "SELECT post_id FROM $wpdb->postmeta WHERE meta_key = '_manage_stock' AND meta_value != 'yes' AND post_id IN {$query_in}", $children ) ) ); // @codingStandardsIgnoreLine.
			foreach ( $managed_children as $managed_child ) {
				if ( update_post_meta( $managed_child, '_stock_status', $status ) ) {
					$this->update_lookup_table( $managed_child, 'wc_product_meta_lookup' );
					$changed = true;
				}
			}
		}

		if ( $changed ) {
			$children = $this->read_children( $product, true );
			$product->set_children( $children['all'] );
			$product->set_visible_children( $children['visible'] );
		}
	}
}