Skip to content

Commit a73811f

Browse files
committed
Use new hook to save order metadata.
1 parent 11bb434 commit a73811f

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

wordpress/legacy_shortcode.php

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
<?php
22

33
function coopcycle_checkout_process() {
4+
45
// TODO Make sure shipping time is valid
56

67
// Skip if another shipping method was chosen
@@ -13,15 +14,15 @@ function coopcycle_checkout_process() {
1314
}
1415
}
1516

16-
function coopcycle_checkout_update_order_meta($order_id) {
17+
function coopcycle_checkout_create_order(WC_Order $order) {
1718

1819
// Skip if another shipping method was chosen
1920
if (!CoopCycle::contains_accepted_shipping_method(wc_get_chosen_shipping_method_ids())) {
2021
return;
2122
}
2223

2324
if (!empty($_POST['shipping_date'])) {
24-
update_post_meta($order_id, 'shipping_date', sanitize_text_field($_POST['shipping_date']));
25+
$order->update_meta_data('shipping_date', sanitize_text_field($_POST['shipping_date']));
2526
}
2627
}
2728

@@ -68,6 +69,6 @@ function coopcycle_enqueue_scripts() {
6869

6970
add_action('woocommerce_checkout_process', 'coopcycle_checkout_process');
7071

71-
add_action('woocommerce_checkout_update_order_meta', 'coopcycle_checkout_update_order_meta');
72+
add_action('woocommerce_checkout_create_order', 'coopcycle_checkout_create_order', 10, 1);
7273

7374
add_action('wp_enqueue_scripts', 'coopcycle_enqueue_scripts');

0 commit comments

Comments
 (0)