【问题标题】:WooCommerce- change admin date formatWooCommerce- 更改管理员日期格式
【发布时间】:2015-01-16 11:44:21
【问题描述】:

我想将 WooCommerce 日期格式从 Y/m/d 更改为 d/m/Y。我有打印发票插件,日期采用 y/m/d 格式,取自在 WooCommerce 中订购的日期。

以下曾经是一个解决方案 - 但它不再适用于 WP 4.0

http://www.remicorson.com/customize-woocommerce-admin-orders-date-format/

add_filter('gettext', 'wpse_77783_woo_bacs_ibn', 10, 3);
add_filter( 'post_date_column_time' , 'woo_custom_post_date_column_time' );

// change default admin orders date format
add_filter( 'post_date_column_time' , 'woo_custom_post_date_column_time' );

function woo_custom_post_date_column_time( $post ) {
$h_time = get_the_time( __( 'm/d/Y', 'woocommerce' ), $post );
return $h_time;
}

有人可以在这里给我建议吗?

【问题讨论】:

    标签: woocommerce


    【解决方案1】:

    您还必须使用相同的“post_date_column_time”过滤器更改“$t_time”变量的值。您必须使用两个单独的回调函数返回两个值($t_time 和 $h_time)。除了代码之外,当您在同一过滤器上添加以下回调时,您的代码将起作用。

     add_filter( 'post_date_column_time' ,'woo_custom_post_date_column_time_withDate' );
    
     function woo_custom_post_date_column_time_withDate( $post ) {  
    $t_time = get_the_time( __( 'd/m/Y g:i:s A', 'woocommerce' ), $post );
     return $t_time; 
    }
    

    (还要检查您在回调函数中设置的格式,将其更改为“d/m/Y”,因为您需要它。)

    【讨论】:

      【解决方案2】:

      此答案不再适用于较新的版本。对于版本 3 及更高版本,请参阅WooCommerce 3.0+ change admin order date column format

      【讨论】:

        猜你喜欢
        • 2020-08-06
        • 1970-01-01
        • 1970-01-01
        • 2010-10-12
        • 1970-01-01
        • 2011-06-05
        • 2016-11-22
        相关资源
        最近更新 更多