Shortcodes
Two shortcodes add the phone field anywhere on your site, with or without WooCommerce. They use the same settings as the checkout field: countries, location detection, number checking and accent color.
[smart_phone_ field]*#
Adds a phone field with the flag dropdown to any form (that you have integration with).
[smart_phone_field name="phone" label="Phone number" required="yes" country="us"]
When the form is sent, phone holds the full international number (for example +12015550123) and phone_country holds the two-letter country code. The second field is always named after the first, plus _country.
[smart_phone_field_ demo]*#
Shows a live demo that looks like the WooCommerce checkout field: a phone field plus the saved number, readable format, country, number type and whether the number is valid. It’s checked in the browser and by the server. Nothing typed into the demo is saved.
[smart_phone_field_demo]
Attributes#
Both shortcodes take the same attributes.
| Attribute | What it does | Default |
|---|---|---|
| name | The field’s name in the submitted form | phone (demo: nahnu_spf_demo_phone) |
| id | HTML id of the input | Empty |
| label | Label text | Phone number |
| value | Starting number | Empty |
| country | Two-letter starting country, such as gb | Detected location, then the store’s country |
| required | yes, true or 1 to make it required | no |
| placeholder | Placeholder text | Empty |
| class | Extra CSS classes | Empty |
| style | woocommerce for the WooCommerce checkout look, with the label inside the box | Empty (demo: woocommerce) |
In a theme or plugin#
Use the PHP functions instead: echo nahnu_spf_field( array( 'name' => 'phone' ) ); or echo nahnu_spf_demo();. See PHP Functions.
*Added spaces so shortcodes do not load