Fluent Commerce Logo
Docs
Sign In

Enable Retailer Context Switcher functionality

How-to Guide

Author:

Fluent Commerce

Changed on:

30 Oct 2023

Key Points

  • Retailer context switcher allows you to switch the retailer without having to log off and back in with the specific credentials. This is feasible as long as the user permissions are configured accordingly. 
  • The context switcher requires a few manifest modifications, which are detailed in the article below. 

Steps

Step-by-step guide

Step arrow right iconStep1

Extend the fc.mystique.manifest.oms manifest with the context section:

Initial Manifest

Result

No alt providedNo alt provided
1{
2    "manifestVersion": "2.0",
3    "name": "Oms module",
4    "title": "Fluent Order Management",
5    "homePath": "orders",
6    "orchestrationAlias": "adminconsole",
7    "context": {
8        "level": "retailer",
9        "switcher": true
10    },
11    "plugins": [
12        {
13            "type": "url",
14            "src": "/_plugins/oms"
15        }
16    ]
17}

Language: json

Name: Code Example

Description:

[Warning: empty required content area]

Step arrow right iconStep2

Update the 

`fc.mystique.manifest.oms.fragment.dashboard`
 manifest fragment

2.1. Extend the query with the following variable type: 

`$retailerId: [Int!]`
 and add the following argument to the 
`orders`
 and 
`returnOrders`
 entities: 
`retailerId: $retailerId`
.

2.2. Extend the query 

`variables`
 with the following variable: 
`"retailerId": "{{activeRetailer.id}}"`

Initial Manifest

Result

No alt providedNo alt provided
1{ 
2    "type": "page",
3    "path": "dashboard",
4    "component": "fc.page",
5    "data": {
6        "query": "query ($TodayStart: DateTime!, $YesterdayStart: DateTime!, $WorkWeekStart: DateTime!, $WeekStart: DateTime!, $MonthStart: DateTime!, $orders_first:Int, $retailerId: [Int!]) { ordersToday: orders(createdOn: {from: $TodayStart},first:$orders_first, retailerId: $retailerId) { edges { node { id } } } ordersYesterday: orders(createdOn: {from: $YesterdayStart, to: $TodayStart}, first:$orders_first, retailerId: $retailerId) { edges { node { id } } } ordersWeek: orders(createdOn: {from: $WorkWeekStart}, first: $orders_first, retailerId: $retailerId) { edges { node { id } } } ordersMonth: orders(createdOn: {from: $MonthStart}, first:$orders_first, retailerId: $retailerId) { edges { node { id } } } escalations: fulfilments(status: \"ESCALATED\", createdOn: {from: $MonthStart}, first:$orders_first) { edges { node { id } } } returns : returnOrders(createdOn: {from: $MonthStart}, first:$orders_first, retailerId: $retailerId) { edges { node { id } } } cancelled: orders(status: \"CANCELLED\", updatedOn: {from: $MonthStart}, first:$orders_first, retailerId: $retailerId) { edges { node { id } } } awaitingAction: orders(status: \"PICK_PACK\", updatedOn: {to: $WeekStart}, first:$orders_first, retailerId: $retailerId) { edges { node { id } } } }", 
7        "variables": {
8            "TodayStart": "{{dateStringFormatter (dateAdd hours=-24) 'YYYY-MM-DD[T]HH:mm:ss.SSS' true}}", 
9            "YesterdayStart": "{{dateStringFormatter (dateAdd hours=-48) 'YYYY-MM-DD[T]HH:mm:ss.SSS' true}}", 
10            "WorkWeekStart": "{{dateStringFormatter (dateAdd day=-5) 'YYYY-MM-DD[T]HH:mm:ss.SSS' true}}", 
11            "WeekStart": "{{dateStringFormatter (dateAdd day=-7) 'YYYY-MM-DD[T]HH:mm:ss.SSS' true}}", 
12            "MonthStart": "{{dateStringFormatter (dateAdd day=-30) 'YYYY-MM-DD[T]HH:mm:ss.SSS' true}}", 
13            "orders_first": 50, 
14            "retailerId": "{{activeRetailer.id}}" 
15            }
16        }
17}

Language: json

Name: Code Example

Description:

[Warning: empty required content area]

Step arrow right iconStep3

Update 

`fc.mystique.manifest.oms.fragment.ordermanagement`
 and/or 
`fc.mystique.manifest.oms.fragment.ordermanagement.mixedbasket`
 manifest fragments

3.1. Extend the Orders page query with the following variable type: 

`$retailerId: [Int!]`
 and add the following argument to the 
`orders`
 entity: 
`retailerId: $retailerId`
.

3.2. Extend the query 

`variables`
 with the following variable: 
`"retailerId": "{{activeRetailer.id}}"`

Initial Manifest

Result

No alt providedNo alt provided
1{
2    "type": "page",
3    "path": "orders",
4    "component": "fc.page",
5    "data": {
6        "query": "query($orders_first: Int, $retailerId: [Int!]) { orders(first: $orders_first, retailerId: $retailerId) { edges{ node {  id ref retailer{id tradingName}  type status retailer{id} workflowRef workflowVersion totalPrice totalTaxPrice items { edges { node { currency }}} createdOn customer{id firstName lastName }} } } }",
7        "variables": {
8            "orders_first": 100,
9            "retailerId": "{{activeRetailer.id}}"
10        }
11    }
12}

Language: json

Name: Code Example

Description:

[Warning: empty required content area]

3.3. Extend the Returns page query with the following variable type: 

`$retailerId: [Int!]`
 and add the following argument to the returnOrders entity: 
`retailerId: $retailerId`
.

3.4. Extend the query 

`variables`
 with the following variable: 
`"retailerId": "{{activeRetailer.id}}"`

Initial Manifest

Result

No alt providedNo alt provided
1{
2    "type": "page",
3    "path": "returns",
4    "component": "fc.page",
5    "data": {
6        "query": "query($returnOrders_first: Int, $retailerId: [Int!]) { returnOrders(first: $returnOrders_first, retailerId: $retailerId) { edges{ node{ id retailer{id} ref order{ref} type status createdOn returnAuthorisationKey returnAuthorisationKeyExpiry workflowRef lodgedLocation{ref}destinationLocation{ref} } } } }",
7        "variables": {
8            "returnOrders_first": 100,
9            "retailerId": "{{activeRetailer.id}}"
10        }
11    }
12}

Language: json

Name: Code Example

Description:

[Warning: empty required content area]
Fluent Commerce

Fluent Commerce

Copyright © 2024 Fluent Retail Pty Ltd (trading as Fluent Commerce). All rights reserved. No materials on this docs.fluentcommerce.com site may be used in any way and/or for any purpose without prior written authorisation from Fluent Commerce. Current customers and partners shall use these materials strictly in accordance with the terms and conditions of their written agreements with Fluent Commerce or its affiliates.

Fluent Logo