get_product(); $image = $product instanceof \WC_Product ? $product->get_image( array( 48, 48 ), array( 'class' => 'acw-ty__thumb-img' ) ) : ''; return '' !== $image ? '' . $name : $name; } /** * The shop's own head code (Checkout settings, "Scripts") on the thank-you page too. */ public static function head_scripts(): void { if ( function_exists( 'is_order_received_page' ) && is_order_received_page() ) { Checkout::print_custom_scripts( 'scripts_head' ); } } /** * The shop's own footer code on the thank-you page too. */ public static function footer_scripts(): void { if ( function_exists( 'is_order_received_page' ) && is_order_received_page() ) { Checkout::print_custom_scripts( 'scripts_footer' ); } } /** * Uses our thank-you template. * * @param string $template Found template. * @param string $template_name Template name. */ public static function locate_template( $template, $template_name ) { if ( 'checkout/thankyou.php' === $template_name && self::applies() ) { return Template::locate( 'checkout/thankyou' ); } return $template; } /** * Whether the order on this order-received page gets the redesigned page: its status is one of * those chosen in the settings (orders that cannot be read keep it, as before). */ public static function applies(): bool { $id = absint( get_query_var( 'order-received' ) ); $order = $id ? wc_get_order( $id ) : false; if ( ! $order instanceof \WC_Order ) { return true; } $statuses = Settings::get( 'thankyou_statuses', array() ); return is_array( $statuses ) && $order->has_status( array_values( array_filter( $statuses, 'is_string' ) ) ); } /** * Styles, on the order-received page only. */ public static function enqueue(): void { if ( ! function_exists( 'is_order_received_page' ) || ! is_order_received_page() || ! self::applies() ) { return; } wp_enqueue_style( 'aiolos-thankyou', Plugin::asset( 'css/thankyou.css' ), array(), Plugin::asset_version( 'css/thankyou.css' ) ); wp_add_inline_style( 'aiolos-thankyou', wp_strip_all_tags( Checkout::css_variables() ) ); } /** * The order's progress: key => [ label, state (done, current, todo) ]. * * @param \WC_Order $order Order. * @return array */ public static function progress( \WC_Order $order ): array { $paid = $order->is_paid(); $done = $order->has_status( 'completed' ); $awaiting = ! $paid && $order->has_status( array( 'on-hold', 'pending' ) ); $shipping = $order->needs_shipping_address(); $steps = array( 'placed' => array( __( 'Order placed', 'aiolos-checkout-for-woocommerce' ), 'done' ), 'paid' => array( $awaiting ? ( $order->has_status( 'pending' ) ? __( 'Awaiting payment confirmation', 'aiolos-checkout-for-woocommerce' ) : __( 'Awaiting payment', 'aiolos-checkout-for-woocommerce' ) ) : __( 'Payment received', 'aiolos-checkout-for-woocommerce' ), $paid || $done ? 'done' : 'current' ), 'preparing' => array( $shipping ? __( 'Preparing your order', 'aiolos-checkout-for-woocommerce' ) : __( 'Processing', 'aiolos-checkout-for-woocommerce' ), $done ? 'done' : ( $paid ? 'current' : 'todo' ) ), 'completed' => array( $shipping ? __( 'On its way', 'aiolos-checkout-for-woocommerce' ) : __( 'Completed', 'aiolos-checkout-for-woocommerce' ), $done ? 'done' : 'todo' ), ); // Cash on delivery: WooCommerce counts the order as paid ("processing"), the customer pays last. if ( 'cod' === $order->get_payment_method() ) { unset( $steps['paid'] ); $steps['preparing'][1] = $done ? 'done' : 'current'; $steps['paid'] = array( __( 'Payment on delivery', 'aiolos-checkout-for-woocommerce' ), $done ? 'done' : 'todo' ); } /** * Filters the progress shown on the thank-you page. * * @since 1.1.0 * * @param array $steps key => [ label, state (done, current, todo) ]. * @param \WC_Order $order Order. */ return (array) apply_filters( 'aiolos_thankyou_progress', $steps, $order ); } }