Back in Stock Notification for E-Commerce

Our company is engaged in the development, support and maintenance of sites of any complexity. From simple one-page sites to large-scale cluster systems built on micro services. Experience of developers is confirmed by certificates from vendors.
Development and maintenance of all types of websites:
Informational websites or web applications
Business card websites, landing pages, corporate websites, online catalogs, quizzes, promo websites, blogs, news resources, informational portals, forums, aggregators
E-commerce websites or web applications
Online stores, B2B portals, marketplaces, online exchanges, cashback websites, exchanges, dropshipping platforms, product parsers
Business process management web applications
CRM systems, ERP systems, corporate portals, production management systems, information parsers
Electronic service websites or web applications
Classified ads platforms, online schools, online cinemas, website builders, portals for electronic services, video hosting platforms, thematic portals

These are just some of the technical types of websites we work with, and each of them can have its own specific features and functionality, as well as be customized to meet the specific needs and goals of the client.

Showing 1 of 1 servicesAll 2065 services
Back in Stock Notification for E-Commerce
Simple
from 1 business day to 3 business days
FAQ
Our competencies:
Development stages
Latest works
  • image_web-applications_feedme_466_0.webp
    Development of a web application for FEEDME
    1161
  • image_ecommerce_furnoro_435_0.webp
    Development of an online store for the company FURNORO
    1041
  • image_crm_enviok_479_0.webp
    Development of a web application for Enviok
    822
  • image_crm_chasseurs_493_0.webp
    CRM development for Chasseurs
    847
  • image_website-sbh_0.png
    Website development for SBH Partners
    999
  • image_website-_0.png
    Website development for Red Pear
    451

Development of Back In Stock Notification for E-Commerce

When a product goes out of stock — the customer leaves. The "Notify When In Stock" form retains this demand: instead of losing a customer, the store gets a contact of an interested buyer and an opportunity to return them when the product appears. Development of this functionality takes 1–2 business days.

Data Schema

CREATE TABLE back_in_stock_requests (
    id BIGSERIAL PRIMARY KEY,
    product_id BIGINT NOT NULL REFERENCES products(id) ON DELETE CASCADE,
    variant_id BIGINT REFERENCES product_variants(id) ON DELETE CASCADE,
    user_id BIGINT REFERENCES users(id) ON DELETE SET NULL,
    email VARCHAR(255) NOT NULL,
    notified_at TIMESTAMP,
    created_at TIMESTAMP DEFAULT NOW()
);

CREATE UNIQUE INDEX idx_bis_email_product
    ON back_in_stock_requests(email, product_id, COALESCE(variant_id, 0))
    WHERE notified_at IS NULL;

Unique index prevents duplicate subscriptions from one email to one product/variant.

Subscription Form

Form is shown instead of "Add to Cart" button when stock = 0:

const BackInStockForm = ({ product, variant }: BackInStockProps) => {
  const { user } = useAuth();
  const [submitted, setSubmitted] = useState(false);
  const { register, handleSubmit, formState: { errors, isSubmitting } } = useForm({
    defaultValues: { email: user?.email ?? '' },
  });

  const onSubmit = async (data: { email: string }) => {
    await api.post('/back-in-stock', {
      product_id: product.id,
      variant_id: variant?.id ?? null,
      email: data.email,
    });
    setSubmitted(true);
  };

  if (submitted) {
    return (
      <div className="flex items-center gap-2 text-green-600 text-sm">
        <CheckIcon className="w-4 h-4" />
        <span>We'll notify you when this product is back in stock</span>
      </div>
    );
  }

  return (
    <form onSubmit={handleSubmit(onSubmit)} className="space-y-2">
      <p className="text-sm text-gray-600">Out of stock. Leave your email — we'll notify you when it arrives.</p>
      <div className="flex gap-2">
        <input
          type="email"
          placeholder="[email protected]"
          className="flex-1 border rounded px-3 py-2 text-sm"
          {...register('email', { required: true, pattern: /^[^\s@]+@[^\s@]+\.[^\s@]+$/ })}
        />
        <Button type="submit" size="sm" loading={isSubmitting}>
          Notify
        </Button>
      </div>
      {errors.email && <p className="text-red-500 text-xs">Enter a valid email</p>}
    </form>
  );
};

Subscription API Endpoint

public function subscribe(Request $request): JsonResponse
{
    $request->validate([
        'product_id' => 'required|exists:products,id',
        'variant_id' => 'nullable|exists:product_variants,id',
        'email'      => 'required|email|max:255',
    ]);

    // Check that product is indeed out of stock
    $product = Product::find($request->product_id);
    if ($product->stock > 0) {
        return response()->json(['message' => 'Product is already in stock'], 422);
    }

    BackInStockRequest::firstOrCreate([
        'product_id' => $request->product_id,
        'variant_id' => $request->variant_id,
        'email'      => strtolower($request->email),
        'notified_at' => null,
    ], [
        'user_id' => $request->user()?->id,
    ]);

    return response()->json(['message' => 'Subscription confirmed']);
}

Automatic Sending on Stock Replenishment

Trigger fires when product stock is updated. This can happen through:

  • Import from 1C/ERP
  • Manual update in admin panel
  • API from supplier
// Observer on Product or ProductVariant model
class ProductObserver
{
    public function updated(Product $product): void
    {
        if ($product->isDirty('stock') && $product->stock > 0 && $product->getOriginal('stock') === 0) {
            NotifyBackInStockSubscribers::dispatch($product)->onQueue('notifications');
        }
    }
}

Notification sending job:

class NotifyBackInStockSubscribers implements ShouldQueue
{
    public function handle(): void
    {
        $requests = BackInStockRequest::where('product_id', $this->product->id)
            ->whereNull('variant_id')
            ->whereNull('notified_at')
            ->get();

        foreach ($requests as $request) {
            Mail::to($request->email)->queue(new BackInStockNotification($this->product, $request));
            $request->update(['notified_at' => now()]);
        }
    }
}

Email Notification

Email contains:

  • Product photo and name
  • Current price (considering applicable discounts)
  • Direct link to product with UTM tag utm_source=back_in_stock
  • Warning "Limited quantity — hurry to buy"

Email is sent once when product arrives. No repeat notifications — notified_at records the sending fact.

Unsubscribe

"Unsubscribe" link in email leads to /back-in-stock/unsubscribe?token={token}. Token is HMAC signature of email + product_id:

$token = hash_hmac('sha256', "{$request->email}:{$request->product_id}", config('app.key'));

Analytics

Block metrics:

  • Number of active subscriptions by product
  • Subscriber to purchase conversion (via UTM + orders)
  • Time from subscription to product arrival
  • Percentage of subscribers who managed to buy after notification

Products with large number of subscriptions — signal to reorder from supplier.