top of page

How to Create a Customized Checkout Page by Hijacking the Checkout Button in Wix

Writer: Michael NzeribeMichael Nzeribe

Creating a customized checkout page on your Wix store can help you build trust with your customers, personalize their experience, and provide functionalities that meet their needs, which can ultimately lead to a higher conversion rate. 


A customized checkout page that meets your brand's unique needs and customers expectations can make a difference. It provides you with the flexibility to choose a suitable payment provider, reduces the possibility of abandoned carts, helps customers easily finalize their payment, and allows you to gather important information about them. 


Adding these customized features to the native Wix checkout page might seem complex; however, you can hijack the checkout button and direct users to your customized checkout page with a simple click.



In this guide, we will explain the step-by-step process of how you can hijack the checkout button and direct your customers to a customized cart page by using a custom code. Let's get started!



Want to learn more? Ready to dive deeper into Wix and Velo? Take your skills to the next level with our comprehensive 'Velo for Beginners' course on Udemy. Enroll today to uncover the intricacies of Wix and Velo.


Need help with your site? The Wix Wiz team is at your side. Schedule a one-on-one consultation or have the entire team onboard with our development and support plans.



Why You Need to Hijack the Wix Checkout Button


The default shopping process on a Wix Store is quite simple: browse through products, add necessary items to your cart, click the checkout button, then it directs you to the native Wix checkout page to complete your order. 


Using the native Wix checkout page to finalize orders is nice, but your site’s needs might require you to add some additional functionalities, such as directing customers to another page on your website—perhaps in case you want to build a quote request form, scenarios where you don’t need to collect payment, or because you want to use a custom payment provider.


One way to achieve this is by completely customizing the cart; you can check the series here; however, this approach can be quite complex. Since we only want the native Wix Cart page to direct customers to a customized checkout page, hijacking the checkout button provides a simple approach to achieving it.


Does that mean completely customizing the cart is outdated?


No, it is still useful in some cases where you need to change the design fundamentally or add certain features. 


If you're looking to enhance user interactions with custom forms, check out our complete guide on Wix Forms to learn how to create and customize forms effectively.


How To Hijack The Wix Checkout Button


There are a few things you need to put in place to hijack the checkout button, which include:


  • A template site with a Wix store installed.


  • Custom code: This allows you to embed custom code snippets like JavaScript or HTML into your Wix site, mostly suitable for adding basic functionalities or customizing the appearance of your website. It is quite different from Velocode. Velocode is suitable when you want to add more advanced and complex features to your website.


Important Note!


To add a custom code to your website, you need to have a premium site with a custom domain.


For the purpose of this tutorial, we will be using the dev-site, which gives some premium site capabilities, but if you want to do this on your own site, then you need to upgrade.


After you have set up your Wix store template and upgraded your site, let's get into the nitty-gritty of how to hijack the checkout button using custom code. 


How to Add Custom Code to Your Wix Website


Embedding custom code snippets to your Wix site gives you the flexibility of adding specific functionalities and dynamic content to your site. In this section, we will use the custom code to dynamically create a new button that directs users to a customized checkout page on your website. 


To add a custom code, follow these steps:


Navigate to the ‘Settings’ section on your dashboard. Scroll down and click ‘Custom code’.

Wix Settings menu in a web interface showing options for communications and custom code integration. A pink arrow highlights "Custom code."

This should appear on your screen.

Wix Dashboard with navigation menu on the left. Main section shows "Custom Code" options for adding code snippets. Blue button for adding code.

Now that you know where to embed your custom code snippets, let's set up our editor environment.


Step 1: Ensure you've installed the Wix store.


Step 2: Navigate to the site template's Wix ‘Cart’ page.

Wix website editor showing an empty cart page. Sidebar menu with "Cart" highlighted in blue. Text reads "Cart is empty."

Notice that it is a closed-box application, which restricts us from performing certain actions.


Although some APIs allow us to interact with the cart, we generally don’t have access to the UI or the button we want to control.


Since we can’t even see the cart element in the editor, how do we control the button?


Simple, just hijack the button through the HTML itself.


How to Hijack the Checkout Button


Since we cannot edit the functionality of the checkout button through the editor, then we can bypass the process through the HTML element in the live site. 


Follow these steps to achieve this:


Step 1: Navigate to the cart page live site 


Step 2: Left-click the page and select ‘Inspect’.


This should appear on your screen.


Wix Shopping cart page on Ceramic Studio site showing a product priced at $45. Order summary indicates $45 total. Developer tools open.

We need to locate the ‘Checkout’ button right inside the dev tool panel in order to know its properties.


Step 3: Click this icon in your dev tool panel. This allows us to locate the ‘Checkout’ button inside the dev tool panel and check its properties


WIx Shopping cart page on the left with a $45 item; HTML code on the right, highlighted with a pink arrow. Simple, clean interface.

Step 4: Select the ‘Checkout button’ you want to inspect.


Wix E-commerce checkout page on left, showing a $45 product in cart. Developer tools open on right, highlighting code in a dark theme.

Step 5: Navigate to the Checkout button code in the dev tool.


Wix Shopping cart page displaying a ceramic product for $45. Developer tools showing HTML code on the right with highlighted elements.

If you inspect the checkout button code, you will notice it has a data hook of CheckButtons.default. This is because we only have a single button, and it is the default option for checkout. 


If you activate the express checkout, you might see several checkout buttons like Paypal, ApplePay, or Google Pay. You may need to deactivate the express checkout if it’s causing issues with what we are trying to implement. 

We are going to assume you have just one checkout button in this tutorial.


Now, let’s jump straight to implementing our functionality, i.e., linking customers to another page on the site once the button is clicked. 

To achieve this, we are going to replace the code in the button element with plain JavaScript that will implement our desired functionality. 

 

First off, let's create a new page in the editor. I.e., the page we want to link users to once the button is clicked.


Step 1: Navigate to the ‘Page & Menu’ section and click the ‘Add page’ icon.

Wix menu setup screen. A pink arrow points to "+ Add Page" on the site menu. Options include Home, Custom Checkout, with social icons on the right.

Step 2: Create a blank page. 

Wix website editor interface displaying options to change background, quick edit, and explore section layouts. "CERAMIC-STUDIO" text visible.

Step 3: Add a title to the page.


Wix site editor shows "Custom Checkout" added to site menu. A red arrow points to it. Settings and menu options are visible in background.

Step 4: Verify its URL by clicking the icon next to the ‘Custom Checkout’ and navigate to the ‘SEO’ basics section to ensure the URL is correct.

Wix settings screen showing site pages and menu options. "Custom Checkout" is highlighted, with URL slug "custom-checkout" and red arrow pointing.

Step 5: Click the ‘Add Elements’ icon and add a title to the page. This will make it easier to know we are on the right page once the button is clicked.

Wix editor interface with "Add Elements" panel open, highlighting "Add Heading 1" text option. Background shows website template with social icons.

Step 6: Enter your text.

Wix website editor showing a custom checkout page. Red arrow points to "Custom Checkout." Icons and USD currency selector visible.


Step 7: Hit the publish button to publish the site.


Wix cart page editor with header showing "Cart is empty." A pink dot and arrow point to a blue "Publish" button. Social icons on the right.

The next step is to ensure that once the checkout button is clicked, it will take the user directly to this page we just created.


To add this functionality, follow these steps:


Step 1: Navigate to the custom code section.

Wix Website settings interface for adding custom code, with sections for Head, Body Start, and Body End. A sidebar shows navigation options.

Step 2: Click the Body - End section.

Wix Studio dashboard showing custom code settings. Side menu options include Getting Paid, Sales, and Catalog. Blue and grey color scheme.


Step 3: Paste this code in the Body - End section.


Edit Custom Code window on Wix with a code snippet and settings on a Wix dashboard. Blue interface with sidebar options visible.




The code explanation


An event listener of DOMContentLoaded is added to the document, which only executes a function when the page loads.


Inside the replaceCheckoutButton function, the querySelector element then selects the button using the data-wix-checkout-button attribute. Then, its value is stored in the originalButton variable.


The conditional statement checks if the original button exists. If it exists, it creates a new button using the createElement attribute and stores it in the newButton variable. 


A ‘Checkout’ text is then added dynamically to the new button using textContent. The same class as the old button is then added using className to the new button to retain its old styling.


Then style elements are added to the button to make it visually appealing.

The click event listener is then added to the button to navigate to the ‘Custom checkout’ page once the button is clicked. 


The originalButton.replaceWith(newButton) replaces the old button with the new button we just created.


The replaceCheckoutButton function is then invoked immediately after the page loads.


To prevent Wix from reverting the button to the old one once it is clicked, MutationObserver is used to watch for changes in the DOM, i.e., if Wix tries to re-render the button. Then, if the old button reappears, replaceCheckoutButton() runs again to replace it


Step 4: Rename the custom code to a more friendly name to make it easier to find on your list later on.


Wix Web interface shows "Edit Custom Code" window in Wix Studio. A script is added with name "Custom Checkout". Pointer highlights the name field.

Step 5: To make the code work only on the Cart page, change the page from ‘All pages’ to ‘Cart’ page only.


Wix Web interface showing "Edit Custom Code" dialog. A dropdown menu selects "Cart" for code placement. Dark sidebar on the left.

Step 6: Place the code in the Body - end to make the code only run after all the HTML on the page loads.


Wix Studio interface showing "Edit Custom Code" popup. Options include adding code to specific pages and selecting code placement.

Step 7: Click ‘Apply’ to apply all the changes you have made.


Edit Custom Code window on Wix dashboard. Options to add code to pages and place code in body-end are selected. Apply button is highlighted.

Now that we have dynamically added our new functionalities using custom code, let’s get to see the functionality in action. 


Step 1: Navigate to the live site.


Step 2: Refresh the page. You don’t need to republish the site because custom codes are active as long as they are toggled on and will work just by refreshing the page.


Step 3: Click the checkout button.


Wix Online shopping cart showing two items with prices, a $95 total, and a highlighted "Checkout" button. Neutral design with white background.

Notice how it directly navigates to the custom checkout page instead of the native WIX checkout page.


Wix Minimal online store interface with "Ceramic Studio" text, currency selector, login, cart icons, and navigation links. Social media icons on the right.


Voilà! We have successfully implemented our functionality to redirect customers to our customized checkout page with just a click.


Now, you can add more functionalities using Wix APIs, like custom forms, to customize the checkout experience.



Conclusion


Creating a customized checkout page offers several benefits, but implementing it on your website while using the native Wix cart page can be daunting and complex. In this article, you learned how to bypass this complex process by hijacking the checkout button and directing customers to a customized checkout page using a custom code. 


Now that you have successfully added this functionality, you can further enhance it by adding more features and functionalities to your customized checkout page. 


Want to learn more? Ready to dive deeper into Wix and Velo? Take your skills to the next level with our comprehensive Velo for Beginners' course on Udemy. Enroll today to uncover the intricacies of Wix and Velo.


Need help with your site? The Wix Wiz team is at your side. Schedule a one-on-one consultation or have the entire team onboard with our development and support plans.


 
 
 

RESOURCES

Become part of a thriving community

CONTACT US

Let's Make Some Magic!

Have a project in mind? Question? Just want to say hi?

Get in touch, and let’s bring your vision to life!

CONTACT INFORMATION

WHAT IS THE NATURE OF INQUIRY?

WHAT IS THE NATURE OF YOUR INQUIRY?
bottom of page