{"id":4387620,"date":"2013-12-06T23:12:28","date_gmt":"2013-12-06T23:12:28","guid":{"rendered":"https:\/\/wordpress.org\/support\/topic\/how-to-skip-checkout-page\/"},"modified":"2016-08-21T13:16:22","modified_gmt":"2016-08-21T13:16:22","slug":"how-to-skip-checkout-page","status":"closed","type":"topic","link":"https:\/\/wordpress.org\/support\/topic\/how-to-skip-checkout-page\/","title":{"rendered":"How to Skip Checkout Page?"},"content":{"rendered":"<p>I&#8217;ve got a product category that includes only free products and they are all displaying in a loop. I need to make it so that when a user clicks the &#8220;Add to Cart&#8221; button, it purchases the product and redirects them straight to the My Account page.<\/p>\n<p>If that&#8217;s too difficult, I&#8217;m willing to settle on a solution that will automatically activate the submit button on the checkout page if someone can help me achieve that. I&#8217;ve tried this javascript code which has worked for me on ordinary forms so I know it does what it&#8217;s supposed to do: <\/p>\n<pre><code>function addtocart () {\nvar form = document.getElementsByClassName(&quot;checkout&quot;)[0];\nform.submit();\n}\nwindow.onload = addtocart;<\/code><\/pre>\n<p>It seems to activate an endless loop of redirecting to the checkout page, rather than purchasing the free product. I&#8217;m almost there, but I could really use some help!<\/p>\n<p>https:\/\/wordpress.org\/plugins\/woocommerce\/<\/p>\n","protected":false},"template":"","class_list":["post-4387620","topic","type-topic","status-closed","hentry","topic-tag-checkout","topic-tag-page","topic-tag-product","topic-tag-skip"],"jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/wordpress.org\/support\/wp-json\/wp\/v2\/topic\/4387620","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/wordpress.org\/support\/wp-json\/wp\/v2\/topic"}],"about":[{"href":"https:\/\/wordpress.org\/support\/wp-json\/wp\/v2\/types\/topic"}],"version-history":[{"count":0,"href":"https:\/\/wordpress.org\/support\/wp-json\/wp\/v2\/topic\/4387620\/revisions"}],"wp:attachment":[{"href":"https:\/\/wordpress.org\/support\/wp-json\/wp\/v2\/media?parent=4387620"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}