Using a plugin (recommended)
The easiest way to add the widget without editing theme files is with the Insert Headers and Footers plugin.Install the plugin
In your WordPress admin, go to Plugins → Add New, search for Insert Headers and Footers, and click Install Now, then Activate.
Add the script
Go to Settings → Insert Headers and Footers. Paste the script into the Scripts in Footer field.
Using functions.php
If you prefer to keep the widget inside your theme, add this to yourfunctions.php:
functions.php
WooCommerce — specific pages only
To load the widget only on certain WooCommerce pages, use conditional tags infunctions.php:
functions.php
is_checkout() and is_cart() for any WordPress conditional tag to target the pages you need.