Automattic\WooCommerce\Internal\ProductAttributesLookup
LookupDataStore::get_update_action()
Determine the type of action to perform depending on the received changeset.
Метод класса: LookupDataStore{}
Хуков нет.
Возвращает
int
. One of the ACTION_ constants.
Использование
// private - только в коде основоного (родительского) класса $result = $this->get_update_action( $changeset );
- $changeset(массив|null) (обязательный)
- The changeset received by on_product_changed.
Код LookupDataStore::get_update_action() LookupDataStore::get update action WC 8.1.1
private function get_update_action( $changeset ) { if ( is_null( $changeset ) ) { // No changeset at all means that the product is new. return self::ACTION_INSERT; } $keys = array_keys( $changeset ); // Order matters: // - The change with the most precedence is a change in catalog visibility // (which will result in all data being regenerated or deleted). // - Then a change in attributes (all data will be regenerated). // - And finally a change in stock status (existing data will be updated). // Thus these conditions must be checked in that same order. if ( in_array( 'catalog_visibility', $keys, true ) ) { $new_visibility = $changeset['catalog_visibility']; if ( $new_visibility === 'visible' || $new_visibility === 'catalog' ) { return self::ACTION_INSERT; } else { return self::ACTION_DELETE; } } if ( in_array( 'attributes', $keys, true ) ) { return self::ACTION_INSERT; } if ( array_intersect( $keys, array( 'stock_quantity', 'stock_status', 'manage_stock' ) ) ) { return self::ACTION_UPDATE_STOCK; } return self::ACTION_NONE; }