Hello,
I am using the popup module for a popup in cart and checkout where customers have to enter their zip-code before they can access these pages. This because a zip code will automatically calculate shipping cost and make the checkout easier.
But i have noticed that expiry time for the cookie is set longer than woocommerce set cart sessions so if a user is to shop again the day after then no popup appear.
I have tried to remove cookie based on if a zip-code is filled in or not using below code, but with no luck, i guess it gets overwritten?
function remove_popup_cookie() {
if ( is_cart() || is_checkout() ) {
if ( isset( $_COOKIE['woodmart_popup-18535_1'] ) && empty( WC()->customer->get_shipping_postcode() ) ) {
unset( $_COOKIE['woodmart_popup-18535_1'] );
setcookie( 'woodmart_popup-18535_1', '', time() - 3600, COOKIEPATH, COOKIE_DOMAIN );
}
}
}
//add_action( 'init', 'remove_popup_cookie' );
Anyone having an idea for how i can force the popup to show up if no zip-code is registered, OR eventually not use cookie but hide the popup if zip-code is registered?
Brgds
Rune
-
This topic was modified 2 months, 1 week ago by
metuza.