Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- /*
- Plugin Name: WooCommerce - Set City
- Plugin URI: http://www.damiencarbery.com
- Description: Set the value of the billing and shipping city.
- Author: Damien Carbery
- Version: 0.1
- */
- // Set the value of the City input field.
- add_filter('woocommerce_checkout_get_value', 'wsc_set_get_value', 10, 2);
- function wsc_set_get_value($empty, $input) {
- if (('billing_city' == $input) || ('shipping_city' == $input)) {
- return 'The City';
- }
- }
- // Make City input field read only.
- add_filter('woocommerce_form_field_text', 'wsc_read_only_city_input', 10, 4);
- function wsc_read_only_city_input($field, $key, $args, $value) {
- if (('billing_city' == $key) || ('shipping_city' == $key)) {
- $field = str_replace('type="text"', 'type="text" disabled="disabled"', $field);
- $field .= '<input type="hidden" name="'.$key.'" value="'.$value.'" />';
- }
- return $field;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement