Events – Upsells

Upsells are additional products (e.g., shirts, insurance, subscriptions) that can be attached to an event and offered during checkout. They enhance the attendee experience and drive incremental revenue.

🎯 Purpose

  • Attach customizable products to events
  • Offer items at checkout—before, during, or after registration
  • Manage availability, pricing, and expiration per event

📦 Data Model

Upsell (app/Models/Upsell.php)

class Upsell extends Model
{
    protected $fillable = [
        'name','amount','original_amount','description','type',
        'track_inventory','inventory','notify_at','expiration_days',
        'partner_upsell','requires_address','show_on_presale',
        'group','display_type','upsell_page','checkout_page',
        'post_checkout_page','expiration_date','disclaimer'
    ];

    // Pivot: event_upsells(order, expiration_days)
    public function events()
    {
        return $this->belongsToMany(Event::class, 'event_upsells')
                    ->withPivot('order','expiration_days');
    }

    // Sizes for variants (e.g., shirt sizes)
    public function sizes()
    {
        return $this->belongsToMany(Size::class, 'upsell_sizes')
                    ->withPivot('quantity','notified');
    }

    // Multiple images per upsell
    public function images()
    {
        return $this->hasMany(UpsellImage::class);
    }
}

Relationships illustrated:

classDiagram
    Event -->|<�> event_upsells| Upsell
    Upsell --> UpsellImage : hasMany
    Upsell --> UpsellSize  : hasMany via upsell_sizes
    Event : id, title, date…
    Upsell : id, name, amount, type, inventory…
    UpsellImage : id, url, upsell_id
    UpsellSize : id, upsell_id, size_id, quantity

🛠 Administration

Admins and Event Managers can view, add, remove, and edit upsells on an event via the dashboard.

Action Controller Method Route Name Description
List Event Upsells indexEventUpsells() event.upsells Show all upsells attached, plus available products
Add Event Upsells addEventUpsells() event.addUpsells Attach selected upsells and tickets (sync pivot)
Remove Event Upsell removeEventUpsells() event.removeupsell Detach an upsell from the event
Edit Expiration Days editEventUpsell() event.editUpsell Update pivot expiration_days

All methods live in App\Http\Controllers\EventController .

Admin Blade View

  • File: resources/views/dashboard/events/partials/upsells.blade.php
  • Renders a table of attached upsells with inline edit for expiration days and remove buttons .
  • Manages ordering via drag-and-drop list of all upsells.

🔗 API Endpoints

{
    "title": "List Event Upsells",
    "description": "Retrieve attached and available upsells for an event",
    "method": "GET",
    "baseUrl": "https://events.prephoops.com",
    "endpoint": "/events/{event_id}/upsells",
    "pathParams": [
        { "key": "event_id", "value": "Event ID", "required": true }
    ],
    "bodyType": "none",
    "responses": {
        "200": {
            "description": "View rendered HTML partial",
            "body": "<html>…upsells table…</html>"
        }
    }
}
{
    "title": "Add Event Upsells",
    "description": "Attach selected upsells to an event",
    "method": "POST",
    "baseUrl": "https://events.prephoops.com",
    "endpoint": "/events/{event_id}/add-upsell",
    "pathParams": [
        { "key": "event_id", "value": "Event ID", "required": true }
    ],
    "bodyType": "form",
    "formData": [
        { "key": "newupsells[]", "value": "Array of Product IDs", "required": false }
    ],
    "responses": {
        "200": {
            "description": "JSON redirect to upsells page",
            "body": "{ \"redirect\": \"/events/123/upsells\" }"
        }
    }
}
{
    "title": "Remove Event Upsell",
    "description": "Detach an upsell from the specified event",
    "method": "POST",
    "baseUrl": "https://events.prephoops.com",
    "endpoint": "/events/{event_id}/remove-upsell/{product_id}",
    "pathParams": [
        { "key": "event_id", "value": "Event ID", "required": true },
        { "key": "product_id", "value": "Upsell Product ID", "required": true }
    ],
    "bodyType": "none",
    "responses": {
        "200": {
            "description": "JSON redirect to upsells page",
            "body": "{ \"redirect\": \"/events/123/upsells\" }"
        }
    }
}
{
    "title": "Edit Upsell Expiration",
    "description": "Update the expiration_days for an attached upsell",
    "method": "PUT",
    "baseUrl": "https://events.prephoops.com",
    "endpoint": "/events/{event_id}/edit-upsell/{product_id}",
    "pathParams": [
        { "key": "event_id", "value": "Event ID", "required": true },
        { "key": "product_id", "value": "Upsell Product ID", "required": true }
    ],
    "bodyType": "form",
    "formData": [
        { "key": "expiration_days", "value": "Days before event", "required": true }
    ],
    "responses": {
        "200": {
            "description": "JSON redirect or success",
            "body": "{ \"redirect\": \"/events/123/upsells\" }"
        }
    }
}

🎨 Public Views

Upsell Grid (upsell-grid.blade.php)

  • Responsive grid by group and display_type
  • Iterates @include('public.events.partials.upsell-block') for each upsell

Upsell Block (upsell-block.blade.php)

  • Shows image, name, price, description
  • Embeds upsell-quantity controls (qty, sizes, questions)
@include('public.events.partials.upsell-quantity')

Quantity & Questions

  • For standard items: number input
  • For sizes: dynamic size selectors
  • For custom questions: renders form fields for required answers

🤝 Checkout Integration

  • Livewire component processes addProduct($upsellId) and checkout()
  • Cart holds upsells alongside tickets
  • On order completion, inventory and subscriptions are handled

Validation Rules

Rule Class Purpose
ProductNotExpired app/Rules/Checkout/ProductNotExpired.php Fails if sale expired for upsell
UpsellHasOrder app/Rules/Checkout/UpsellHasOrder.php Prevent upsell-only orders without ticket or prior order
ProductHasInventory app/Rules/Checkout/ProductHasInventory.php Validates stock before checkout

📦 Inventory Management

  • On order creation, Upsell::updateInventory() adjusts stock
  • For shirts, calls updateSizeQuantity() and updateItemInventory()
  • On order cancellation, restoreInventory() replenishes stock

⚙️ Design & Dependencies

  • Uses pivot table event_upsells for per-event settings
  • Leverages Products table, filtering type = 'upsell'
  • Blade components (x-block, x-table) for consistent UI
  • Alpine.js for UI interactions (drag-and-drop, inline editing)
  • Stripe-powered checkout via Checkout Livewire class

✨ Upsells empower events with flexible add-ons, seamlessly managed in the admin and beautifully rendered for attendees.