Skip to main content
주문완료 페이지 만들기
add_filter( 'the_content', 'wc_custom_thankyou' );
function wc_custom_thankyou( $content ) {
	// Check if is the correct page
	if ( ! is_page( {PAGE_ID} ) ) {
		return $content;
	}
	// check if the order ID exists
	if ( ! isset( $_GET['order'] ) ) {
		return $content;
	}
	// intval() ensures that we use an integer value for the order ID
	$order = wc_get_order( intval( $_GET['order'] ) );
	ob_start();
	// Check that the order is valid
	if ( ! $order ) {
		// The order can't be returned by WooCommerce - Just say thank you
		?><p><?php echo apply_filters( 'woocommerce_thankyou_order_received_text', __( 'Thank you. Your order has been received.', 'woocommerce' ), null ); ?></p><?php
	} else {
		if ( $order->has_status( 'failed' ) ) {
			// Order failed - Print error messages and ask to pay again
			/**
			 * @hooked wc_custom_thankyou_failed - 10
			 */
			do_action( 'wc_custom_thankyou_failed', $order );
		} else {
			// The order is successfull - print the complete order review
			/**
			 * @hooked wc_custom_thankyou_header - 10
			 * @hooked wc_custom_thankyou_table - 20
			 * @hooked wc_custom_thankyou_customer_details - 30
			 */
			do_action( 'wc_custom_thankyou_successful', $order );
		}
	}
	$content .= ob_get_contents();
	ob_end_clean();
	return $content;
}