{"id":3576,"date":"2022-05-14T13:55:56","date_gmt":"2022-05-14T13:55:56","guid":{"rendered":"https:\/\/scriptfeeds.com\/blog\/?p=3576"},"modified":"2022-12-06T21:56:45","modified_gmt":"2022-12-06T21:56:45","slug":"how-to-add-custom-woocommerce-thank-you-page-without-plugin","status":"publish","type":"post","link":"https:\/\/scriptfeeds.com\/blog\/wordpress\/how-to-add-custom-woocommerce-thank-you-page-without-plugin\/","title":{"rendered":"How to add custom WooCommerce thank you page without plugin"},"content":{"rendered":"\n<p>A custom thank you page can be very useful specially in WooCommerce Products. A custom thank you page can help you in upsell or after instructions notes for a customer after selling product. This article will help you to add custom thank you page after WooCommerce Product page. You can add any any to a thank you page using a simple redirect action. <\/p>\n\n\n\n<h2 class=\"has-medium-font-size wp-block-heading\">Step by Step guide to add custom thank you page for WooCommerce Product<\/h2>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Open the WooCommerce product on which you wanna add redirect. Copy the ID of the Product (You can get the id from the url when you open the product in dashboard)<\/li>\n\n\n\n<li>Click on theme editor and select the child theme of your Active theme.<\/li>\n\n\n\n<li>Click on functions.php file and add the below code with your ID and custom page link.<\/li>\n<\/ul>\n\n\n\n<pre class=\"wp-block-code\"><code>add_action( 'woocommerce_thankyou', 'redirect_product_based', 1 ); \nfunction redirect_product_based ( $order_id ){\n            $order = wc_get_order( $order_id );\n        \n            foreach( $order-&gt;get_items() as $item ) {\n                \/\/ Add whatever product id you want below here\n                if ( $item&#91;'product_id'] == 1565 ) {\n                    \/\/ change below to the URL that you want to send your customer to\n                     wp_redirect( 'https:\/\/www.scriptfeeds.com\/thank-you\/' );\n                \n                }\n             \n            }        \n}\n<\/code><\/pre>\n\n\n\n<p>You can any number custom thank you pages by changing product ID and URL repeating code below in above code.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>if ( $item&#91;'product_id'] == 1555 ) {\n                    \/\/ change below to the URL that you want to send your customer to\n                     wp_redirect( 'https:\/\/www.abc.com\/thank-you\/' );\n                \n                }<\/code><\/pre>\n\n\n\n<p>Use the code and let us know how it works.<\/p>\n\n\n\n<p>Happy Coding!<\/p>\n\n\n<p>[caldera_form id=&#8221;CF60ca2e3ccf64f&#8221;]<\/p>\n","protected":false},"excerpt":{"rendered":"<p>A custom thank you page can be very useful specially in WooCommerce Products. A custom thank you page can help you in upsell or after instructions notes for a customer after selling product. This article will help you to add custom thank you page after WooCommerce Product page. You can add any any to a [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":3393,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"jnews-multi-image_gallery":[],"jnews_single_post":{"subtitle":"","format":"standard","video":"","gallery":"","source_name":"","source_url":"","via_name":"","via_url":"","override_template":"0","override":[{"template":"2","single_blog_custom":"","parallax":"1","fullscreen":"1","layout":"right-sidebar","sidebar":"default-sidebar","second_sidebar":"default-sidebar","sticky_sidebar":"1","share_position":"float","share_float_style":"share-monocrhome","show_share_counter":"1","show_view_counter":"1","show_featured":"1","show_post_meta":"1","show_post_author":"1","show_post_author_image":"1","show_post_date":"1","post_date_format":"default","post_date_format_custom":"Y\/m\/d","show_post_category":"1","show_post_reading_time":"0","post_reading_time_wpm":"300","show_zoom_button":"0","zoom_button_out_step":"2","zoom_button_in_step":"3","show_post_tag":"1","show_prev_next_post":"0","show_popup_post":"0","number_popup_post":"1","show_author_box":"0","show_post_related":"1","show_inline_post_related":"0"}],"override_image_size":"0","image_override":[{"single_post_thumbnail_size":"no-crop","single_post_gallery_size":"crop-500"}],"trending_post":"0","trending_post_position":"meta","trending_post_label":"Trending","sponsored_post":"0","sponsored_post_label":"Sponsored by","sponsored_post_name":"","sponsored_post_url":"","sponsored_post_logo_enable":"0","sponsored_post_logo":"","sponsored_post_desc":"","disable_ad":"0"},"jnews_primary_category":{"id":"","hide":""},"footnotes":""},"categories":[86,75],"tags":[219,220],"class_list":["post-3576","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-woocommerce","category-wordpress","tag-custom-woocommerce-thank-you-page","tag-woocommerce-custom-thank-you-page-without-plugin"],"_links":{"self":[{"href":"https:\/\/scriptfeeds.com\/blog\/wp-json\/wp\/v2\/posts\/3576","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/scriptfeeds.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/scriptfeeds.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/scriptfeeds.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/scriptfeeds.com\/blog\/wp-json\/wp\/v2\/comments?post=3576"}],"version-history":[{"count":0,"href":"https:\/\/scriptfeeds.com\/blog\/wp-json\/wp\/v2\/posts\/3576\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/scriptfeeds.com\/blog\/wp-json\/wp\/v2\/media\/3393"}],"wp:attachment":[{"href":"https:\/\/scriptfeeds.com\/blog\/wp-json\/wp\/v2\/media?parent=3576"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/scriptfeeds.com\/blog\/wp-json\/wp\/v2\/categories?post=3576"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/scriptfeeds.com\/blog\/wp-json\/wp\/v2\/tags?post=3576"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}