Skip to content

Instantly share code, notes, and snippets.

@Barrytron1983
Created October 28, 2014 18:06
Show Gist options
  • Save Barrytron1983/a9d79c1cdd86ad941026 to your computer and use it in GitHub Desktop.
Save Barrytron1983/a9d79c1cdd86ad941026 to your computer and use it in GitHub Desktop.
Add a store location dropdown in the address area and output to email WOOCOMMERCE
/* testo2 */
// Hook in
add_filter( 'woocommerce_checkout_fields' , 'custom_override_checkout_fields2' );
// Our hooked in function - $fields is passed via the filter!
function custom_override_checkout_fields2( $fields ) {
$fields['billing']['Location'] = array(
'label' => __('If picking up your order locally, what is the most convenient store location for you?', 'woocommerce'),
'type' => 'select',
'class' => array('form-row-wide'),
'options' => array(
'not_selected' => __('Choose your pickup location', 'woocommerce' ),
'_Galway' => __('Galway', 'woocommerce' ),
'Carrigaline' => __('Cork - Carrigaline', 'woocommerce' ),
'Paul St' => __('Cork - Paul St', 'woocommerce' ),
'Midleton' => __('Cork - Midleton', 'woocommerce' ),
'Clonakilty' => __('Cork - Clonakilty', 'woocommerce' ),
'Cobh' => __('Cork - Cobh', 'woocommerce' ),
'Kinsale' => __('Cork - Kinsale', 'woocommerce' ),
'Mallow' => __('Cork - Mallow', 'woocommerce' ),
'Greystones' => __('Wicklow - Greystones', 'woocommerce' ),
'Temple Bar' => __('Dublin - Temple Bar', 'woocommerce' ),
'FinglasVillage' => __('Dublin - Finglas Village Centre', 'woocommerce' ),
'FinglasNorthside' => __('Dublin - Finglas Northside Shopping Centre', 'woocommerce' ),
'Letterkenny' => __('Letterkenny', 'woocommerce' ),
'Wexford' => __('Wexford', 'woocommerce' )
),
'placeholder' => __('Your most convenient location?')
);
return $fields;
}
add_filter('woocommerce_email_order_meta_keys', 'my_custom_checkout_field_order_meta_keys1');
function my_custom_checkout_field_order_meta_keys1( $keys ) {
$keys[] = '_Location';
return $keys;
}
/* testo2 end */
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment