Skip to main content

How to trigger a Wordpress button to open Double

In this article we'll explain how to trigger a Wordpress button to open Double using Elementor

Updated over a month ago

There are several ways to make a button open the Double checkout, but the method below uses a class ID, which is the cleanest and most reliable approach - and the one we recommend using.

If your website is built with WordPress + Elementor, follow these steps to trigger the Double checkout when a visitor clicks a button.

Step 1 - Add a button in Elementor

  1. Open the page where you want the donation button to appear.

  2. Drag a new Elementor Button widget onto the page, or select an existing button you’d like to use.

  3. Under Advanced → CSS Classes, enter a class name (for example):

    open-double

    💡 You can name it anything you want — just make sure it matches the script below.

Step 2 - Add a small script to open the Double checkout

Now you’ll tell your website to open the Double checkout when that button is clicked.

  1. Go to Elementor → Custom Code → Add New.

  2. Give it a name like “Open Double Button” - this will make it easy to identify later on.

  3. Set Location: Before </body>.

  4. Paste this code:

    <script>
    document.addEventListener('DOMContentLoaded', function() {
    const buttons = document.querySelectorAll('.open-double');
    buttons.forEach(btn => {
    btn.addEventListener('click', function(e) {
    e.preventDefault();
    if (window.Double) {
    Double.openWidget();
    } else {
    console.error('Double embed not loaded yet.');
    }
    });
    });
    });
    </script>
  5. Publish the script.

💡 Pro tip

You can use the same script for multiple buttons - just give them all the same CSS class (e.g., open-double).

Did this answer your question?