Disable Zip field during Checkout

Looking to turn off the zip code field which is required at the moment, during MarketPress checkout. Trying to make use of Paid Courses via CoursePress, and MarketPress. We have countries like Colombia which don’t use Zip codes, if there is any workaround to make the Zip code field not required it would be helpful.

  • Nithin
    • Support Wizard

    Hi CK Fusion,

    I’m checking with the developer regarding this, to see whether there is a quick solution to implement this in the plugin side. Will get back to you in this ticket, once I get a feedback from the developer with a workaround.

    Have a great weekend ahead. :slight_smile:

    Kind Regards,

    Nithin

  • Panos
    • SLS

    Hi there at CK Fusion ,

    Not sure how that would work as member doesn’t have set a country till checkout.

    If you are selling only courses, you could remove the zip field completely by adding the following snippet in a mu-plugin:

    add_filter( 'mp_checkout/address_fields_array', function( $address_fields, $type ){

    if ( 'billing' == $type ) {
    foreach ( $address_fields as $key => $address_field ) {
    if ( isset( $address_field['subfields'] ) ) {

    foreach ( $address_field['subfields'] as $subfield_key => $subfield ) {
    if ( isset( $subfield['name'] ) && 'billing[zip]' == $subfield['name'] ) {
    unset( $address_fields[$key]['subfields'][$subfield_key] );
    }
    }
    }
    }
    }

    return $address_fields;
    }, 20, 2 );

    If you don’t need address, then you could download the mu-plugin from here:

    https://gist.github.com/wpmudev-sls/df7cb49d1e258b50caf3ab8f0e1909da

    unzip file and upload it to your wp-content/mu-plugins folder (if it doesn’t exist you can simply create that folder). Then go to the Course product and set the Product Type to Virtual.

    In case you are not familiar with mu-plugins, you could read more about them here :

    https://premium.wpmudev.org/manuals/wpmu-manual-2/using-mu-plugins/

    Please let us know if these suggestions help or not :slight_smile:

    Kind regards!

  • CK Fusion
    • Flash Drive

    That worked perfectly. Worth noting that the item to upload into the mu-plugin folder is the actual PHP file inside the folder opened by the Zip file. I first tried to upload the whole folder to the mu-plugin directory and that didn’t work. Then I extracted the PHP file and uploaded that to the mu-plugin folder, and that did the trick.

    Thank you so much!

Thank NAME, for their help.

Let NAME know exactly why they deserved these points.

Gift a custom amount of points.