Created
May 25, 2025 04:19
-
-
Save shameemreza/68356e67a98beb3e4c8773e9c173b241 to your computer and use it in GitHub Desktop.
Exempt product variations from object caching to fix variation selection buttons
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Exempt product variations from object caching to fix variation selection buttons | |
* | |
* This fixes an issue where variation buttons disappear when object caching is enabled | |
* on Pressable or any other hosting. | |
*/ | |
add_filter('advanced_post_cache_skip_for_post_type', 'oleomontreal_exempt_variations_from_cache', 10, 2); | |
function oleomontreal_exempt_variations_from_cache($return_me, $post_type) { | |
$exempted = array('product_variation'); | |
if (in_array($post_type, $exempted)) { | |
return true; | |
} | |
return $return_me; | |
} | |
// Additional exemption for product attributes taxonomy if needed | |
add_filter('advanced_post_cache_skip_for_taxonomy', 'oleomontreal_exempt_taxonomies_from_cache', 10, 2); | |
function oleomontreal_exempt_taxonomies_from_cache($return_me, $taxonomy) { | |
$exempted = array('product_cat', 'product_tag', 'pa_color', 'pa_size'); | |
if (in_array($taxonomy, $exempted)) { | |
return true; | |
} | |
return $return_me; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment