ADO.NET Provider for WooCommerce

Build 20.0.7587


Retrieve and modify coupons.

Table Specific Information


WooCommerce allows only a small subset of columns to be used in the WHERE clause of a SELECT query. These columns support only the = comparison, unless stated otherwise. The available columns for this table are: Id, Code. All other columns are processed client side.

SELECT * FROM Coupons WHERE Id = 4
SELECT * FROM Coupons WHERE Code = 'criteria'


To perform an update or insert using any of the aggregate columns which contain simple primitive arrays, we can simply pass a JSON array string as the value:

UPDATE Coupons SET ProductIdsAggregate = '[14, 16, 29]' WHERE ID = 42

To introduce new metadata fields which are not present in the schema, the 'metadata' pseudocolumn can be used. The update below will create two new metadata fields with keys 'key1' and 'key2' and set their respective values. If any of the keys specified already exists, its value will be updated.

UPDATE Coupons SET metadata = 'key1:val1, key2:val2' WHERE ID = 58


The following attribute is required when performing an insert: Code.

INSERT INTO Coupons (Code) VALUES ('coupon_code')


Name Type ReadOnly Description
Id [KEY] Integer True

Unique identifier for the object.

Code String False

Coupon code.

Amount String False

The amount of discount. Should always be numeric, even if setting a percentage.

DateCreated Datetime True

The date the coupon was created, in the site's timezone.

DateModified Datetime True

The date the coupon was last modified, in the site's timezone.

DiscountType String False

Determines the type of discount that will be applied. Options: percent, fixed_cart and fixed_product. Defaults to fixed_cart.

Description String False

Coupon description.

DateExpires Datetime False

The date the coupon expires, in the site's timezone.

UsageCount Integer True

Number of times the coupon has been used already.

IndividualUse Boolean False

If true, the coupon can only be used individually. Other applied coupons will be removed from the cart. Defaults to false.

ProductIdsAggregate String False

List of product IDs the coupon can be used on.

ExcludedProductIdsAggregate String False

List of product IDs the coupon cannot be used on.

UsageLimit Integer False

How many times the coupon can be used in total.

UsageLimitPerUser Integer False

How many times the coupon can be used per customer.

LimitUsageToXItems Integer False

Max number of items in the cart the coupon can be applied to.

FreeShipping Boolean False

If true and if the free shipping method requires a coupon, this coupon will enable free shipping. Defaults to false.

ProductCategoriesAggregate String False

List of category IDs the coupon applies to.

ExcludedProductCategoriesAggregate String False

List of category IDs the coupon does not apply to.

ExcludeSaleItems Boolean False

If true, this coupon will not be applied to items that have sale prices. Defaults to false.

MinimumAmount String False

Minimum order amount that needs to be in the cart before coupon applies.

MaximumAmount String False

Maximum order amount allowed when using the coupon.

EmailRestrictionsAggregate String False

List of email addresses that can use this coupon.

UsedByAggregate String True

List of user IDs (or guest email addresses) that have used the coupon.

Copyright (c) 2020 CData Software, Inc. - All rights reserved.
Build 20.0.7587