reload shop page by script
-
I wrote a script in my functions.php that – depending on the state of a cookie – displays a text in my shops head:
// show missing consent warning on shop pages add_action( 'woocommerce_archive_description', 'RCB_Payment_Notice' ); function RCB_Payment_Notice() { // check consent only if RCB is running if( function_exists('wp_rcb_consent_given') ) { // PayPal if( wp_rcb_consent_given("http", "ts", ".paypal.com")['cookieOptIn'] ) { if( isset($_COOKIE['con_fail_pp'])) { unset($_COOKIE['con_fail_pp']); setcookie('con_fail_pp',false,-3600); } } else { if( !isset($_COOKIE['con_fail_pp'])) { setcookie('con_fail_pp',true); } echo '<p class="rcb_paymen_notice" id="RCB_PP">my notice goes here.</p>'; } // Stripe if ( wp_rcb_consent_given("http", "__stripe_sid", "*")['cookieOptIn'] ) { if( isset($_COOKIE['con_fail_stripe'])) { unset($_COOKIE['con_fail_stripe']); setcookie('con_fail_stripe',false,-3600); } } else { if( !isset($_COOKIE['con_fail_stripe'])) { setcookie('con_fail_stripe',true); } echo '<p class="rcb_paymen_notice" id="RCB_Stripe">another notice.</p>'; } } }
That works perfectly well, exept when I turn on WPSC. Looks like WPSC makes everything in woocommerce_archive_description static, so changes will not get displayed.
I played with the wp_cache_post_change function, but that does not work either.
if( $clear_cache && function_exists('wp_cache_post_change') ) { $GLOBALS["super_cache_enabled"]=1; global $post; wp_cache_post_change($post->ID); )
I could not find a wp_cache_page_change function, so I’m asking if anybody can help me out here. Right now I had to disable caching for my shop pages to make it work but that is not a viable solution.
So is there any way to tell WPSC to reload the shop page?
Thanks!
Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
- The topic ‘reload shop page by script’ is closed to new replies.