Created
June 5, 2025 15:43
-
-
Save kilbot/8c2856ee590d1fc6abe1095ab742322a to your computer and use it in GitHub Desktop.
Migrate POS orders from Actuality Extensions
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
function wcpos_update_created_via_field() { | |
$batch_size = 100; | |
$page = 1; | |
do { | |
$orders = wc_get_orders( [ | |
'limit' => $batch_size, | |
'page' => $page, | |
'type' => 'shop_order', | |
'status' => 'any', | |
'orderby' => 'ID', | |
'order' => 'ASC', | |
'return' => 'objects', | |
] ); | |
foreach ( $orders as $order ) { | |
if ( $order->get_created_via() === 'pos' ) { | |
$order->set_created_via( 'woocommerce-pos' ); | |
$order->save(); | |
} | |
} | |
$page++; | |
} while ( count( $orders ) === $batch_size ); | |
} | |
wcpos_update_created_via_field(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment