• Resolved mowlman

    (@mowlman)


    I would like to include the time for the Order Date, such as Tuesday 11/07/2017, 07:35pm

    Option1: Is there a way to format the order date to include time?

    I did find /wp-content/plugins/woocommerce-delivery-notes/includes/wcdn-template-functions.php

    And I commented out original line 265 which is within function: wcdn_get_order_info and added the line with the formatting I would like:

    	$fields['order_date'] = array( 
    		'label' => __( 'Order Date', 'woocommerce-delivery-notes' ),
    	//	'value' => date_i18n( get_option( 'date_format' ), strtotime( $wdn_order_order_date ) )
    		'value' => date_i18n(__( 'l m/d/Y, h:ia', 'woocommerce' ), strtotime( $wdn_order_order_date ) ) //bill change date format
    	);

    Option2: But is there a way to override this function?

    So any way to override for either option 1 or option2?

    Thank you for your time.

Viewing 2 replies - 1 through 2 (of 2 total)
  • bhavik.kiri

    (@bhavikkiri)

    Hi @mowlman,

    > So any way to override for either option 1 or option2?

    Yes, you can override the date format using the filter “wcdn_order_info_fields” given in the plugin.

    add_filter ( 'wcdn_order_info_fields', 'update_wcdn_order_date_value', 10 , 2  ) ;
    
    function update_wcdn_order_date_value ( $values, $order ) {
    
    	$wdn_order_id =  ( version_compare( get_option( 'woocommerce_version' ), '3.0.0', ">="  ) ) ? $order->get_id() : $order->id;
    	$order_post = get_post( $wdn_order_id );
    	$wdn_order_order_date =  ( version_compare( get_option( 'woocommerce_version' ), '3.0.0', ">="  ) ) ? $order_post->post_date : $order->order_date;
    
    	$values['order_date'] = array( 
    		'label' => __( 'Order Date', 'woocommerce-delivery-notes' ),
    		'value' => date_i18n( __( 'l m/d/Y, h:ia', 'woocommerce' ), strtotime( $wdn_order_order_date ) )
    	);
    	return $values;
    }

    You need to add the above code snippet in your active theme’s functions.php file.

    Please let me know the results.

    Regards,
    Bhavik

    Thread Starter mowlman

    (@mowlman)

    THANKS! Works Great.

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Include time for Order Date’ is closed to new replies.