Skip to content

Add Promotions Feature with Push Notifications#60

Merged
roncodes merged 2 commits intodev-v0.4.8from
feature/add-promotions-push-notifications
Dec 5, 2025
Merged

Add Promotions Feature with Push Notifications#60
roncodes merged 2 commits intodev-v0.4.8from
feature/add-promotions-push-notifications

Conversation

@roncodes
Copy link
Copy Markdown
Member

This PR implements a complete Promotions feature with Push Notifications functionality for the storefront.

Overview

This feature allows store owners to send promotional push notifications to their customers through a new "Promotions" section in the storefront console.

Frontend Implementation

Routing & Navigation

  • Added new promotions route with push-notifications sub-route (set as default path /)
  • Added "Promotions" link to sidebar navigation (positioned above "Settings")
  • Route structure allows for future expansion with additional promotional features

Controllers

  • PromotionsController: Manages tab navigation for the promotions section
  • PushNotificationsController: Handles form submission logic with validation and API calls

Templates

  • promotions.hbs: Main template with TabNavigation component
  • push-notifications.hbs: Form template with:
    • Title input field
    • Body textarea
    • ModelSelectMultiple component for customer selection (queries contacts with type="customer")
    • Submit button with loading state

Features

  • Form validation for title, body, and customer selection
  • Loading states during submission
  • Success/error notifications
  • Automatic form reset after successful submission

Backend Implementation

API Endpoint

  • Added POST /storefront/int/v1/actions/send-push-notification endpoint
  • Endpoint validates inputs and sends notifications to selected customers
  • Returns sent count and total count in response

Notification Class

  • Created PromotionalPushNotification class
  • Supports both APN (Apple Push Notification) and FCM (Firebase Cloud Messaging)
  • Automatically detects available notification channels for the store
  • Includes error handling for failed notifications

Controller Method

  • Added sendPushNotification method to ActionController
  • Validates title, body, and customer selection
  • Retrieves customers and sends notifications
  • Logs errors for failed notifications while continuing with others

Translations

All translation keys added to en-us.yaml:

  • Sidebar navigation label
  • Tab titles
  • Form labels and placeholders
  • Help text
  • Validation messages
  • Success/error messages

Files Changed

  • Frontend: 12 new files (routes, controllers, templates, exports)
  • Backend: 3 modified files, 1 new notification class
  • Translations: Updated en-us.yaml

Testing Recommendations

  1. Verify navigation link appears in sidebar
  2. Test form validation (empty fields, no customers selected)
  3. Test successful notification sending with valid data
  4. Verify notifications are received on customer devices
  5. Test with stores that have/don't have notification channels configured
  6. Verify permissions work correctly

Future Enhancements

The promotions route structure is designed to accommodate additional features such as:

  • Promotional campaigns
  • Discount codes
  • Scheduled notifications
  • Customer segmentation

Frontend Changes:
- Added promotions route with push-notifications sub-route
- Created PromotionsController with tab navigation
- Created PushNotificationsController with form logic
- Added promotions template with TabNavigation component
- Added push-notifications template with form (title, body, customer selection)
- Added Promotions link to sidebar navigation (above Settings)
- Exported all routes, controllers, and templates from app directory

Backend Changes:
- Added sendPushNotification endpoint to ActionController
- Created PromotionalPushNotification notification class
- Added route for send-push-notification in routes.php
- Implemented APN and FCM push notification support

Translations:
- Added all required translation keys for promotions feature
- Added sidebar navigation label
- Added form labels, placeholders, help text, and validation messages
Frontend Changes:
- Added selectAllCustomers toggle to PushNotificationsController
- Updated template with Toggle component for select all option
- Customer selector now hidden when select all is enabled
- Updated validation to allow select all without individual selection
- Form reset now includes selectAllCustomers flag

Backend Changes:
- Added select_all parameter handling in sendPushNotification method
- Backend now queries all customers when select_all is true
- Validation updated to allow empty customer array when select_all is true

Translations:
- Added select-all-customers label
- Added select-all-customers-help-text
@roncodes roncodes changed the base branch from main to dev-v0.4.8 December 5, 2025 09:58
@roncodes roncodes merged commit aa78b16 into dev-v0.4.8 Dec 5, 2025
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant