get_id(), $order->get_order_key(), Settings::secret() ) ); } /** * Order-received page. * * @param int $order_id Order id. */ public function thankyou( $order_id ) { $this->box( wc_get_order( $order_id ) ); } /** * My Account → order. * * @param int $order_id Order id. */ public function view_order( $order_id ) { $this->box( wc_get_order( $order_id ) ); } /** * The button. * * @param \WC_Order|false $order Order. */ private function box( $order ) { $link = self::link_for( $order ); if ( '' === $link ) { return; } printf( '

%1$s

%3$s
', esc_html__( 'Want updates about this order on Telegram? We will message you when it ships.', 'orderchirp' ), esc_url( $link ), esc_html__( 'Get updates on Telegram', 'orderchirp' ) ); } /** * A line in the customer's order emails (received and on-hold only: by "completed" it is late). * * @param \WC_Order $order Order. * @param bool $sent_to_admin Admin copy. * @param bool $plain_text Plain-text email. * @param \WC_Email $email Email. */ public function email( $order, $sent_to_admin, $plain_text, $email = null ) { if ( $sent_to_admin || ! $email || ! in_array( $email->id, array( 'customer_processing_order', 'customer_on_hold_order' ), true ) ) { return; } $link = self::link_for( $order ); if ( '' === $link ) { return; } $text = __( 'Want updates about this order on Telegram?', 'orderchirp' ); if ( $plain_text ) { echo esc_html( $text ) . ' ' . esc_url_raw( $link ) . "\n\n"; return; } printf( '

%1$s %3$s

', esc_html( $text ), esc_url( $link ), esc_html__( 'Get updates on Telegram', 'orderchirp' ) ); } /** * Button style on the two pages that show it. */ public function styles() { if ( ( function_exists( 'is_order_received_page' ) && is_order_received_page() ) || ( function_exists( 'is_view_order_page' ) && is_view_order_page() ) ) { wp_enqueue_style( 'orderchirp', ORDERCHIRP_URL . 'assets/orderchirp.css', array(), ORDERCHIRP_VERSION ); } } }