I have a site with a pop up regarding a post code its use the following code to generate that pop up
/**
* Get the popup_id
* & return
*/
function get_popup_id() {
return 359;
}
/**
* get popup content
*/
function get_popup_content() {
$popup = get_post(get_popup_id());
echo $popup->post_content;
}
/**
* get popup array
*/
function get_pop_array() {
$postcode_array = explode(",", get_field("postcode_array", get_popup_id()));
return $postcode_array;
}
/**
* Check if popup been set
*/
function check_to_see_if_postcode_is_correct() {
if ( isset($_POST["post-code"]) ) {
if ( in_array($_POST["post-code"], get_pop_array()) ) {
setcookie("ALLOWED_TO_ORDER", "YES", time() + (10 * 365 * 24 * 60 * 60));
wp_redirect("/");
}
if ( ! in_array($_POST["post-code"], get_pop_array()) ) {
setcookie("ALLOWED_TO_ORDER", "NO", time() + (10 * 365 * 24 * 60 * 60));
wp_redirect("/");
}
}
}
add_action("wp", "check_to_see_if_postcode_is_correct");
/**
* if they are allowed to order
* leave them.
* If they arent send to page
*/
function display_message_to_people_in_wrong_postcode() {
if (isset($_COOKIE["ALLOWED_TO_ORDER"])) {
if ($_COOKIE["ALLOWED_TO_ORDER"] == "NO") {
echo "<div class='postcode-message'>You aren't currently in our delivery area! <div id='show-popup-again'>Change your delivery location</div></div>";
}
if ($_COOKIE["ALLOWED_TO_ORDER"] == "YES") {
echo "<div class='postcode-message extra-postcode-padding'>We deliver to your area!! </div>";
}
}
}
// add_action("wp", "display_message_to_people_in_wrong_postcode");
/**
*
*/
function dont_allow_menu() {
if (isset($_COOKIE["ALLOWED_TO_ORDER"])) {
if ($_COOKIE["ALLOWED_TO_ORDER"] == "NO") {
if ( get_post_type() == "product" ) {
wp_redirect("/");
}
}
}
}
add_action("wp", "dont_allow_menu");
?>
I didn't create the code and the issue is that I cant seem to contact the orignal developer all that I need is for the message that is displayed in the header We deliver to your area!! or sorry we don't deliver to your area to appear in a pop up like the attached image wellI would prefer if it doesnt have a code that is correct that only then the pop appears saying sorry we don't deliver to your area any help greatly appreciated.
Jade