wc_get_cart_item_data_hash()
Gets a hash of important product data that when changed should cause cart items to be invalidated.
The woocommerce_cart_item_data_to_validate filter can be used to add custom properties.
Hooks from the function
Return
String
.
Usage
wc_get_cart_item_data_hash( $product );
- $product(WC_Product) (required)
- Product object.
wc_get_cart_item_data_hash() wc get cart item data hash code WC 7.7.0
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 ) ) ); }