Do I have to import my catalog to create products-specific rules?

No, you don't have import your inventory to use product-specific rules in your campaigns. That means there is no need of storing products catalog in Voucherify upfront and up-to-date.

 But firstly, you need to understand the 'request' entity.

What is a redemption request?

When your system is integrated with Voucherify, every time someone tries to redeem a code, the validation and redemption request is sent to Voucherify API. This request is equipped with all customer and order details including product metadata (if added). 

When a redemption request is sent, dependently on validation rules and campaign limits, Voucherify sends a response to your system which tells if redemption is succeeded or failed. 

The Voucherify engine enables you to assign custom attributes as metadata to products/SKUs in the order in the moment of invoking a redemption. Read on to see the workflow.

How it works


1

Firstly, it's recommended to use Metadata Schema to define custom attributes for your products which then, can be used while creating validation rules. In the Schema, you don't attach these attributes to specific products, you just define their names, types, and values (optional). The detailed guide describing how to add custom product attributes with Metadata Schema is here.

2

When you have product metadata defined, you can create a promo campaign with validation rules based on product metadata. As a result, all the products in the order will be validated accordingly to the rules with product metadata. You can see how to add validation rules with product metadata in this section.

3

When the campaign is fired off, your customers can start redeeming codes. And so, we're coming back to the validation/redemption request. When creating a redemption request via API you can add products with metadata from scratch. When a redemption request gets to Voucherify, metadata assigned to ordered products will be compared to the validation rules with product metadata assigned to the code. 

For example, there is a campaign of unique codes with 10% discount with the following validation rule attached:
While invoking a code's redemption, I can add a product/products to the redemption request details. These products aren't in Voucherify inventory, they are created from scratch.
{
  "customer": {
    "source_id": "source@voucherify.io"
  },
  "order": {
    "amount": 70000,
    "items": [
      {"quantity": 1, "source_id": "FOR-1", "related_object": "product", "price": 30000, "amount": 60000, "product": { "metadata": { "Category": "Electronics" } } }
    ]
  }
}
	

In the next step, Voucherify will verify if validation rules attached to this code (Product metadata satisfy: Category is Electronics) are met by a customer and his/her order. In this case, Voucherify compares product metadata attached to code (in a validation rules object) with product metadata attached to products in a customer's order.

If you'd like to learn more, please follow our tech docs. We've presented example API requests with detailed info.

tech-docs-validation-rules