Skip to main content
Once a customer has subscribed to products, they also want to stay in control of them: see when the next delivery is due, change the quantity, pause a subscription for the summer or end it entirely. There is a separate page in the shop for this, and the tags on this page build it. Everything revolves around a loop. SUBS-Data loops over the subscriptions of the logged-in customer, and within this loop all other tags return the details for the respective subscription.
  • Guide: Subscription module
  • Reference: SUBS- (taking out a subscription)

The loop over the subscriptions

SUBS-Data can do three things: output the number of subscriptions as a single tag, check as a bracketing whether there are any at all, and loop over them.
All other tags on this page are invalid tags outside the SUBS-Data loop. This also applies within the {SUBS-Data} bracketing, because only the loop determines which subscription is meant. The exception is the two tags for the button that triggers new subscriptions.
SUBS-Data is not limited to the management page. The loop works on all templates as long as a buyer is logged in. On an overview page, for example, you can use it to display the number of running subscriptions.

The subscribed product

Product name, price and currency code are stored on the subscription and date from the time of the last order or the last change to the subscription. They are therefore a snapshot and not the current state of the product. If the current price is to appear, reload the product via its index.
SUBS-Data_Index is the identifier the shop system uses to address this one subscription. It is contained in all field names within the loop and ensures that a form page with several subscriptions remains unambiguous.
SUBS-Data_SubShop() optionally takes subshop identifiers as parameters and then applies as a bracketing only for these. Without a parameter, it outputs the identifier in which the product was subscribed.

The delivery interval

Here, too, the codes do not follow the length of the periods. The week has code 3 and comes after the year. Therefore, never evaluate _unit_code with a size comparison.

Letting the customer change the interval

If the customer is to change the interval, build the same selection within the loop as on the product page. There, SUBS-CycleSelection_input automatically returns the field name related to this subscription, and SUBS-CycleSelection_data_selected compares against the stored interval instead of against a form input.
Reference: The cycle selection on the SUBS- (taking out a subscription) page

Points in time and counters

All four time values come as Unix timestamps and are converted into a readable form via the date tags.
For SUBS-Data_nextorder_unixtimestamp, only the date part is reliable. The time it contains says nothing about when on that day the order is actually placed.
All five tags apply as a bracketing when a value is present. For a newly created subscription, the time of the last order and the counter are still empty. Therefore, bracket the output instead of displaying a 0 or 1 January 1970.
Reference: DC- (date and time)

The state of the subscription

SUBS-Data_state_code outputs the technical code; four bracketings query it.
The four states are mutually exclusive. SUBS-Data_state_isactive applies exclusively for code 0 and therefore specifically not for a new subscription, even though it is also running. If you want to express “running” in the sense of “not paused”, use the negative bracketing of SUBS-Data_state_ispaused.
States 1 and 2 concern the transition from taking out the subscription to the first delivery. A subscription is initially new, and as soon as the first order has been triggered, it is considered triggered. After that, it switches to active.
SUBS-Data_state_code is exclusively a single tag. For case distinctions, use the four bracketings.

Pausing, resuming and deleting

Each action runs via its own button. SUBS-Data_Buttonname returns the name, the three Buttonvalue tags the value.
Pausing and resuming are only available in the appropriate state. SUBS-Data_Buttonvalue_pause returns nothing for an already paused subscription and does not apply as a bracketing there either; conversely, SUBS-Data_Buttonvalue_resume only applies for a paused subscription. Therefore, bracket the two buttons with their own tag so that only the sensible one appears in each case.
Deleting is always available. The bracketing of SUBS-Data_Buttonvalue_delete applies in every state and serves the consistency of the template rather than a case distinction.
Deletion happens without a confirmation prompt from the shop system. Build a safety prompt into the template, because the customer cannot restore an accidentally deleted subscription.

The feedback after an action

After submission, five tags per subscription tell you what happened to it.
Code 0 means “not affected”. It is never output, because in this case SUBS-Data_affected already does not apply. The four codes are therefore: 0 not affected, 1 changed, 2 paused, 3 resumed.
There is no feedback for a deleted subscription. After the action, it is no longer in the list, and the loop does not iterate over it. A success message for deletion therefore belongs outside the loop, not inside it.
The feedback applies to the call immediately after submission. If the customer reloads the page, it is gone.

Payment method, bank details and delivery address per subscription

These three details are stored on the individual subscription. All three tags output the value as a single tag and apply as a bracketing if it is set. With a parameter, they check for equality instead.
For index 0, the bracketing does not apply. Here this is not a missing value but a statement: for SUBS-Data_DelivAddress(), 0 means that no different delivery address is stored, and for SUBS-Data_BankIndex(), that no bank details are attached to the subscription. Catch this case with the negative bracketing.
In the example for SUBS-Data_BankIndex(), the previous documentation shows the comparison with SUBS-Data_PaymentCode(1) instead of SUBS-Data_BankIndex(1). This is an error in the original. The corrected comparison is shown here.
The bank index is only relevant for direct debit. For other payment methods, it is usually 0.

Building the selection for changes

If the customer is to change these three details, use the same _input and _selected tags as on the product page. Within the loop, the _input tags append the subscription identifier to the field name, so that a page with several subscriptions also remains unambiguous.
The _selected tags compare against the most recently submitted form input, not against the value stored on the subscription. For the stored state, use SUBS-Data_PaymentCode(), SUBS-Data_BankIndex() and SUBS-Data_DelivAddress() with a parameter. The exception is SUBS-CycleSelection_data_selected, which within the loop checks against the stored interval by itself.

Triggering new subscriptions

When the customer has just taken out a subscription, it initially appears as new in the list without any order having been placed yet. A separate button triggers the first order.
Both tags belong outside the SUBS-Data loop, because they refer to all new subscriptions at once and not to a single one. They are therefore also the only tags on this page that are available outside the loop.
The bracketing applies as long as at least one subscription is in the “new and active” state, that is, code 1. An already triggered subscription with code 2 no longer counts.

Tags at a glance

The table reflects the tag mask of the shop system. Several tags are permitted as single tags in it but output nothing there. This concerns all pure bracketings, that is, the units, the states and the tags of the SUBS-Data_affected family. The previous documentation lists these tags only as bracketings, which corresponds to their sensible use.
All tags except SUBS-Buttonname and SUBS-Buttonvalue_triggernewsubscriptions belong in the SUBS-Data loop. Outside it, they are invalid tags.
  • Guide: Subscription module
  • Reference: SUBS- (taking out a subscription)
  • Reference: E-SUBS- (subscription module)
  • Reference: DC- (date and time)
  • Reference: Subscription section in the shop configuration