Skip to content

Customization

Meloncart is designed to be fully customizable through October CMS's theming system. The commerce theme serves as a complete reference implementation that you can copy, modify, or use as inspiration for building your own storefront.

Theme Structure

A Meloncart-powered theme follows the standard October CMS theme structure with shop-specific pages and partials:

themes/your-theme/
├── assets/
│   ├── css/
│   ├── js/
│   │   └── controls/          ← Frontend JavaScript controls
│   └── images/
├── layouts/
│   ├── default.htm            ← Main site layout
│   └── account.htm            ← Account pages layout
├── pages/
│   ├── shop/
│   │   ├── index.htm          ← Shop homepage / catalog
│   │   ├── category.htm       ← Category listing
│   │   ├── product.htm        ← Product detail
│   │   ├── cart.htm            ← Shopping cart
│   │   ├── checkout.htm       ← Checkout flow
│   │   └── payment.htm        ← Payment processing
│   └── account/
│       ├── login.htm           ← Login page
│       ├── register.htm        ← Registration
│       ├── index.htm           ← Profile
│       ├── orders.htm          ← Order history
│       ├── order.htm           ← Order detail
│       ├── addresses.htm       ← Address book
│       ├── password.htm        ← Password reset
│       └── security.htm        ← Security settings
├── partials/
│   ├── shop/                   ← Shop UI partials
│   └── account/                ← Account UI partials
├── content/
└── theme.yaml

Theme Dependencies

Your theme.yaml should declare the required plugins:

yaml
name: My Store
description: 'Custom eCommerce theme.'
author: Your Name
require:
    - Meloncart.Shop
    - RainLab.User
    - RainLab.UserPlus
    - RainLab.Location
    - Responsiv.Pay
    - Responsiv.Currency

Using the Commerce Theme

The commerce theme is the recommended starting point for building a Meloncart storefront. You can use it in two ways:

Copy and modify — Duplicate the entire themes/commerce-theme/ directory as your own theme, then modify pages and partials to match your design.

Reference implementation — Build your theme from scratch, referencing the commerce theme's pages and partials to understand how components and AJAX handlers are used.

The commerce theme includes complete implementations of every Meloncart feature, including multi-step checkout, product galleries, cart management, account pages, and order history.

Overriding Partials

The commerce theme separates its UI into small, focused partials. This makes it easy to customize individual pieces without affecting the rest of the storefront.

Shop Partials

PartialPurpose
shop/product-viewFull product detail layout (variant-aware pricing and availability)
shop/product-imagesProduct image gallery (variant-specific images)
shop/product-optionsProduct option selectors with AJAX variant updates
shop/product-extrasProduct extras with pricing
shop/product-attributesProduct specifications table
shop/product-cardProduct card for grid/list views
shop/add-to-cart-controlAdd-to-cart form with variant-aware pricing
shop/bundleBundle slot container for bundle products
shop/bundle-item-productsProduct selection per bundle slot (dropdown/radio/checkbox)
shop/bundle-product-parametersBundle child product detail (image, options, extras, quantity)
shop/bundle-product-optionsOptions for a bundle child product
shop/bundle-product-extrasExtras for a bundle child product
shop/bundle-product-quantityQuantity and price for a bundle child product
shop/cart-viewFull cart page layout
shop/cart-listCart item listing (bundle grouping, variant name display)
shop/cart-summaryCart totals and checkout button
shop/mini-cartMini cart badge in navigation
shop/checkout-step-detailsCheckout contact/address step
shop/checkout-step-shippingShipping method selection
shop/checkout-step-paymentPayment method selection
shop/order-summaryOrder total breakdown (bundle grouping, variant name display)
shop/order-itemsOrder item listing (bundle grouping, variant name display)
shop/payment-formPayment gateway form
shop/shipping-estimatorCart shipping cost estimator
shop/breadcrumbCategory/product breadcrumbs
shop/category-productsCategory page product listing

Account Partials

PartialPurpose
account/login-formLogin form
account/login-recovery-formPassword recovery form
account/login-two-factor-form2FA challenge form
account/field-nameEditable name field
account/field-emailEditable email with verification
account/field-passwordEditable password field
account/field-profileCompany/phone profile fields
account/field-two-factor-auth2FA management
account/field-account-sessionsBrowser session management
account/field-account-deleteAccount deletion
account/address-listAddress book listing
account/sidebarAccount navigation sidebar

Extending Meloncart

Beyond theming, you can extend Meloncart's core functionality by building custom payment gateways, shipping providers, and discount rules. Each has a dedicated guide:

  • Payment Gateways — Build custom payment integrations by extending GatewayBase
  • Shipping Types — Build custom shipping rate providers by extending ShippingTypeBase
  • Price Rules — Build custom discount actions and conditions for the price rule engine

Mail Templates

Meloncart registers four mail templates and one shared partial. You can customize these in the backend under Settings > Mail Templates or by overriding them in your plugin.

Templates

CodeSubjectRecipientsDescription
shop:order_thankyouThank you for your order!CustomerSent when a new order is placed
shop:new_order_internalNew Order - #AdminsSent to store managers on new orders
shop:order_status_update_internalOrder Status Changed - #AdminsSent when an order changes status
shop:low_stock_internalProduct Stock Low -AdminsSent when a product reaches its low stock threshold

Shared Partial

The shop_order_content partial is used by order-related templates to render the order items table. It provides both a plain-text and HTML version of the order line items.

Template Variables

All order templates have access to these variables:

VariableTypeDescription
orderOrderThe order model with all relationships
order.idintegerOrder ID
order.ordered_atCarbonOrder date
order.totalintegerGrand total (use |currency filter)
order.itemsCollectionOrder line items
userUserThe customer (available in order_thankyou)
statusOrderStatusNew status (available in status update template)
previous_statusOrderStatusPrevious status
commentstringStatus transition comment
productProductThe product (available in low_stock_internal)

TIP

You can add custom variables to order and product notification templates using the shop.order.getNotificationVars and shop.product.getNotificationVars events.

Customizing Templates

Edit templates in the backend UI at Settings > Mail Templates, or override them programmatically:

php
public function boot()
{
    // Override the order confirmation template
    Event::listen('mailer.beforeSend', function($mailer) {
        // Custom pre-send logic
    });
}

JavaScript Controls

The commerce theme includes reusable JavaScript controls built on the oc.ControlBase framework. These controls handle interactive UI behavior on the frontend.

checkout-form

Manages the multi-step checkout form interactions. Automatically updates shipping options, payment methods, and order totals when the customer changes their address or selections.

twig
<form data-control="checkout-form" data-request="onAction">
    <!-- Checkout form fields -->
</form>

Behavior:

  • Detects changes to address fields (city, zip, state_id, country_id) and refreshes shipping options
  • Detects changes to shipping_method and refreshes payment options and order summary
  • Detects changes to payment_method and refreshes the payment form
  • Detects changes to address_book_id and loads the selected address
  • Listens for pay:fetch-invoice events from payment gateways to prepare the order

quantity-input

Provides increment/decrement buttons for quantity fields.

twig
<div data-control="quantity-input">
    <button type="button" class="button-minus">-</button>
    <input type="text" name="quantity" value="1" class="quantity-field" />
    <button type="button" class="button-plus">+</button>
</div>

Product image gallery with thumbnail navigation and lightbox support. Uses Slick carousel for the slider and PhotoSwipe for the lightbox.

twig
<div data-control="gallery-slider">
    <div class="gallery-previews">
        <!-- Full-size images -->
    </div>
    <div class="gallery-thumbs">
        <!-- Thumbnail images -->
    </div>
</div>

card-slider

Horizontal card carousel for product cards, featured items, or any card-based content. Uses Slick carousel.

Creating Custom Controls

You can create your own controls following the same pattern:

js
oc.registerControl('my-control', class extends oc.ControlBase {
    connect() {
        // Called when the control is mounted to the DOM
        this.listen('click', '.my-button', this.onButtonClick);
    }

    disconnect() {
        // Called when the control is removed from the DOM
        // Clean up event listeners and references
    }

    onButtonClick(event) {
        event.preventDefault();

        // Make an AJAX request
        oc.request(this.element, 'onMyHandler', {
            update: {
                'shop/my-partial': '#myTarget'
            }
        });
    }
});

Include custom controls on your page using the [resources] component:

ini
[resources]
js[] = "controls/my-control.js"

Checkout Customization

Multi-Step vs Single-Page

The commerce theme includes two checkout page implementations:

  • checkout.htm — Multi-step checkout with separate sections for contact details, shipping, and payment
  • checkout-single.htm — Single-page checkout with all steps visible at once

Both use the same [checkout] component and AJAX handlers. The difference is in how the page partials are arranged. You can choose either approach or design your own layout.

Custom Checkout Flow

The checkout-form JavaScript control coordinates updates between checkout steps. When a customer changes their address, the control automatically calls onAction to refresh the shipping and payment sections.

To customize the checkout flow, you can:

  1. Rearrange partials — Move sections around, combine steps, or split them differently
  2. Add custom fields — Include extra fields in the checkout form (they will be submitted with onAction)
  3. Override partial content — Replace individual step partials with your own designs
  4. Skip the control — Build your own JavaScript to manage step interactions

Payment Page

The payment page (shop/payment.htm) handles payment processing after order placement. It receives an invoice_hash parameter from the checkout and renders the payment gateway's form.

twig
url = "/shop/payment/:hash?"
==
{% set invoice = checkout.getInvoice %}
{% if invoice %}
    {{ invoice.getPaymentFormHtml|raw }}
{% endif %}