Registry::int_param( $params, 'order_id', 0, 1, PHP_INT_MAX ) ); } public function execute( array $params, float $deadline ): array { if ( ! function_exists( 'wc_get_order' ) ) { return array( 'error' => 'woocommerce_not_active' ); } $order = wc_get_order( $params['order_id'] ); if ( ! $order instanceof \WC_Order ) { return array( 'error' => 'order_not_found', 'id' => $params['order_id'] ); } $notes = array(); foreach ( array_slice( wc_get_order_notes( array( 'order_id' => $order->get_id(), 'limit' => 10, 'type' => 'internal' ) ), 0, 10 ) as $n ) { $notes[] = array( 'at' => $n->date_created ? $n->date_created->date( 'c' ) : null, 'content' => Redactor::text( wp_strip_all_tags( (string) $n->content ) ) ); } $items = array(); foreach ( $order->get_items() as $item ) { $items[] = array( 'product_id' => method_exists( $item, 'get_product_id' ) ? (int) $item->get_product_id() : null, 'quantity' => (int) $item->get_quantity(), 'total' => method_exists( $item, 'get_total' ) ? (float) $item->get_total() : 0.0 ); } return array( 'id' => $order->get_id(), 'status' => $order->get_status(), 'currency' => $order->get_currency(), 'total' => (float) $order->get_total(), 'payment_method' => (string) $order->get_payment_method(), 'created_via' => (string) $order->get_created_via(), 'created_at' => $order->get_date_created() ? $order->get_date_created()->date( 'c' ) : null, 'paid_at' => $order->get_date_paid() ? $order->get_date_paid()->date( 'c' ) : null, 'completed_at' => $order->get_date_completed() ? $order->get_date_completed()->date( 'c' ) : null, 'has_transaction_id' => $order->get_transaction_id() !== '', 'is_renewal' => function_exists( 'wcs_order_contains_renewal' ) ? (bool) wcs_order_contains_renewal( $order ) : null, 'items' => array_slice( $items, 0, 50 ), 'notes' => $notes, ); } }