wc_get_cart_item_data_hash( WC_Product $product )
Gets a hash of important product data that when changed should cause cart items to be invalidated.
Description Description
The woocommerce_cart_item_data_to_validate filter can be used to add custom properties.
Parameters Parameters
- $product
-
(Required) Product object.
Return Return
(string)
Source Source
File: includes/wc-cart-functions.php
function wc_get_cart_item_data_hash( $product ) {
return md5(
wp_json_encode(
apply_filters(
'woocommerce_cart_item_data_to_validate',
array(
'type' => $product->get_type(),
'attributes' => 'variation' === $product->get_type() ? $product->get_variation_attributes() : '',
),
$product
)
)
);
}