This plugin is to extends the WooCommerce Conditional Shipping and Payments plugin to allow conditional logic to be applied to the shipping and/or billing address line 1 & 2 fields to check if the do or do not contain specified strings.
This plugin was created with the intention of being an example/demo of how it would work and be added to the core plugin itself.
- PHP 7.4+
- WordPress 6.2+
- WooCommerce 8.2+.
- WooCommerce Conditional Shipping and Payments 2.0+
- Download the plugin release files.
- Add plugin.zip file to your site's plugin directory via FTP or Uploading the Plugin.
- Activate the plugin.
To use the new feature simple follow the same steps you would to add a global or product based restriction.
This is an example of how the plugin can be used to set a global restriction on a shipping method from being selected if a PO Box shipping address is entered.
- After logging in go to WooCommerce > Settings then the Restrictions tab.
- Under the Shipping Methods click the 'Add Restriction' button.
- Set the 'Short Description' explaining the restriction. In this example we would describe it as "PO Box shipping restriction"
- Set the 'Exclude Methods' to the shipping methods you would like excluded when the conditions are met.
- Set the Add Condition dropdown to 'Shipping Street Address'
- Set the condition to "contains" to search for our key word strings used in the shipping address line 1 and 2 checkout fields.
- Enter a list of keywords as a case insensitive string separated by pipe "|" that would meet the condition and trigger the restriction. In this case it would be a string of all the variations used to denote a PO Box.
- Example:
po box|p.o. box|p o box|post office box|p.o. box|p.o.b.|p.o. box no.|postbox|po box no.
- Example:
- Save the restriction.
This example will look at the shipping address an if any of the PO Box strings are using for the shipping address line 1 or 2, or billing address if used as shipping, it will exclude the shipping methods mentioned in the restriction.