VOOZH about

URL: https://deepwiki.com/gp247net/shop/5-customer-management

⇱ Customer Management | gp247net/shop | DeepWiki


Loading...
Menu

Customer Management

Purpose and Scope

This document provides an overview of the customer management system in GP247/Shop. It covers the customer data model, authentication mechanisms, and administrative interfaces for managing customer accounts and addresses.

For detailed information about customer authentication and frontend registration flows, see Customer Authentication. For administrative CRUD operations and address management, see Customer Administration. For information about customer-specific API endpoints, see Customer API.


Customer Data Model

The ShopCustomer model represents customer accounts in the system. It extends Laravel's Authenticatable class to support authentication and uses several traits for enhanced functionality.

Core Model Structure


Sources: src/Models/ShopCustomer.php1-195

Key Model Attributes and Methods

Attribute/MethodTypeDescription
$tablestringshop_customer
$guardedarrayEmpty (all fields mass assignable)
$hiddenarraypassword, remember_token
$appendsarrayname (computed attribute)
orders()RelationshipHasMany relationship to ShopOrder
addresses()RelationshipHasMany relationship to ShopCustomerAddress
getNameAttribute()AccessorConcatenates first_name and last_name
getAddressDefault()MethodReturns the customer's default address
isVerified()MethodChecks if email_verified_at is not null
hasVerifiedEmail()MethodReturns true if verification required but not completed
sendEmailVerify()MethodSends verification email if required

Sources: src/Models/ShopCustomer.php25-194

UUID Generation and Lifecycle Hooks

The model uses the UuidTrait to automatically generate customer IDs with the prefix "CUS":


Sources: src/Models/ShopCustomer.php71-93

Customer Creation and Updates

The model provides static methods for creating and updating customers:


Sources: src/Models/ShopCustomer.php96-142


Email Verification System

The customer model integrates with Laravel's email verification system and provides configuration-driven verification requirements.

Verification Flow


Sources: src/Models/ShopCustomer.php164-194 src/Middleware/EmailIsVerifiedMiddleware.php1-39

Email Verification Middleware

The EmailIsVerifiedMiddleware enforces email verification based on the customer_verify configuration:

Route NameBehavior
customer.verifyAllowed for unverified users
customer.verify_resendAllowed for unverified users
customer.verify_processAllowed for unverified users
customer.logoutAllowed for unverified users
All other routesBlocked if unverified, redirected to customer.verify

Sources: src/Middleware/EmailIsVerifiedMiddleware.php17-38


Configuration-Driven Field Visibility

Customer fields are highly configurable through the gp247_config_admin() function, allowing different stores to require different customer information.

Field Configuration Map


Sources: src/Views/admin/screen/customer_edit.blade.php24-332

Example Configuration Checks

The admin customer edit view uses configuration checks throughout to conditionally render fields:

Configuration KeyControlsView Lines
customer_lastnameFirst/Last name split vs single name field24-80
customer_name_kanaJapanese phonetic name fields82-119
customer_phonePhone number field121-140
customer_postcodePostal code field142-162
customer_address2Secondary address line203-221
customer_address3Tertiary address line223-241
customer_countryCountry selection dropdown244-266
customer_sexGender selection268-288
customer_birthdayDate of birth field290-310
customer_groupCustomer group number312-332

Sources: src/Views/admin/screen/customer_edit.blade.php24-332


Customer Address Management

Customers can have multiple addresses, with one designated as the default address stored in ShopCustomer.address_id.

Address Relationships


Sources: src/Models/ShopCustomer.php40-48 src/Models/ShopCustomer.php145-154

Address Operations

The admin interface provides address management functionality:

OperationRouteDescription
View addressescustomer_edit viewDisplays all addresses for a customer
Edit addressadmin_customer.update_addressUpdates an existing address
Delete addressadmin_customer.delete_addressDeletes an address (AJAX)
Default indicatorVisual badgeShows which address is the default

Sources: src/Views/admin/screen/customer_edit.blade.php399-490

Address Deletion Flow


Sources: src/Views/admin/screen/customer_edit.blade.php467-487


Password Reset and Recovery

The ShopCustomer model overrides Laravel's default password reset notification to use the GP247 email system.

Password Reset Flow


Sources: src/Models/ShopCustomer.php50-59


Social Login Integration

The ShopCustomer model uses the SocialAccountTrait to support social login providers when the LoginSocial plugin is active.

Social Login Configuration


Sources: src/Models/ShopCustomer.php16 src/Views/front/auth/login.blade.php45-51


Multi-Store Customer Isolation

Customers are isolated by store_id in multi-store environments:

FieldPurpose
store_idLinks customer to specific store/vendor
Query filteringAutomatically applied in multi-store mode
Root store accessCan view all customers across stores

For more information on multi-store architecture, see Multi-Store and Multi-Vendor Architecture.

Sources: src/Models/ShopCustomer.php25-27


Admin Dashboard Customer Display

The admin dashboard includes a component that displays recently registered customers:

Top Customer Component


The component conditionally displays the provider column only if the SocialAccount class exists, indicating the LoginSocial plugin is installed.

Sources: src/Views/admin/component/new_customer.blade.php1-53


Custom Field Integration

Customers support custom fields through the GP247 Core custom field system:

Custom Field Lifecycle


Sources: src/Models/ShopCustomer.php71-86 src/Models/ShopCustomer.php104-114 src/Models/ShopCustomer.php125-136 src/Views/admin/screen/customer_edit.blade.php368

The admin customer edit form includes a custom field rendering section at line 368 using the gp247-core::component.render_form_custom_field partial.