WordPress.org

Support

Support » Plugins and Hacks » WooCommerce » How to save custom fields in woocommerce?

How to save custom fields in woocommerce?

  • i had add custom fields to checkout page by following code in functions.php file of my theme

    add_filter(‘woocommerce_checkout_fields’,’custom_override_checkout_fields’);

    function custom_override_checkout_fields($fields){
    $custom_field_type = get_post_meta( $post->ID, ‘_custom_field_type’, true );
    $fields[‘billing’][‘billing_deliverydate’][‘placeholder’] = ‘Enter Delivery Date’;
    $fields[‘billing’][‘billing_deliverydate’][‘label’] = ‘Delivery Date’;
    $fields[‘billing’][‘billing_options’] = array(
    ‘label’ => __(‘Dumpster Placement’, ‘woocommerce’),
    ‘placeholder’ => _x(”, ‘placeholder’, ‘woocommerce’),
    ‘required’ => false,
    ‘clear’ => false,
    ‘type’ => ‘select’,
    ‘options’ => array(
    ‘option_a’ => __(‘Driver State’, ‘woocommerce’ ),
    ‘option_b’ => __(‘Street’, ‘woocommerce’ ),
    ‘option_c’ => __(‘Other’, ‘woocommerce’ )
    )
    );
    return $fields;
    }

    Now i want to value enered by user in this custom field. So how can i save this value with the help of functions.php

    i have tried following code but not worked.

    add_filter(‘woocommerce_email_order_meta_keys’, ‘my_custom_checkout_field_order_meta_keys’);

    function my_custom_checkout_field_order_meta_keys( $keys ) {
    $keys[] = ‘billing_deliverydate’;
    return $keys;
    }

    please help. any suggestions will appreciated.

    https://wordpress.org/plugins/woocommerce/

Viewing 2 replies - 1 through 2 (of 2 total)
Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘How to save custom fields in woocommerce?’ is closed to new replies.
Skip to toolbar