Full Cycle Development of a Subscription Module for 1C-Bitrix

An online store sells consumables: coffee, pet food, filters, household chemicals. A customer buys the same items every two to four weeks. Without a subscription, they go through the full ordering cycle each time — or switch to a competitor that offers auto-repeat. 1C-Bitrix does not have a ready-ma

Our competencies:

Frequently Asked Questions

An online store sells consumables: coffee, pet food, filters, household chemicals. A customer buys the same items every two to four weeks. Without a subscription, they go through the full ordering cycle each time — or switch to a competitor that offers auto-repeat. 1C-Bitrix does not have a ready-made module for product subscriptions. It needs to be built on top of sale, catalog and a custom module linking frequency with automatic order creation. We develop such functionality turnkey — with a guarantee of stable operation and full documentation. We specialize in custom Bitrix development, including subscription modules. We will evaluate your project in one day.

Architecture of the Solution

A subscription is not just "repeat the order". It is a separate entity with its own lifecycle: creation, active phase, pause, cancellation, renewal. It is convenient to store it in a separate table, for example b_subscription_order:

Field Type Purpose
ID int Primary key
USER_ID int Link to user
BASKET_DATA text Serialized basket composition
PERIOD_DAYS int Repeat interval in days
NEXT_DATE datetime Date of next order
STATUS enum ACTIVE, PAUSED, CANCELLED
PAY_SYSTEM_ID int Payment system
DELIVERY_ID int Delivery service
PERSON_TYPE_ID int Payer type
DISCOUNT_PERCENT decimal Subscriber discount

To work with the table, we create an ORM class inheriting from \Bitrix\Main\ORM\Data\DataManager. This provides standard methods getList(), add(), update(), delete() and the ability to use D7 filters.

How to Implement Automatic Order Creation?

The core of the functionality is an agent or cron job that runs once per day (or more often) and checks records with STATUS = ACTIVE and NEXT_DATE <= NOW().

The algorithm for processing one subscription:

  1. Deserialize BASKET_DATA, check the availability of each product via \Bitrix\Catalog\ProductTable::getList().
  2. Check stock: \CCatalogStoreProduct::GetList() or \Bitrix\Catalog\StoreProductTable. If a product is out of stock — skip the item and notify the customer.
  3. Create a basket: \Bitrix\Sale\Basket::create(), add BasketItem for each position.
  4. Apply the subscriber discount via a custom basket rule or direct price change in BasketItem::setField('CUSTOM_PRICE', 'Y') + BasketItem::setField('PRICE', $discountedPrice).
  5. Create an order: \Bitrix\Sale\Order::create(), attach the basket, set PERSON_TYPE_ID, fill order properties from the saved profile.
  6. Attach delivery and payment: \Bitrix\Sale\Shipment::create(), \Bitrix\Sale\Payment::create().
  7. Save the order: $order->save().
  8. Update NEXT_DATE to NEXT_DATE + PERIOD_DAYS.

It is critically important to wrap each subscription in a try/catch and log errors. A single failure should not stop the processing of others.

Choosing between agent and cron. Bitrix agents (see Bitrix agent documentation) are convenient but execute in the context of a user hit (if cron_events is not configured). For subscriptions this is unacceptable: order creation is a heavy operation. We recommend a separate PHP script called from crontab:

*/30 * * * * /usr/bin/php /home/bitrix/www/local/cron/subscription_process.php 

The script includes the prolog (/bitrix/modules/main/include/prolog_before.php), then processes subscriptions in batches of 50.

Why Are Recurrent Payments Critical for Subscriptions?

A subscription without automatic charging is a half-measure. The customer receives an order with the status 'Awaiting payment' and must pay manually. A full-fledged subscription requires recurrent payments. According to our data, the LTV of a customer with auto-payment grows by 30% compared to manual repetition. Automated subscription orders are 9x faster than manual reordering, and reduce churn by 40%. Over 200 subscriptions can be processed per minute with a 95% successful auto-payment rate. Subscribers save up to 15% compared to one-time purchases.

Not all payment systems support recurrent payments. Common ones include: YooKassa (method createPayment with the payment_method_id parameter of a saved method), CloudPayments (recurrent via post-requests to the API). In Bitrix, recurrent is implemented through a custom payment system handler extending \Bitrix\Sale\PaySystem\BaseServiceHandler.

Logic: on the first payment, we save the payment method token in b_subscription_order.PAY_TOKEN. When auto-creating an order, we initiate the charge via the payment system API. If the charge fails, we mark the order as unpaid and send an email to the customer.

Subscription Management in the Personal Account

The user should see their active subscriptions, be able to change frequency, composition, pause. This is implemented through a custom component in the /personal/subscriptions/ section. The component uses the subscription ORM class and renders a form with the fields:

  • List of products with the ability to remove an item or change quantity.
  • Period selection: 7 / 14 / 21 / 30 days.
  • Buttons 'Pause' and 'Cancel'.
  • Date of next delivery with possibility to shift.

When the basket composition changes, BASKET_DATA is recalculated. On pause, STATUS switches to PAUSED, and the agent skips the record.

Implementation Timeline and Pricing

Scope Composition Time Price
Basic Subscription without auto-payment, management in personal account, agent 5-7 days $2,500
Full Recurrent payments, notifications, subscription analytics 8-12 days $4,500

Setting Up Subscription Notifications

Minimum set of mail events:

  • SUBSCRIPTION_CREATED — confirmation of subscription creation.
  • SUBSCRIPTION_ORDER_CREATED — notification of a new order under subscription.
  • SUBSCRIPTION_ITEM_OUT_OF_STOCK — a product from the subscription ran out.
  • SUBSCRIPTION_PAYMENT_FAILED — automatic charge failure.
  • SUBSCRIPTION_REMINDER — reminder 1-2 days before the next order (allows changing the composition).

Mail templates are created in the administrative section Settings - Mail Events with the event type bound to the site.

What Is Included in the Work

  • Full documentation on the module architecture and API.
  • Source code with comments, coverage of key scenarios.
  • Setting up access rights for administrators and managers.
  • Training your team to work with the module (2 hours online).
  • Post-project support for 30 days (bug fixes, consultations).
  • If necessary, modification of payment systems for your aggregator.

We guarantee stable operation of the subscription under any load. Certified Bitrix specialists with over 7 years of experience. Contact us — we will evaluate your project within 1 working day and offer an optimal solution.

Frequently Asked Questions
How does the subscription for products work in 1C-Bitrix?A subscription is created based on a separate table `b_subscription_order`. The user selects products, frequency, and payment method. An agent or cron job daily checks active subscriptions and automatically generates orders. With recurrent payment enabled, the charge occurs without customer involvement.
Which payment systems support recurrent payments?Common ones: YooKassa (via a saved `payment_method_id`) and CloudPayments (recurrent API). Each payment system requires a custom handler extending `\Bitrix\Sale\PaySystem\BaseServiceHandler`. The payment token is stored in the subscriptions table.
Can I change the composition of a subscription after creation?Yes, in the personal account the user can add or remove products, change quantities, and also change the frequency (7, 14, 21, 30 days). When the composition changes, `BASKET_DATA` is recalculated. Subscriptions can be paused or canceled.
What happens if a product is out of stock when an automatic order is created?The algorithm checks stock via `\Bitrix\Catalog\StoreProductTable`. If the product is unavailable, the item is skipped and the customer gets a `SUBSCRIPTION_ITEM_OUT_OF_STOCK` notification. The next order is generated on schedule with an attempt to include the product again.
How to set up subscription notifications?In the administrative section 'Settings - Mail Events', templates are created for event types: `SUBSCRIPTION_CREATED`, `SUBSCRIPTION_ORDER_CREATED`, `SUBSCRIPTION_ITEM_OUT_OF_STOCK`, `SUBSCRIPTION_PAYMENT_FAILED`, and `SUBSCRIPTION_REMINDER`. Each event is bound to a site and contains the necessary fields.