Force popup to open again
-
Hi @waltmesser and @danieliser, thank you for your help and sorry for the delay. My question was this:
I’ve got a popup where users write a CP to see if they can buy in our store. In the confirmation I’ve a query to database, and in case they can buy a set a cookie by javascript, with CP value, and in case they can’t buy, I set this cookie value as NO. Then I refresh the page an show the user a message. The popup is controlled by a Session Cookie, pum-20.
What I need is that if user enters a CP invalid, and then, click again the Buy button (which triggers the popup), the popup shows again. But as in first time, it created the pum-20 cookie, the popup doesn’t open again.
So, how can I show the popup always, if you enter an invalid CP? Should I delete the cookie? How?
I’ve try jQuery(‘#pum-20’).trigger(‘pumSetCookie’); with no luck. My code is this:
add_filter('gform_confirmation_4', 'ch_courage_confirmation', 10, 4); function ch_courage_confirmation($confirmation, $form, $lead, $ajax) { global $wpdb; $user_count = $wpdb->get_var( "SELECT COUNT(*) FROM pz_z_cp WHERE cp_cp = '".$_POST['input_1']."'" ); //busca a la BBDD if (!session_id()) { session_start(); } if($user_count==0) { $confirmation = "You cannot buy"; $confirmation .= "<script> jQuery('#popmake-20').trigger('popmakeSetCookie'); document.cookie = 'PIZZA-CP=NO; path=/'; setTimeout(function () { jQuery('#popmake-20').popmake('close'); }, 500); window.location.href = window.location.href; </script>"; $_SESSION['comprar'] = "No"; }else{ $botiga = $wpdb->get_row( "SELECT * FROM pz_z_cp, pz_z_botigues WHERE pz_z_cp.botiga_cp = pz_z_botigues.id_bg AND pz_z_cp.cp_cp = ".$_POST['input_1'] ); $confirmation = "Gracias! Te atenderá tu tienda más cercana. Por favor haz tu pedido."; $confirmation .= "<script> jQuery('#popmake-20').trigger('popmakeSetCookie'); document.cookie = 'PIZZA-CP=".$_POST['input_1']."; path=/'; document.cookie = 'PIZZA-BOTIGA=".$botiga->name_bg."; path=/'; document.cookie = 'PIZZA-EMAIL=".$botiga->email_bg."; path=/'; jQuery(‘#pum-20’).trigger(‘pumSetCookie’); setTimeout(function () { jQuery('#popmake-20').popmake('close'); }, 500); window.location.href = window.location.href; </script>"; $_SESSION['comprar'] = "Si"; } // return the confirmation return $confirmation; }
If I enter a wrong CP, the popup doesn’t show again. Thank you for your help!
- The topic ‘Force popup to open again’ is closed to new replies.