Let your customers subscribe to an out of stock product with Spree Commerce

This page summarizes the projects mentioned and recommended in the original post on dev.to

InfluxDB - Power Real-Time Data Analytics at Scale
Get real-time insights from all types of time series data with InfluxDB. Ingest, query, and analyze billions of data points in real-time with unbounded cardinality.
www.influxdata.com
featured
SaaSHub - Software Alternatives and Reviews
SaaSHub helps you find the best software and product alternatives
www.saashub.com
featured
  • Spree Commerce

    A headless open source e-commerce platform for global brands

  • # see https://github.com/spree/spree/blob/master/backend/app/controllers/spree/admin/stock_items_controller.rb module Spree module Admin module StockItemsControllerDecorator def self.prepended(base) base.before_action :process_notifiees_on_stock_item, only: :update # We have not taken into account should stock_movement.save fails. # see https://github.com/spree/spree/blob/master/backend/app/controllers/spree/admin/stock_items_controller.rb#L13 base.before_action :process_notifiees_on_stock_movement, only: :create base.before_action :notify_notifiees, only: :destroy end private # We've made the executive decision by not keeping stocks. # Alert all customers that the product is available to purchase. def notify_notifiees stock_item_id = params[:id] stock_item = Spree::StockItem.find(stock_item_id) variant_id = stock_item.variant.id email_all_notifiees(variant_id) end def process_notifiees_on_stock_movement quantity = params[:stock_movement][:quantity].to_i variant_id = params[:variant_id] if quantity > 0 email_all_notifiees(variant_id) end end def email_all_notifiees(variant_id) product_id = Spree::Variant.find(variant_id).product.id notifiees = lookup_notifiees_by(product_id) send_notification_email(notifiees) # We said we'd delete their email address notifiees.destroy_all end def process_notifiees_on_stock_item stock_item_id = params[:id] stock_item = Spree::StockItem.find(stock_item_id) # Backorderable: boolean # stock_item.backorderable # Number of items in stock: integer # stock_item.count_on_hand if stock_item.count_on_hand > 0 variant_id = stock_item.variant.id email_all_notifiees(variant_id) end end def lookup_notifiees_by(product_id) ProductNotification.where(product_id: product_id) end def send_notification_email(notifiees) if notifiees.present? emails_to_send = notifiees.pluck(:email) # send the email end end end end end ::Spree::Admin::StockItemsController.prepend Spree::Admin::StockItemsControllerDecorator if ::Spree::Admin::StockItemsController.included_modules.exclude?(Spree::Admin::StockItemsControllerDecorator)

  • InfluxDB

    Power Real-Time Data Analytics at Scale. Get real-time insights from all types of time series data with InfluxDB. Ingest, query, and analyze billions of data points in real-time with unbounded cardinality.

    InfluxDB logo
NOTE: The number of mentions on this list indicates mentions on common posts plus user suggested alternatives. Hence, a higher number means a more popular project.

Suggest a related project

Related posts

  • Ask HN: Suggestions about platform to develop a customizable B2B marketplace

    1 project | news.ycombinator.com | 1 May 2023
  • What is the right approach to handle an inventory system with Items and prices that may change over time? How do you adjust Item prices without affecting a past Sale that references it?

    2 projects | /r/rails | 19 Dec 2022
  • What headless ecommerce solution free that i can use without Shopify or WP?

    1 project | /r/laravel | 7 Nov 2021
  • Spree Commerce 4.3 released!

    1 project | dev.to | 16 Sep 2021
  • Show HN: Viezly – better code review from dependency diagram

    1 project | news.ycombinator.com | 2 Jun 2021