在woocommerce网站上,网站迁移没有按计划进行,直到很晚才被发现。 结果是,随着新用户注册并下订单,先前使用相同ID(迁移前)的用户的订单历史记录将显示在新用户的订单摘要(面向客户)下。
我想将(迁移日期)之前的所有订单重新分配给(旧用户)。
function reassign_orders( ){
if(!is_admin()) return;
else {
$new_customer_id = 286;
// Iterating with a loop through a range of numbers
for( $order_id = 22680; $order_id <= 22680; $order_id++ ){
// Getting the postmeta customer ID for 'order' post-type
$customer_id = get_post_meta( $order_id, '_customer_user', true );
// If it's an existing order and doesn't already have this user ID
// It update the customer ID
if( !empty($customer_id) && $new_customer_id != $customer_id )
update_post_meta( $order_id, '_customer_user', $new_customer_id );
}
}
}
reassign_orders();
什么都没发生。