Skip to main content

Overview

The storefront session facade is a provided to help keep certain resources your storefront needs set, such as channel, customer group etc.
use Lunar\Facades\StorefrontSession;

Channels

Initialise the Channel

This will set the Channel based on what’s been previously set, otherwise it will use the default.
StorefrontSession::initChannel();
This is automatically called when using the facade.

Set the Channel

$channel = new Channel([
    'name' => 'Webstore',
    'handle' => 'webstore',
]);

StorefrontSession::setChannel($channel);
StorefrontSession::setChannel('webstore');

Get the Channel

StorefrontSession::getChannel();

Customer Groups

Initialise the Customer Groups

This will set the Customer Groups based on what’s been previously set (from the session), otherwise it will use the default record.
StorefrontSession::initCustomerGroups();
This is automatically called when using the facade.

Set the Customer Groups

$customerGroup = new CustomerGroup([
    'name' => 'Retail',
    'handle' => 'retail',
]);

// Set multiple customer groups
StorefrontSession::setCustomerGroups(collect($customerGroup));

// Set a single customer group, under the hood this will just call `setCustomerGroups`.
StorefrontSession::setCustomerGroup($customerGroup);

Get the Customer Groups

StorefrontSession::getCustomerGroups();

Customer

Initialise the Customer

This will set the Customer based on what’s been previously set (from the session), otherwise it will retrieve the latest customer attached with the logged in user.
StorefrontSession::initCustomer();
This is automatically called when using the facade.

Set the Customer

$customer = /** your store logic to determine current customer */ ;

StorefrontSession::setCustomer($customer);

Get the Customer

StorefrontSession::getCustomer();

Currencies

Set the Currency

$currency = new Currency([
    'name' => 'US Dollars',
    'code' => 'USD',
    // ...
]);

StorefrontSession::setCurrency($currency);
StorefrontSession::setCurrency('USD');

Get the Currency

StorefrontSession::getCurrency();