| 1 |
<?php |
| 2 |
/** |
| 3 |
* Functions |
| 4 |
* |
| 5 |
* @package AutomatorWP\Integrations\WooCommerce\Functions |
| 6 |
* @author AutomatorWP <[email protected]>, Ruben Garcia <[email protected]> |
| 7 |
* @since 1.0.0 |
| 8 |
*/ |
| 9 |
// Exit if accessed directly |
| 10 |
if( !defined( 'ABSPATH' ) ) exit; |
| 11 |
|
| 12 |
/** |
| 13 |
* Helper function to get the address fields |
| 14 |
* |
| 15 |
* @since 1.0.0 |
| 16 |
* |
| 17 |
* @return array |
| 18 |
*/ |
| 19 |
function automatorwp_woocommerce_get_address_fields() { |
| 20 |
|
| 21 |
return array( |
| 22 |
'first_name', |
| 23 |
'last_name', |
| 24 |
'company', |
| 25 |
'address_1', |
| 26 |
'address_2', |
| 27 |
'city', |
| 28 |
'postcode', |
| 29 |
'country', |
| 30 |
'state', |
| 31 |
'phone', |
| 32 |
'email', |
| 33 |
); |
| 34 |
|
| 35 |
} |
| 36 |
|
| 37 |
/** |
| 38 |
* Helper function to get an address field label |
| 39 |
* |
| 40 |
* @since 1.0.0 |
| 41 |
* |
| 42 |
* @param string $field |
| 43 |
* |
| 44 |
* @return string |
| 45 |
*/ |
| 46 |
function automatorwp_woocommerce_get_address_field_label( $field ) { |
| 47 |
|
| 48 |
$labels = array( |
| 49 |
'first_name' => __( 'First name', 'automatorwp' ), |
| 50 |
'last_name' => __( 'Last name', 'automatorwp' ), |
| 51 |
'company' => __( 'Company', 'automatorwp' ), |
| 52 |
'address_1' => __( 'Address line 1', 'automatorwp' ), |
| 53 |
'address_2' => __( 'Address line 2', 'automatorwp' ), |
| 54 |
'city' => __( 'City', 'automatorwp' ), |
| 55 |
'postcode' => __( 'Postcode / ZIP', 'automatorwp' ), |
| 56 |
'country' => __( 'Country / Region', 'automatorwp' ), |
| 57 |
'state' => __( 'State / County', 'automatorwp' ), |
| 58 |
'phone' => __( 'Phone', 'automatorwp' ), |
| 59 |
'email' => __( 'Email', 'automatorwp' ), |
| 60 |
); |
| 61 |
|
| 62 |
return isset( $labels[$field] ) ? $labels[$field] : ''; |
| 63 |
|
| 64 |
} |
| 65 |
|
| 66 |
/** |
| 67 |
* Helper function to get an address field preview |
| 68 |
* |
| 69 |
* @since 1.0.0 |
| 70 |
* |
| 71 |
* @param string $field |
| 72 |
* |
| 73 |
* @return string |
| 74 |
*/ |
| 75 |
function automatorwp_woocommerce_get_address_field_preview( $field ) { |
| 76 |
|
| 77 |
$previews = array( |
| 78 |
'first_name' => 'AutomatorWP', |
| 79 |
'last_name' => __( 'Plugin', 'automatorwp' ), |
| 80 |
'company' => __( 'AutomatorWP Ltd.', 'automatorwp' ), |
| 81 |
'address_1' => __( 'False Street, 123', 'automatorwp' ), |
| 82 |
'address_2' => __( 'First floor, door 2', 'automatorwp' ), |
| 83 |
'city' => __( 'Brooklyn', 'automatorwp' ), |
| 84 |
'postcode' => __( '12345', 'automatorwp' ), |
| 85 |
'country' => __( 'United States', 'automatorwp' ), |
| 86 |
'state' => __( 'New York', 'automatorwp' ), |
| 87 |
'phone' => __( '202-555-1234', 'automatorwp' ), |
| 88 |
'email' => __( '[email protected]', 'automatorwp' ), |
| 89 |
); |
| 90 |
|
| 91 |
return isset( $previews[$field] ) ? $previews[$field] : ''; |
| 92 |
|
| 93 |
} |