WordPress.org

Ready to get started?Download WordPress

Forums

WooCommerce - excelling eCommerce
How to save custom fields in woocommerce? (3 posts)

  1. sanjayrathod885
    Member
    Posted 4 months ago #

    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/

  2. Roy Ho
    Member
    Posted 4 months ago #

  3. sanjayrathod885
    Member
    Posted 4 months ago #

    i had tried that 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;
    }

Reply

You must log in to post.

About this Plugin

About this Topic