凉的谢谢你的回答,这对我帮助很大。
我试图得到我的未付订单,在Woocommerce中一段时间后自动取消它们。它不起作用,因为默认情况下它使用current\\u time(“timestamp”)。
woocommerce/includes/wc-order-functions.php
function wc_cancel_unpaid_orders() {
global $wpdb;
$held_duration = get_option( \'woocommerce_hold_stock_minutes\' );
if ( $held_duration < 1 || get_option( \'woocommerce_manage_stock\' ) != \'yes\' )
return;
$date = date( "Y-m-d H:i:s", strtotime( \'-\' . absint( $held_duration ) . \' MINUTES\', current_time( \'timestamp\' ) ) );
$unpaid_orders = $wpdb->get_col( $wpdb->prepare( "
SELECT posts.ID
FROM {$wpdb->posts} AS posts
WHERE posts.post_type IN (\'" . implode( "\',\'", wc_get_order_types() ) . "\')
AND posts.post_status = \'wc-pending\'
AND posts.post_modified < %s
", $date ) );
if ( $unpaid_orders ) {
foreach ( $unpaid_orders as $unpaid_order ) {
$order = wc_get_order( $unpaid_order );
if ( apply_filters( \'woocommerce_cancel_unpaid_order\', \'checkout\' === get_post_meta( $unpaid_order, \'_created_via\', true ), $order ) ) {
$order->update_status( \'cancelled\', __( \'Unpaid order cancelled - time limit reached.\', \'woocommerce\' ) );
}
}
}
}
那么我无法更改此代码。这始终使用current\\u时间(“timestamp”)。
如果我保存订单,他的日期是2016-10-25 11:20:11am 但是current\\u time(“timestamp”)表示2016-10-25 06:20:11.
我做错什么了?
PD:wp\\u选项中的我的变量是:gmt\\u offset为空,timezone\\u string为America/Lima
当做