-
Notifications
You must be signed in to change notification settings - Fork 1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
67 changed files
with
2,446 additions
and
72 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
# 2020-08-14 - Merchant Registration | ||
|
||
## Context | ||
|
||
We have to provide a registration for merchant. | ||
The definition of a customer, which is defined as a merchant, we want to realize via customer groups. | ||
However, this is not "merchant" specific, because we do not react to "merchant customer groups" in any way in the core. In other words, we implement a customer group registration system. | ||
|
||
The process should work as follows: | ||
* The shop owner enables customer group registration for a customer group and generates an url | ||
* This url must be shared by the shop owner to customers (footer, social media, mails, etc.) | ||
* Customer registers on an individual registration page on an individual url | ||
* The customer will be created with the default customer group | ||
* The shop operator can accept / decline the "merchant" registration in the admin | ||
|
||
For this I would suggest the following: | ||
* At the customer we store another Foreign Key (desired customer group) | ||
* This is then considered in the StoreApiRoute and stored at the customer | ||
* In Administration we extend the current customer module with an accept / decline button | ||
* Upon activation, we switch the customer group of the customer and set "desired customer group" back to zero. | ||
|
||
## Decision | ||
|
||
### Headless Frontend | ||
|
||
* Headless sales channel can resolve the url to get the foreign key using the seo-url store api route | ||
* Call the customer-group-registration config endpoint with the foreign key to get the form configuration | ||
* Sends a registration to customer registration endpoint with the `requestedGroupId` | ||
|
||
## Consequences | ||
|
||
* Registration always creates customer accounts even when the request will be declined. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
45 changes: 45 additions & 0 deletions
45
...ources/app/administration/src/core/service/api/customer-group-registration.api.service.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
import ApiService from '../api.service'; | ||
|
||
/** | ||
* Gateway for the API end point "customer-group-registration" | ||
* @class | ||
* @extends ApiService | ||
*/ | ||
class CustomerGroupRegistrationApiService extends ApiService { | ||
constructor(httpClient, loginService, apiEndpoint = 'customer-group-registration') { | ||
super(httpClient, loginService, apiEndpoint); | ||
this.name = 'customerGroupRegistrationService'; | ||
} | ||
|
||
accept(customerId, additionalParams = {}, additionalHeaders = {}) { | ||
const apiRoute = `/_action/${this.getApiBasePath()}/accept/${customerId}`; | ||
|
||
return this.httpClient.post( | ||
apiRoute, | ||
{}, | ||
{ | ||
params: additionalParams, | ||
headers: this.getBasicHeaders(additionalHeaders) | ||
} | ||
).then((response) => { | ||
return ApiService.handleResponse(response); | ||
}); | ||
} | ||
|
||
decline(customerId, additionalParams = {}, additionalHeaders = {}) { | ||
const apiRoute = `/_action/${this.getApiBasePath()}/decline/${customerId}`; | ||
|
||
return this.httpClient.post( | ||
apiRoute, | ||
{}, | ||
{ | ||
params: additionalParams, | ||
headers: this.getBasicHeaders(additionalHeaders) | ||
} | ||
).then((response) => { | ||
return ApiService.handleResponse(response); | ||
}); | ||
} | ||
} | ||
|
||
export default CustomerGroupRegistrationApiService; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
71 changes: 71 additions & 0 deletions
71
...urces/app/administration/src/core/service/customer-group-registration-listener.service.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
import { next6010 } from 'src/flag/feature_next6010'; | ||
|
||
const { Application, Service } = Shopware; | ||
const { Criteria } = Shopware.Data; | ||
|
||
|
||
/** | ||
* @module core/service/customer-group-registration-listener | ||
*/ | ||
|
||
/** | ||
* | ||
* @memberOf module:core/service/customer-group-registration-listener | ||
* @method addCustomerGroupRegistrationListener | ||
* @param loginService | ||
*/ | ||
export default function addCustomerGroupRegistrationListener(loginService) { | ||
if (!next6010()) { | ||
return; | ||
} | ||
|
||
let applicationRoot = null; | ||
|
||
loginService.addOnLoginListener(checkForUpdates); | ||
|
||
async function checkForUpdates() { | ||
const customerRepository = Service('repositoryFactory').create('customer'); | ||
const criteria = new Criteria(); | ||
criteria.addAssociation('requestedGroup'); | ||
criteria.addFilter(Criteria.not('AND', [Criteria.equals('requestedGroupId', null)])); | ||
|
||
const customers = await customerRepository.search(criteria, Shopware.Context.api); | ||
|
||
customers.forEach(createNotification); | ||
} | ||
|
||
function createNotification(customer) { | ||
const notification = { | ||
title: getApplicationRootReference().$tc( | ||
'global.default.info' | ||
), | ||
message: getApplicationRootReference().$tc( | ||
'sw-customer.customerGroupRegistration.notification.message', | ||
0, | ||
{ name: `${customer.firstName} ${customer.lastName}`, groupName: customer.requestedGroup.name } | ||
), | ||
actions: [{ | ||
label: getApplicationRootReference().$tc( | ||
'sw-customer.customerGroupRegistration.notification.openCustomer', | ||
), | ||
route: { name: 'sw.customer.detail', params: { id: customer.id } } | ||
}], | ||
variant: 'info', | ||
appearance: 'notification', | ||
growl: true | ||
}; | ||
|
||
getApplicationRootReference().$store.dispatch( | ||
'notification/createNotification', | ||
notification | ||
); | ||
} | ||
|
||
function getApplicationRootReference() { | ||
if (!applicationRoot) { | ||
applicationRoot = Application.getApplicationRoot(); | ||
} | ||
|
||
return applicationRoot; | ||
} | ||
} |
26 changes: 26 additions & 0 deletions
26
src/Administration/Resources/app/administration/src/flag/feature_next6010.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
export const NEXT6010 = 'next6010'; | ||
export default { | ||
next6010, | ||
ifNext6010, | ||
ifNext6010Call, | ||
NEXT6010 | ||
}; | ||
|
||
export function next6010() { | ||
return Shopware.FeatureConfig.isActive('next6010'); | ||
} | ||
|
||
export function ifNext6010(closure) { | ||
if (next6010()) { | ||
closure(); | ||
} | ||
} | ||
|
||
export function ifNext6010Call(object, methodName) { | ||
const closure = () => { | ||
object[methodName](); | ||
}; | ||
|
||
ifNext6010(closure); | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
22 changes: 22 additions & 0 deletions
22
...app/administration/src/module/sw-customer/page/sw-customer-detail/sw-customer-detail.scss
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
.sw-customer-detail__customer-registration-alert { | ||
max-width: 800px; | ||
margin: 0 auto; | ||
|
||
.sw-alert__message { | ||
display: flex; | ||
align-items: center; | ||
} | ||
|
||
.sw-alert .sw-alert__icon { | ||
top: 50%; | ||
transform: translateY(-50%); | ||
} | ||
} | ||
|
||
.sw-customer-detail__customer-registration-alert-actions { | ||
margin-left: auto; | ||
|
||
.sw-button:not(:last-child) { | ||
margin-right: 8px; | ||
} | ||
} |
Oops, something went wrong.