【发布时间】:2020-07-13 18:57:35
【问题描述】:
我有一个自定义属性,其中产品有不同的取货时间。我想将此日期作为自定义字段添加到我的 wc 订单中,以通过 cronjob 通知我的客户订单已准备好取货。
使用下面的代码我得到了错误的日期,谁能告诉我这里出了什么问题?
foreach ( $order->get_items() as $item_id => $item ) {
$product_id = $item->get_product_id();
$order_id = $order->get_id();
$new_product = new WC_Product( $product_id ); // create an object of WC_Product class
//$product_attribut = $new_product->get_attribute( 'pa_lieferfrequenz' ); // call get_attribute method
$product_attribut = '1week';
$date = date('d-m-Y', strtotime("+ ' . $product_attribut . '"));
add_post_meta( $order_id, 'lwb_pickup_time_email_notification', $date );
}
【问题讨论】:
标签: php wordpress woocommerce strtotime orders