Skip to content

Instantly share code, notes, and snippets.

@JeroenSormani
Last active August 2, 2017 19:52
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save JeroenSormani/917d73577cdf64cfce1abd3e98b5c60c to your computer and use it in GitHub Desktop.
Save JeroenSormani/917d73577cdf64cfce1abd3e98b5c60c to your computer and use it in GitHub Desktop.
advanced pricing bust cache user roles
<?php
// You can copy&paste the contents of the script to your (child) themes functions.php. I recommend doing it over FTP.
// Busts the cache for Advanced Pricing > User role based pricing rules
add_filter( 'woocommerce_get_variation_prices_hash', function( $hash, $product, $include_taxes ) {
$user = wp_get_current_user();
$hash['user_role'] = implode( ',', $user->roles );
return $hash;
}, 10, 3 );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment