Sales in Vend can be discounted in one of 2 ways, at the sale or line-item level. We’ll present both ways below.

Sale-level discounts

Adding a “total” discount at the sale level is done by adding a special vend-discount product line item.

Discount product

In Vend, we have the notion of system-wide internal products. These products are static and exist in every retailer account so you can be assured they are available to use. To find the discount_product_id of the vend-discount product, you can call the /api/2.0/retailer endpoint like:

https://{domain_prefix}.vendhq.com/api/2.0/retailer.

The discount_product_id will be used as the product_id of a register_sale_product. The quantity will have to be negative (-1) with the price being the discount amount on the sale.

The discount_product_id of that product is account specific and will not change throughout the lifetime of that account. It can be retrieved once and stored for later use on all discounted sales.

Discount line item

To add a discount to the sale a line item, using the discount product’s id needs to be added to the register_sale_prodcuts array like below. In this example, we have a sale with a product worth $13.80 ($12.00 price + $1.80 tax) discounted by 50%:

{
	//...
	"register_sale_products": [{
			"product_id": "b1d87b58-f019-11e3-a0f5-b8ca3a64f8f4",
			"quantity": 1,
			"price": 12,
			"cost": 8.73,
			"price_set": 0,
			"discount": 0,
			"loyalty_value": 1.38,
			"tax": 1.8,
			"tax_id": "b1d192bc-f019-11e3-a0f5-b8ca3a64f8f4"
		},
		{
			"product_id": "9a84e9e1-f038-11e3-a0f5-b8ca3a64f8f4",
			"quantity": -1,
			"price": 6,
			"cost": 0,
			"price_set": 1,
			"discount": 0,
			"loyalty_value": 0,
			"tax": 0.9,
			"tax_id": "b1d192bc-f019-11e3-a0f5-b8ca3a64f8f4"
		}
	]
	...
}

Even if the discount is expressed as a % value to the customer, the value of the discount line item’s price and tax should be calculated as the proportion of the total value of the sale and expressed in direct currency value.

NOTE: When adding the discount product to the sale, it’s price should be the positive value of the discount and the quantity should be -1.

Line item discounts

Discounting specific line items is done by modifying the price of the line item In the example below, a product worth $115 was discounted by 50%. The original, tax-exclusive price of that product was $100 and the tax was $15, both of which were reduced by 50%.

{
	//...
	"register_sale_products": [{
		"product_id": "06bf537b-c783-11e7-ff13-2ae5d02c65f5",
		"quantity": 1,
		"price": 50,
		"cost": 40,
		"price_set": 1,
		"discount": 57.5,
		"loyalty_value": 5.75,
		"tax": 7.5,
		"tax_id": "b1d192bc-f019-11e3-a0f5-b8ca3a64f8f4"
	}]
	...
}

WARNING: When using that kind of discount, it’s important to also set the price_set attribute to 1. This indicates to Vend that the value of this product was intentionally modified and should not be recalculated for pending sales which may be brought to the sell screen for further processing.

Which To Use?

Use the vend-discount product when you just want to apply a discount to the entire total of the sale. This will be easily viewable on the receipt as it’s own subtotal.

Apply a discount to an explicit line item if you have a number of product lines on a sale, but only certain products should receive a discount. This will ensure that each discounted line item has the amount of the discount displayed on the receipt.

Of course, there is nothing to stop you from posting a sale without a discount product line item or no discount value assigned against each of your product line items. But by using the vend-discount product or assigning discount values, you can be assured that your client can report on the discount values applied.