diff --git a/plugins/woocommerce/includes/rest-api/Controllers/Version2/class-wc-rest-orders-v2-controller.php b/plugins/woocommerce/includes/rest-api/Controllers/Version2/class-wc-rest-orders-v2-controller.php index 55ca8c15fcf..48c81c132bd 100644 --- a/plugins/woocommerce/includes/rest-api/Controllers/Version2/class-wc-rest-orders-v2-controller.php +++ b/plugins/woocommerce/includes/rest-api/Controllers/Version2/class-wc-rest-orders-v2-controller.php @@ -257,7 +257,7 @@ class WC_REST_Orders_V2_Controller extends WC_REST_CRUD_Controller { * @return array */ protected function get_formatted_item_data( $order ) { - $extra_fields = array( 'meta_data', 'line_items', 'tax_lines', 'shipping_lines', 'fee_lines', 'coupon_lines', 'refunds' ); + $extra_fields = array( 'meta_data', 'line_items', 'tax_lines', 'shipping_lines', 'fee_lines', 'coupon_lines', 'refunds', 'payment_url' ); $format_decimal = array( 'discount_total', 'discount_tax', 'shipping_total', 'shipping_tax', 'shipping_total', 'shipping_tax', 'cart_tax', 'total', 'total_tax' ); $format_date = array( 'date_created', 'date_modified', 'date_completed', 'date_paid' ); // These fields are dependent on other fields. @@ -317,6 +317,9 @@ class WC_REST_Orders_V2_Controller extends WC_REST_CRUD_Controller { ); } break; + case 'payment_url': + $data['payment_url'] = $order->get_checkout_payment_url(); + break; } } @@ -382,6 +385,7 @@ class WC_REST_Orders_V2_Controller extends WC_REST_CRUD_Controller { 'fee_lines', 'coupon_lines', 'refunds', + 'payment_url', ); $data = array_intersect_key( $data, array_flip( $allowed_fields ) ); @@ -1774,6 +1778,12 @@ class WC_REST_Orders_V2_Controller extends WC_REST_CRUD_Controller { ), ), ), + 'payment_url' => array( + 'description' => __( 'Order payment URL.', 'woocommerce' ), + 'type' => 'string', + 'context' => array( 'view', 'edit' ), + 'readonly' => true, + ), 'set_paid' => array( 'description' => __( 'Define if the order is paid. It will set the status to processing and reduce stock items.', 'woocommerce' ), 'type' => 'boolean',