Restrict package by postal code

This topic contains 11 replies, has 2 voices, and was last updated by  Dany Bergeron 7 years, 9 months ago.

We have moved to a support ticketing system and our forums are now closed.

Open Support Ticket
  • Author
    Posts
  • #393561

    Dany Bergeron
    Expired Member
    Post count: 24

    Hi! I would like to add a validation javascript to limit a package for limited postal codes. As user add or modify paces, a validation on submit will verify postal codes for specific package. So, which element to get for the package radio button and the postal code input field?

    Thank you,

    #393718

    Stiofan O’Connor
    Site Admin
    Post count: 22956

    Hi Dany,

    I guess the best way to do it would be read the package ID and then add a validation to the map, we can add a warning message.

    If you give me an example and wp-admin details i will give you some example code.

    Thanks,

    Stiofan

    #397946

    Dany Bergeron
    Expired Member
    Post count: 24
    This reply has been marked as private.
    #398019

    Stiofan O’Connor
    Site Admin
    Post count: 22956

    Hi Dany,

    I have added the following code snippet:

    
    
    add_action('geodir_add_listing_geocode_js_vars','_my_post_code_limit');
    function _my_post_code_limit(){
      ?>
    	//console.log(jQuery("input[name=package_id]:checked").val());
    	if(jQuery("input[name=package_id]:checked").val()==9){
    	  
    	  var allowed_pc = ["G0E 1T0", "G0E 1L0", "G0E 2E0"];
    	  
    	  
    	  if(allowed_pc.indexOf(getZip) != -1){}
    	  else{
    		alert("Listing must be in one of the following zip codes: "+allowed_pc.toString());
    		return;//bail
    	  }
    	  
    	}
    	<?php
      
    }

    Thanks,

    Stiofan

    #398069

    Dany Bergeron
    Expired Member
    Post count: 24

    Hi! It just works fine when we click by example to set on the map (pop up if denied postal code). But when the post is submited, no pop up.

    #398081

    Stiofan O’Connor
    Site Admin
    Post count: 22956

    You could do something similar with the form submit, though you might be best adding it to the footer code, but it would be the same code used except on the forum submit hook.

    Stiofan

    #398088

    Dany Bergeron
    Expired Member
    Post count: 24

    Sorry, i’m new to customizing function and actions. Where do I find the documentation on the submit hook to apply the code?

    Thank you

    #398091

    Stiofan O’Connor
    Site Admin
    Post count: 22956

    Please check now.

    Stiofan

    #398095

    Dany Bergeron
    Expired Member
    Post count: 24

    Perfect!!!!!!

    #398097

    Dany Bergeron
    Expired Member
    Post count: 24

    The last modification is not in a code snippet? Where can I translate the alert message?
    Thank you

    #398098

    Stiofan O’Connor
    Site Admin
    Post count: 22956

    GD>Design>Scripts>footer script

    #398100

    Dany Bergeron
    Expired Member
    Post count: 24

    Yes! I found it just before your answer… thank you.

    Really perfect! 🙂

    PS: As you add category exclusion for price package, another way of price administration is to add requirement (as postal code or also cateogry required: a package could be cheaper if place offer some required avantage as a category) So maybe for future development, I suggest to let price packages to exclude or require some category or postal code…

Viewing 12 posts - 1 through 12 (of 12 total)

We have moved to a support ticketing system and our forums are now closed.

Open Support Ticket
20% Discount Offer
Hurry! Get your 20% discount before it expires. Get 20% Discount