woocommerce_store_api_cart_item_parent_item_key
Filter to declare the parent cart item of a cart line.
Only a non-empty string is kept; empty strings and other values become null. A key that names no line in the current cart, or the line's own key, also becomes null. A line with no declared parent counts as a standalone line. Callbacks that declare no parent for a line should return the value unchanged.
Использование
add_filter( 'woocommerce_store_api_cart_item_parent_item_key', 'wp_kama_woocommerce_store_api_cart_item_parent_key_filter', 10, 3 );
/**
* Function for `woocommerce_store_api_cart_item_parent_item_key` filter-hook.
*
* @param string|null $parent_item_key Initially null; may be a value returned by an earlier
* callback.
* @param array $cart_item The raw cart item.
* @param string $cart_item_key The cart item key.
*
* @return string|null
*/
function wp_kama_woocommerce_store_api_cart_item_parent_key_filter( $parent_item_key, $cart_item, $cart_item_key ){
// filter...
return $parent_item_key;
}
- $parent_item_key(строка|null)
- Initially null; may be a value returned by an earlier callback.
- $cart_item(массив)
- The raw cart item.
- $cart_item_key(строка)
- The cart item key.
Список изменений
| С версии 11.3.0 | Введена. |
Где вызывается хук
woocommerce_store_api_cart_item_parent_item_key
woocommerce/src/StoreApi/Schemas/V1/CartItemSchema.php 132
$parent_item_key = apply_filters( 'woocommerce_store_api_cart_item_parent_item_key', null, $cart_item, $cart_item['key'] );