Skip to content

Subscribe button

The subscribe button shows the subscription price with its discount and lets the shopper pick how often to deliver the product. Place it under the «Buy» button on a product page, in a catalogue card or in a cart row.

Subscribe button: subscribed (left) and available (right)

  • Subscription price and discount right on the button.
  • Delivery frequency from the shop’s presets or a custom interval.
  • Changing and removing a product subscription.
  • The same state on every page and tab: product page, catalogue, cart.
  1. The shopper clicks «Subscribe» and the frequency window opens.
  2. They pick a frequency and click «Add subscription». The button switches to «Subscription added».
  3. The choice is kept in the shopper’s browser. Your cart takes it with getOrderItems() when it creates the order.

The button does not add the product to your cart and does not create an order — your page does.

<neocarts-button
product-id="food"
amount="249000"
title="Brit Care Adult Large Breed Lamb & Rice"
image="https://shop.example.com/img/brit-care-12kg.png"
variant="12 kg"
checkout-url="/cart"
></neocarts-button>

The script must be embedded on the page.

Attribute Type Required Description
product-id string yes Your product ID — the same external_id as in the order line. Example: food
amount integer yes Price of one unit in kopecks, before discount, greater than 0. Example: 249000 = 2 490,00 ₴
title string yes Product name in the subscription window
image URL yes Product image in the subscription window
variant string no Variant under the name. Example: 12 kg
checkout-url URL no Adds a «Go to checkout» button after the subscription is saved. Only http(s) or a relative path

If a required attribute is missing or amount is not a positive integer, the button is not shown and the console gets a warning listing the problems:

[Neocarts] <neocarts-button product-id="food"> hidden: missing or invalid amount, image

Attributes can be changed by script — the button updates itself. Buttons can be added at any time (SPA, infinite scroll).

State When What the shopper sees
Available no subscription for the product «Subscribe», «−7% on every delivery», old and new price
Subscribed the shopper added a subscription «Subscription added», subscription price and discount, delivery frequency, «Change»
Hidden the shop has not finished payment or delivery setup, or the page has no shop id nothing
Available Subscribed
Button in the Available state Button in the Subscribed state

The shop sets the discount in Settings → Subscriptions. Without a discount the button shows «Regular delivery with Neocarts» and a price without strikethrough.

The discounted price on the button is a preview. Final totals are computed by the server when the order is created (Money and rounding).

The delivery frequency window

  • Product — image, name, variant, discounted price.
  • How often to deliver — the shop’s presets and «Other frequency…» (every N days or weeks, within the shop’s limits).
  • Subscription price — savings on every charge and the date of the next charge.
  • «Add subscription» — saves the choice. In edit mode: «Save changes» and «Remove subscription».

There is no quantity in the window: it stays in your cart. Delivery is paid to the carrier separately.

After saving, the shopper sees a confirmation with «Continue shopping» and, if checkout-url is set, «Go to checkout».

Subscription added

The button only remembers the frequency for a product-id. The cart stays yours, so connect the two in two places.

A subscription on a product that is not in the cart. The shopper can subscribe from a catalogue card without adding the product to the cart and then click «Go to checkout». So that the cart is not empty, add the product when a subscription appears:

NeocartsSubscription.subscribe((all) => {
for (const [id, s] of Object.entries(all)) {
if (s.mode === 'subscription' && !cart.has(id)) {
cart.add(id, 1); // your cart
}
}
renderCart();
});

subscribe() calls the function with all of the shopper’s choices on every change. Leave a product that is already in the cart alone: its quantity stays, and getOrderItems() turns it into a subscription.

Removing from the cart. When the shopper removes a product from the cart, forget its choice too, otherwise the product comes back as a subscription as soon as it is added again:

NeocartsSubscription.remove(id);

«Remove subscription» in the subscription window forgets only the choice: the product stays in the cart and goes into the order as one_time. If it should disappear together with the subscription, remove it from the cart in the same subscribe().

Explains the subscription to the shopper: frequency, a reminder 3 days before each charge, card payment through the shop’s payment provider, managing the subscription. Opens from the «How it works» link in the subscription window or from your own button:

<button type="button" onclick="NeocartsSubscription.openHowItWorks()">How does the subscription work?</button>

The «How the subscription works» window

  • The button takes the full width of its parent block. Put it in the same column as your «Buy» button.
  • In a narrow container (under 256 px) the button stacks into two lines — for catalogue cards on phones.
  • Do not give the container display: contents — the button will always be narrow.
  • The button can sit inside a link card <a>: clicking the button does not follow the link.

Colours come from the shop’s palette (Palettes and languages); page styles do not affect the button.