get_meta( self::STATE ); } /** * Whether the order already has, or is getting, a shipment. * * @param \WC_Order $order Order. * @return bool */ public static function is_in_progress_or_done( \WC_Order $order ) { return in_array( self::state( $order ), array( self::QUEUED, self::SENDING, self::CREATED, self::UNKNOWN ), true ); } /** * Sets the state and, optionally, an error message; saves the order. * * @param \WC_Order $order Order. * @param string $state State constant. * @param string $error Error message ('' clears it). * @return void */ public static function set_state( \WC_Order $order, $state, $error = '' ) { $order->update_meta_data( self::STATE, $state ); if ( '' === $error ) { $order->delete_meta_data( self::ERROR ); } else { $order->update_meta_data( self::ERROR, $error ); } $order->save(); } /** * Reference sent to ABS for an order, e.g. "#1058" (matches the Shopify app's convention). * * @param \WC_Order $order Order. * @return string */ public static function ref( \WC_Order $order ) { return '#' . $order->get_order_number(); } }