Skip to main content
Price Lists · Revision #3

How do I resolve custom price lists?

How do I resolve custom price lists?

To resolve custom price lists you can create a customer group in the Admin and create price lists that are only available for customers in that group.

First, create a setting for this customer group so that you can easily access it in code:

\Aero\Common\Facades\Settings::group('acme', function (\Aero\Common\Settings\SettingGroup $group) {
    $group->eloquent('customer_group', \Aero\Account\Models\CustomerGroup::class)->dontLoadModel();
});

Then add the logic to conditionally resolve price lists from this group for a customer instead of their own:

\Aero\Common\Models\PriceList::addCustomerGroupResolver(function () {
    if (! session()->has('newsletter_subscriber')) {
        return null;
    }

    // The customer group id
    return setting('acme.customer_group');
});

Parameters

Parameter Type Description
$customer ?\Aero\Account\Models\Customer The currently authenticated customer.