{"id":83,"date":"2026-04-03T13:31:18","date_gmt":"2026-04-03T13:31:18","guid":{"rendered":"https:\/\/wp.gapshop.net\/index.php\/checkout\/"},"modified":"2026-04-03T13:31:18","modified_gmt":"2026-04-03T13:31:18","slug":"checkout","status":"publish","type":"page","link":"https:\/\/wp.gapshop.net\/index.php\/checkout\/","title":{"rendered":"Checkout"},"content":{"rendered":"    <div class=\"gapshop-wrap\" id=\"gs-checkout-wrap\">\r\n        <div class=\"gapshop-loading\">Loading...<\/div>\r\n    <\/div>\r\n    <script>\r\n    document.addEventListener('DOMContentLoaded', function() {\r\n        var cart = window.gapShopCart.get();\r\n        var wrap = document.getElementById('gs-checkout-wrap');\r\n\r\n        if (!cart.items.length) {\r\n            wrap.innerHTML = '<div class=\"gapshop-msg-error\">Your cart is empty. <a href=\"\/\">Continue shopping<\/a>.<\/div>';\r\n            return;\r\n        }\r\n\r\n        var sub   = window.gapShopCart.subtotal();\r\n        var token = localStorage.getItem('gapshop_token');\r\n\r\n        wrap.innerHTML =\r\n            '<div style=\"display:grid;grid-template-columns:1fr 320px;gap:32px;align-items:start\">'\r\n            + '<div>'\r\n            + (!token ? '<div style=\"background:#fff3e0;border-left:4px solid #f57c00;padding:12px 16px;border-radius:4px;margin-bottom:20px;font-size:.88rem\">\ud83d\udca1 <a href=\"\/account\/?redirect='+encodeURIComponent(window.location.href)+'\" style=\"color:#e65100;font-weight:600\">Sign in<\/a> to save your order history.<\/div>' : '')\r\n            + '<h3 style=\"margin:0 0 16px;font-size:1rem;font-weight:700\">Contact Information<\/h3>'\r\n            + '<div style=\"display:grid;grid-template-columns:1fr 1fr;gap:12px\">'\r\n            + '<input id=\"gs-fn\" class=\"gapshop-field\" type=\"text\" placeholder=\"First Name *\" \/>'\r\n            + '<input id=\"gs-ln\" class=\"gapshop-field\" type=\"text\" placeholder=\"Last Name *\" \/>'\r\n            + '<\/div>'\r\n            + '<input id=\"gs-em\" class=\"gapshop-field\" type=\"email\" placeholder=\"Email Address *\" \/>'\r\n            + '<input id=\"gs-ph\" class=\"gapshop-field\" type=\"tel\" placeholder=\"Phone\" \/>'\r\n            + '<h3 style=\"margin:16px 0;font-size:1rem;font-weight:700\">Shipping Address<\/h3>'\r\n            + '<input id=\"gs-a1\" class=\"gapshop-field\" type=\"text\" placeholder=\"Address Line 1 *\" \/>'\r\n            + '<input id=\"gs-a2\" class=\"gapshop-field\" type=\"text\" placeholder=\"Address Line 2\" \/>'\r\n            + '<div style=\"display:grid;grid-template-columns:2fr 1fr 1fr;gap:12px;margin-bottom:12px\">'\r\n            + '<input id=\"gs-ci\" style=\"padding:10px 12px;border:1px solid #ddd;border-radius:6px;font-size:.9rem;box-sizing:border-box\" type=\"text\" placeholder=\"City *\" \/>'\r\n            + '<input id=\"gs-st\" style=\"padding:10px 12px;border:1px solid #ddd;border-radius:6px;font-size:.9rem;box-sizing:border-box\" type=\"text\" placeholder=\"State\" maxlength=\"2\" \/>'\r\n            + '<input id=\"gs-zp\" style=\"padding:10px 12px;border:1px solid #ddd;border-radius:6px;font-size:.9rem;box-sizing:border-box\" type=\"text\" placeholder=\"ZIP *\" \/>'\r\n            + '<\/div>'\r\n            + '<p style=\"font-size:.78rem;color:#888;margin:0 0 16px\">You will be redirected to our secure payment page to complete your purchase.<\/p>'\r\n            + '<button id=\"gs-place\" class=\"gapshop-btn gapshop-btn-primary\" style=\"width:100%;padding:14px;font-size:1rem\" onclick=\"gsPlaceOrder()\">\ud83d\udd12 Proceed to Payment \u2014 $'+sub.toFixed(2)+'<\/button>'\r\n            + '<div id=\"gs-co-err\" class=\"gapshop-msg-error\" style=\"display:none;margin-top:12px\"><\/div>'\r\n            + '<\/div>'\r\n            + '<div class=\"gapshop-summary\">'\r\n            + '<h3 style=\"margin:0 0 16px;font-size:1rem;font-weight:700\">Order Summary<\/h3>'\r\n            + cart.items.map(function(i){\r\n                return '<div style=\"display:flex;justify-content:space-between;padding:6px 0;font-size:.85rem;border-bottom:1px solid #f5f5f5\"><span>'+i.name+' \u00d7 '+i.quantity+'<\/span><span style=\"font-weight:600\">$'+(i.unitPrice*i.quantity).toFixed(2)+'<\/span><\/div>';\r\n              }).join('')\r\n            + '<div style=\"display:flex;justify-content:space-between;padding:12px 0 0;font-size:1rem;font-weight:700;border-top:2px solid #eee;margin-top:8px\"><span>Total<\/span><span style=\"color:#1565c0\">$'+sub.toFixed(2)+'<\/span><\/div>'\r\n            + '<p style=\"font-size:.75rem;color:#aaa;margin-top:12px;text-align:center\">Secure payment powered by Stripe<\/p>'\r\n            + '<\/div><\/div>';\r\n    });\r\n\r\n    async function gsPlaceOrder() {\r\n        var btn = document.getElementById('gs-place');\r\n        var err = document.getElementById('gs-co-err');\r\n        btn.disabled = true; btn.textContent = 'Processing...'; err.style.display = 'none';\r\n\r\n        var email = document.getElementById('gs-em').value.trim();\r\n        var zip   = document.getElementById('gs-zp').value.trim();\r\n        if (!email) { showErr('Email is required.'); return; }\r\n        if (!zip)   { showErr('ZIP code is required.'); return; }\r\n\r\n        var cart  = window.gapShopCart.get();\r\n        var token = localStorage.getItem('gapshop_token');\r\n\r\n        var payload = {\r\n            firstName: document.getElementById('gs-fn').value.trim(),\r\n            lastName:  document.getElementById('gs-ln').value.trim(),\r\n            email:     email,\r\n            phone:     document.getElementById('gs-ph').value.trim(),\r\n            shippingAddress: {\r\n                line1:  document.getElementById('gs-a1').value.trim(),\r\n                line2:  document.getElementById('gs-a2').value.trim(),\r\n                city:   document.getElementById('gs-ci').value.trim(),\r\n                state:  document.getElementById('gs-st').value.trim(),\r\n                zip:    zip\r\n            },\r\n            items: cart.items.map(function(i) {\r\n                return { productId: i.productId, variantId: i.variantId || null, name: i.name, quantity: i.quantity, unitPrice: i.unitPrice };\r\n            }),\r\n            returnUrl: \"https:\\\/\\\/wp.gapshop.net\\\/index.php\\\/checkout\\\/\",\r\n            cancelUrl: \"https:\\\/\\\/wp.gapshop.net\\\/index.php\\\/cart\\\/\"        };\r\n\r\n        var hdrs = { 'Content-Type': 'application\/json', 'X-Tenant-Domain': window.location.hostname };\r\n        if (token) hdrs['Authorization'] = 'Bearer ' + token;\r\n\r\n        try {\r\n            var res  = await fetch(\"https:\\\/\\\/api.gapshop.net\\\/api\\\/store\\\/checkout\", { method: 'POST', headers: hdrs, body: JSON.stringify(payload) });\r\n            var data = await res.json();\r\n            if (res.ok && data.checkoutUrl) {\r\n                window.gapShopCart.clear();\r\n                window.location.href = data.checkoutUrl;\r\n            } else {\r\n                showErr(data.error || 'Checkout failed. Please try again.');\r\n            }\r\n        } catch (e) {\r\n            showErr('Network error. Please try again.');\r\n        }\r\n    }\r\n\r\n    function showErr(msg) {\r\n        var btn = document.getElementById('gs-place');\r\n        var err = document.getElementById('gs-co-err');\r\n        btn.disabled    = false;\r\n        btn.textContent = '\ud83d\udd12 Proceed to Payment';\r\n        err.textContent = msg;\r\n        err.style.display = 'block';\r\n    }\r\n    <\/script>\r\n    \n","protected":false},"excerpt":{"rendered":"","protected":false},"author":1,"featured_media":0,"parent":0,"menu_order":0,"comment_status":"closed","ping_status":"closed","template":"","meta":{"footnotes":""},"class_list":["post-83","page","type-page","status-publish","hentry"],"_links":{"self":[{"href":"https:\/\/wp.gapshop.net\/index.php\/wp-json\/wp\/v2\/pages\/83","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/wp.gapshop.net\/index.php\/wp-json\/wp\/v2\/pages"}],"about":[{"href":"https:\/\/wp.gapshop.net\/index.php\/wp-json\/wp\/v2\/types\/page"}],"author":[{"embeddable":true,"href":"https:\/\/wp.gapshop.net\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/wp.gapshop.net\/index.php\/wp-json\/wp\/v2\/comments?post=83"}],"version-history":[{"count":0,"href":"https:\/\/wp.gapshop.net\/index.php\/wp-json\/wp\/v2\/pages\/83\/revisions"}],"wp:attachment":[{"href":"https:\/\/wp.gapshop.net\/index.php\/wp-json\/wp\/v2\/media?parent=83"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}