This tutorial will guide you through the installation and configuration of a Voucherify-WooCommerce plugin. Then, you’ll learn how to use it to leverage Voucherify coupons and cart-level promotions on your WordPress site.Documentation Index
Fetch the complete documentation index at: https://docs.voucherify.io/llms.txt
Use this file to discover all available pages before exploring further.
Supported features
Before you start creating promo campaigns for your WooCommerce audience, read the summary of Voucherify features that are supported in the plugin and make sure your use cases are covered. Features:- Syncing orders, products, SKUs, and customers
- Gift cards
- Percentage discount coupons
- Amount discount coupons
- Free shipping coupons
- Unit discount coupons with free products (no support for product variants)
- Cart-level discounts:
- percentage
- amount
- free shipping
- unit discount with free products (no support for product variants)
- All discounts are applied to the whole cart.
- Paying with Loyalty Points
- Referral coupon codes
- Fixed discount effect
- Dynamic Discounts
- Applying discounts to order-line items
- Capping discounts to a number of units
Installation
To start with, log into your WooCommerce account and follow these steps:- Go to the Plugins and choose Add New.
- Search for Voucherify plugin.
- Click Install Now.
- After installation, select Activate.
Configuration
When the plugin is active, you can connect both accounts in four steps:- Log into your Voucherify account and go to the Project settings.
- Copy your Application ID and a Secret Key.
- Enter your WordPress account and select Voucherify.
- Paste “App ID” and “App Secret Key” and mark Voucherify integration enabled. Confirm with Save Changes, and you’re ready to go!
Use Voucherify coupons on your WordPress site
Now, your visitors can redeem Voucherify coupon codes to get a discount while shopping on your WordPress site. The workflow looks as follows:- A customer selects products and adds them to the cart.
- In a cart summary, they can see a field for a coupon code.
- The customer enters a Voucherify code, and after choosing the Apply coupon, their order is automatically updated. Applied discounts are also visible on a checkout page and order summary.
- You can see redeemed coupons in your WordPress dashboard. Go to the Orders section and choose which order you’d like to display. If any coupon has been applied, you’ll see it in the details.
Synchronize
The Synchronize button synchronizes all products, SKUs, customers, and orders that have not been synchronized yet. The resources that have already been synchronized are skipped in this action. Remember that under normal circumstances, all resources are synchronized automatically when they are created or edited. Synchronize your resources if:- You have resources in your WooCommerce platform and you have just installed the Voucherify plugin.
- You have temporarily disabled the Voucherify plugin and added new resources.
- The API has been temporarily unavailable.
- You have added resources manually to a database and not through Wordpress or WooCommerce.
Resynchronize all
The Resynchronize button synchronizes all existing products, SKUs, customers, and orders, including those that have been already synchronized. Resynchronize all your resources if:- You have a WooCommerce shop integrated with Voucherify, but you have changed the Voucherify project and you need to add your resources to a new project.
- There have been issues that caused resources to be marked as synchronized, but they are not present in Voucherify.
Cart-level promotions
Besides the coupon campaigns, you can use Voucherify cart-level promotions on your WordPress site.- Firstly, create promotion tiers and define rules in the campaign manager (read more details here).
- While shopping, users can see current promotions defined in your Voucherify account.
- If a cart meets the required conditions, a box with available promotions appears. When the customer selects Apply promotion, the cart updates automatically following the promotion rules. If more than one promotion is available for a single cart, users need to select which one they would like to apply during the purchase.
- Similarly to the coupon codes, you can see applied promotions in the WordPress dashboard.
Tracking performance
Once the plugin is configured, you will be able to use coupon codes, gift vouchers, referral codes, promotions, and loyalty cards. For more tracking data, you can visit the Voucherify dashboard. In the Redemptions and Customers sections, Voucherify collects and presents detailed up-to-date information. You can read more about tracking in this guide.WooCommerce custom snippets
Without any additional development work, the plugin itself provides a set of features that you can work with. You can extend the capabilities of the plugin by adding custom scripts to WooCommerce. With these scripts you can, for example:- Synchronize customer creation (described in this document)
- Synchronize orders, allowing your customers to gain points for making a purchase (described in this document)
- Get balance on Loyalty Cards (described in this document)
- Show your customers unique coupon codes in a popup using the Create Publication API call
- Show the list of vouchers for a single customer using the List Vouchers API call
- And many more!
Code snippets
While there are a couple of ways to introduce custom code to WordPress and WooCommerce, we will use the Code Snippets plugin available from the WordPress marketplace. You can download it using this link. Once the Code Snippet plugin is installed, you will have the option to add your snippets.Creating a custom script
To introduce a custom script, you need to define when this script should be run and the outcome of the script. When a specific action is taken in WooCommerce, the custom code is triggered and we will explain how this action will affect Voucherify.WooCommerce hooks
Hooks in WordPress essentially allow you to change or add code without editing core files. They are used extensively throughout WordPress and WooCommerce and are very useful for developers. There are two types of hooks: actions and filters.- Action hooks allow you to insert custom code at various points (wherever the hook is run).
- Filter hooks allow you to manipulate and return a variable which it passes (for instance, a product price).
woocommerce_order_status_changed action hook, but the hook might be different depending on your cases.
woocommerce_order_status_changed hook returns the order_id. Therefore, we will use the order_id to get the status of the order later on.
You can learn more about the idea of action hooks in WooCommerce’s documentation.
Code snippets tutorial
This part of the tutorial will focus on the script itself. The script will have to connect to Voucherify using an API call. To send out an API call from WordPress, you need to use thewp_remote_post function documented under this link. This method contains two arguments:
- $url - URL to the API endpoint
- $args - Request arguments.
Example snippets
Synchronize orders
This code snippet will synchronize orders between WooCommerce and Voucherify. It will synchronize only the customer who is making the purchase, the status of the purchase, and the amount of the whole cart.Synchronize customers
This code snippet will create a customer in Voucherify once a customer is created in WooCommerce.Show loyalty balance
This code will show how many points the customer has. The HTML should be styled. To use the “GET” HTTP method you need to use the wp_remote_get function.Troubleshooting
This section explains how to debug your scripts and find the issues.Code Snippet’s safe mode
Your code can crash the site. In some cases, you might even lose access to the dashboard because your code has a bug that crashes every time you log in. Code Snippets team provides a safe mode that helps in that case. You can learn more about the safe mode under this link.WooCommerce logs
Logs can be found on the dashboard of a site. To view the logs:- Go to WooCommerce > Status
- Click on the Logs tab
- Choose a log from the drop-down

