How to launch or close your Coupon X for WordPress widget using JavaScript

In this guide we’ll show you how you can launch and close your Coupon X widget using a link or a JavaScript function in a few super simple and quick clicks. Click to read more about how to use Coupon X for WordPress.

You can use the plug-in to create announcement popups and to collect emails using email sign up popups. If you want to offer discount codes, you will need to have WooCommerce installed and activated on your site, since discount codes are based on WooCommerce. If you are planning to use the plug-in for announcement popups only, it will work without WooCommerce as well.

You can use this feature to launch or close your widget from anywhere on your website, through a button, and with whatever criteria you want to be met, for example you can only show the widget after other JavaScript commands fire or hide it after a JavaScript command fires.

How to open your Coupon X widget

Let’s take the example from above. To launch the Coupon X widget with a JavaScript function, add a button. It will serve as your custom button that visitors will click to open the Coupon X widget. Then, add this code:

javascript:launch_couponx();

You can also use this code with a number inside the brackets, e.g. (1), (2) if you have more than one widget in that page.

How to close your widget

To close the Coupon X widget with a JavaScript function, add a custom button, just like in the above example. It will serve as a button that visitors will click to close the Coupon X widget. Then, add the JavaScript function.

javascript:close_couponx();

Again, you can also use this code with a number inside the brackets, e.g. (1), (2) if you have more than one widget in that page.

When you’re done, don’t forget to hit ”Save” at the top of the page. That’s it! Easy as 1,2,3 


Still have questions? Ping us at our Facebook group, and we’d love to help out!