Custom Discounts API

The Revy Unlimited Bundles app has a feature via API that allows adding extra discounts to the Bundle Discount, this feature was created due to the Shopify Discount limitation which allows applying just one discount to an order, using this feature you can stack more discounts to the Bundle Discount.

Basically, this feature adds more discounts to the Bundle Discount, here is an example:

  1. The customer has a Bundle with product A and B and this Bundle have a discount of $5 OFF; 
  2. Our app will generate a Bundle Discount with the value of $5; 
  3. Now, let's say the customer adds a third product, the C product.
  4. Merchant wants to add a discount on the product C of $3; 
  5. Using the Bundle API he can use this command to add the discount:
window.RevyBundle.api.addCustomDiscount({
	id: "product_c_discount",
	quantity: 1,
	variant_id: VARIANT_ID_OF_PRODUCT_C,
	discount_type: "fixed_amount",
	discount_value: 3,
	discount_title: "Product C Discount"
})

In this example the discount of product C will be incorporated in the Bundle Discount, the final Bundle Discount value will be $8, the original Bundle Discount($5) plus the Custom Discount($3).

Conditions

There are conditions that need to meet in order for the Custom Discount to applies correctly:

  • Make sure you select the "Draft Order" discount type on your Bundle App settings
  • Cart matches a Bundle (if cart not matches a Bundle it will not exist a Bundle Discount that the Custom Discount can be applied to)
  • A Custom Discount will only apply to variants that not belongs to matched Bundles, to avoid 1 variant to be discounted multiple times, the variant can only be discounted once(or by the Bundle Discount or by the Custom Discount)
  • The ID of the Custom Discount needs to be unique, if another Custom Discount with the same ID be added, it will replace the current one with the same ID

Adding a Custom Discount

The Custom Discount API is quite simple, it uses our Javascript API:

window.RevyBundle.api.addCustomDiscount(Bundle Discounts..)

The attributes of the Custom Discounts are:

id: Unique identifier of the Custom Discount, can be a number or a string, just keep it small. 

variant_id: Variant id of the product that will be discounted

quantity: Quantity of the variant that the Discount will be applied

discount_type: The possible values are "percentage", "fixed_amount" and "free_gift"(reduced 100% of the variant price)

discount_value: The value of the discount, you can use an integer or a float, but don't add a currency symbol, examples: "5.00", "5", 5, 5.0

discount_title: A small text describing the discount, it will show on the line item discount description, keep it small, 2 or 3 words at maximum, or keep it empty

The complete command to generate a example discount would be:

window.RevyBundle.api.addCustomDiscount({
	id: "christmas_20_percent",
	quantity: 1,
	variant_id: 113847474844,
	discount_type: "percentage",
	discount_value: 20,
	discount_title: "Christmas 20% OFF"
})

Removing a Custom Discount

To remove a custom discount just use:

window.RevyBundle.api.removeCustomDiscount(DISCOUNT_ID)

Retrieve all Custom Discounts

To remove a custom discount just use:

window.RevyBundle.api.getCustomDiscounts()

Remove all Custom Discounts

To remove a custom discount just use:

window.RevyBundle.api.clearCustomDiscounts()

Please let us know if you need any help setting up the Custom Discounts API, we will be happy to answer you, just ping us at [email protected] ;)

Still need help? Contact Us Contact Us