LogoLogo
Build appsContact API support
Discounts and tips
  • Build apps
  • Site Templates
  • API Reference
  • Changelog
Discounts and tips
  • Discounts and tips overview
  • Add discounts to the store
    • Automatic discounts (promotions)
    • Discount coupons
    • Bulk discount prices for products
    • Discounts calculated on your server
  • Add tips or surcharges to the store
    • Add tips selection to the checkout
    • Apply hidden surcharges
    • Calculate surcharges on your server
  • Customize discounts
    • Set up "Buy X - Get Y" promotions
    • Set up "Free shipping" promotions
    • Set up start and end dates for discounts
    • Limit discounts to customer groups
    • Limit discounts by products and categories
    • Limit the number of discount coupon uses

Lightspeed® 2025

On this page
  • Connect JS API
  • Configure the tips block with the code
  • See also

Was this helpful?

  1. Add tips or surcharges to the store

Add tips selection to the checkout

PreviousDiscounts calculated on your serverNextApply hidden surcharges

Last updated 2 months ago

Was this helpful?

You can add a configurable block with tip selections for customers at the end of the checkout with JavaScript code.

Connect JS API

To apply the JavaScript code, you need to enable Ecwid JS API on your storefront. To do so, set up a self-hosted JavaScript file running on your server and use the code example below.

Jump into the .

Configure the tips block with the code

Start easily with the code example below:

Ecwid.OnAPILoaded.add(function () {
	Ecwid.OnPageLoaded.add(function (page) {
		if (page.type == "CART") {
			window.ec = window.ec || {};
			ec.order = ec.order || {};
			ec.order.extraFields = ec.order.extraFields || {};

			ec.order.extraFields.tips = {
				'type': 'toggleButtonGroup',
				'options': [
					{
						'title': 'No tip',
					},
					{
						'title': '5%',
						'surcharge': 5
					},
					{
						'title': '10%',
						'surcharge': 10
					}
				],
				'surchargeType': 'PERCENT',
				'surchargeShortName': {
					'name': 'Tip',
					'showSurchargePercentValue': true,
					'nameTranslated': {
						'en': 'Tip',
						'nl': 'Tip'
					}
				},
				'showZeroSurchargeInTotal': false,
				'required': true,
				'checkoutDisplaySection': 'payment_details'
			};

			window.Ecwid && Ecwid.refreshConfig();
		}
	});
});

This example adds a required extra field where customers must choose one of the tip options specified in the code (0%, 5%, 10%). By default, the last option is chosen when the extra field is required ('required': true).

For customers, it will look like this:

You can specify your tip values by changing numbers and adding/removing objects in the options array.

See also

Full documentation on setting up extra fields with tips selection:

Checkout extra fields
Quickstart guide