PHP

If you use Wordpress with the Woo Commerce plugin, you're in the right place

This is a guide for advanced users who can code in PHP. The easiest way to integrate Tento widgets is through Wordpress plugin. No-Code Installation in 2 minutes for Wordpress / WooCommerce

Here are the following steps to getting Tento integrated with your WooCommerce shop on Wordpress without the plugin for wider control:

1: Download a plugin like CodeSnippets, or something similar, to inject javascript into your ecommerce site

2: Create a new or edit an existing snippet, and add the following code. These blocks of code can all be used in the same CodeSnippet.

add_action('wp_footer', function() {
    ?>
    <script src="https://scripts.tento.co/embed/embedded.min.js"></script>
    <?php
});

This will add the tento embedded library in the background of your webapp.

add_action('woocommerce_after_add_to_cart_form', function() {
    echo '<div id="button-container-bcm" class="button-container-bcm"></div>';
}, 25);

This will give the add to cart form a div to attach the next snippet of code to:

add_action('wp_footer', function() {
    if (is_woocommerce()) {
        ?>
        <script>
            document.addEventListener("DOMContentLoaded", function() {
                if (typeof window === 'undefined' || typeof document === 'undefined') return;
                if (document.querySelector('#button-container-bcm button') && document.querySelector('#button-container-financing button')) return;

                if (window.Tento) {
                    window.Tento.appendBcmButton({
                        text: 'See My Credit Score',
                        selector: '#button-container-bcm',
                        data: {},
                    });
                    window.Tento.appendFinancingButton({
                        text: 'See My Financing Options',
                        selector: '#button-container-financing',
                        data: {},
                    });
                }
            });
        </script>
        <?php
    }
});

This will attach the relevant buttons to the previously created div.


Here are some screenshots for guidance: