Skip to content

Plugins

This article contains all actions for retrieving and managing plugins.

Get plugin by ID#

query {
  getPlugin(id: "1") {
    id
    siteid
    type
    label
    provider
    config
    position
    status
    mtime
    ctime
    editor
  }
}
Aimeos.query(`query {
  getPlugin(id: "1") {
    id
    siteid
    type
    label
    provider
    config
    position
    status
    mtime
    ctime
    editor
  }
}`).then(data => {
  console.log(data)
})
const body = JSON.stringify({'query':
`query {
  getPlugin(id: "1") {
    id
    siteid
    type
    label
    provider
    config
    position
    status
    mtime
    ctime
    editor
  }
}`});

fetch('<GraphQL URL>', {
    method: 'POST',
    credentials: 'same-origin',
    headers: { // Laravel only
        'X-CSRF-TOKEN': '<CSRF token>'
    },
    body: body
}).then(response => {
    return response.json();
}).then(data => {
    console.log(data);
});

Response:

{
  "data": {
    "getPlugin": {
      "id": "1",
      "siteid": "1.",
      "type": "catalog",
      "label": "+10% Test",
      "provider": "Percent",
      "datestart": null,
      "dateend": null,
      "config": "{\\"last-plugin\\":0,\\"percent\\":10}",
      "position": 0,
      "status": 1,
      "mtime": "2022-12-22 09:51:38",
      "ctime": "2022-06-21 13:36:28",
      "editor": "aimeos@aimeos.org"
    }
  }
}

Search plugins#

The filter parameter is explained in the filter section of the GraphQL basics article.

query {
  searchPlugins(filter: "{\\"~=\\": {\\"plugin.label\\":\\"Product\\"}}") {
    items {
      id
      siteid
      type
      label
      provider
      config
      position
      status
      mtime
      ctime
      editor
    }
    total
  }
}
Aimeos.query(`query {
  searchPlugins(filter: "{\\"~=\\": {\\"plugin.label\\":\\"Product\\"}}") {
    items {
      id
      siteid
      type
      label
      provider
      config
      position
      status
      mtime
      ctime
      editor
    }
    total
  }
}`).then(data => {
  console.log(data)
})
let filter = {
    "~=": {"plugin.label":"Product"}
};
const fstr = JSON.stringify(JSON.stringify(filter));
const body = JSON.stringify({'query':
`query {
  searchPlugins(filter: ` + fstr + `) {
    items {
      id
      siteid
      type
      label
      provider
      config
      position
      status
      mtime
      ctime
      editor
    }
    total
  }
}`});

fetch('<GraphQL URL>', {
    method: 'POST',
    credentials: 'same-origin',
    headers: { // Laravel only
        'X-CSRF-TOKEN': '<CSRF token>'
    },
    body: body
}).then(response => {
    return response.json();
}).then(data => {
    console.log(data);
});

Response:

{
  "data": {
    "searchPlugins": {
      "items" : [
        {
          "id": "1",
          "siteid": "1.",
          "type": "catalog",
          "label": "+10% Test",
          "provider": "Percent",
          "datestart": null,
          "dateend": null,
          "config": "{\\"last-plugin\\":0,\\"percent\\":10}",
          "position": 0,
          "status": 1,
          "mtime": "2022-12-22 09:51:38",
          "ctime": "2022-06-21 13:36:28",
          "editor": "aimeos@aimeos.org"
        }
      ],
      "total": 1
    }
  }
}

Fetch plugin configuration#

To retrieve the backend configuration for a plugin provider and the added decorators use:

query {
  getPluginConfig(provider: "Autofill", type: "order") {
    code
    type
    label
  }
}
Aimeos.query(`query {
  getPluginConfig(provider: "Autofill", type: "order") {
    code
    type
    label
  }
}`).then(data => {
  console.log(data)
})
const body = JSON.stringify({'query':
`query {
  getPluginConfig(provider: "Autofill", type: "order") {
    code
    type
    label
  }
}`});

fetch('<GraphQL URL>', {
    method: 'POST',
    credentials: 'same-origin',
    headers: { // Laravel only
        'X-CSRF-TOKEN': '<CSRF token>'
    },
    body: body
}).then(response => {
    return response.json();
}).then(data => {
    console.log(data);
});

Response:

{
  "data": {
    "getPluginConfig": [
      {
        "code":"address",
        "type":"boolean",
        "label":"Add customer address automatically"
      },{
        "code":"delivery",
        "type":"boolean",
        "label":"Add delivery option automatically"
      },{
        "code":"deliverycode",
        "type":"string",
        "label":"Add delivery by code"
      },{
        "code":"payment",
        "type":"boolean",
        "label":"Add payment option automatically"
      },{
        "code":"paymentcode",
        "type":"string",
        "label":"Add payment by code"
      },{
        "code":"useorder",
        "type":"boolean",
        "label":"Add from last order"
      },{
        "code":"orderaddress",
        "type":"boolean",
        "label":"Add address from last order"
      },{
        "code":"orderservice",
        "type":"boolean",
        "label":"Add delivery\/payment from last order"
      }
    ]
  }
}

Save single plugin#

mutation {
  savePlugin(input: {
    type: "order"
    label: "Test plugin"
    provider: "Shipping"
    config: "{\\"threshold\\": "50.00"}"
    status: 0
  }) {
    id
  }
}
Aimeos.query(`mutation {
  savePlugin(input: {
    type: "order"
    label: "Test plugin"
    provider: "Shipping"
    config: "{\\"threshold\\": "50.00"}"
    status: 0
  }) {
    id
  }
}`).then(data => {
  console.log(data)
})
const body = JSON.stringify({'query':
`mutation {
  savePlugin(input: {
    type: "order"
    label: "Test plugin"
    provider: "Shipping"
    config: "{\\"threshold\\": "50.00"}"
    status: 0
  }) {
    id
  }
}`});

fetch('<GraphQL URL>', {
    method: 'POST',
    credentials: 'same-origin',
    headers: { // Laravel only
        'X-CSRF-TOKEN': '<CSRF token>'
    },
    body: body
}).then(response => {
    return response.json();
}).then(data => {
    console.log(data);
});

Response:

{
  "data": {
    "savePlugin": {
      "id": "13"
    }
  }
}

Save multiple plugins#

mutation {
  savePlugins(input: [{
    type: "order"
    label: "Test plugin 2"
    provider: "Shipping"
    config: "{\\"threshold\\": "25.00"}"
    status: 0
  }
  {
    type: "order"
    label: "Test plugin 3"
    provider: "Example"
    config: "{}"
    status: 0
  }]) {
    id
  }
}
Aimeos.query(`mutation {
  savePlugins(input: [{
    type: "order"
    label: "Test plugin 2"
    provider: "Shipping"
    config: "{\\"threshold\\": "25.00"}"
    status: 0
  }
  {
    type: "order"
    label: "Test plugin 3"
    provider: "Example"
    config: "{}"
    status: 0
  }]) {
    id
  }
}`).then(data => {
  console.log(data)
})
const body = JSON.stringify({'query':
`mutation {
  savePlugins(input: [{
    type: "order"
    label: "Test plugin 2"
    provider: "Shipping"
    config: "{\\"threshold\\": "25.00"}"
    status: 0
  }
  {
    type: "order"
    label: "Test plugin 3"
    provider: "Example"
    config: "{}"
    status: 0
  }]) {
    id
  }
}`});

fetch('<GraphQL URL>', {
    method: 'POST',
    credentials: 'same-origin',
    headers: { // Laravel only
        'X-CSRF-TOKEN': '<CSRF token>'
    },
    body: body
}).then(response => {
    return response.json();
}).then(data => {
    console.log(data);
});

Response:

{
  "data": {
    "savePlugins": [
      {
        "id": "14"
      },
      {
        "id": "15"
      }
    ]
  }
}

Delete single plugin#

mutation {
  deletePlugin(id: "13")
}
Aimeos.query(`mutation {
  deletePlugin(id: "13")
}`).then(data => {
  console.log(data)
})
const body = JSON.stringify({'query':
`mutation {
  deletePlugin(id: "13")
}`});

fetch('<GraphQL URL>', {
    method: 'POST',
    credentials: 'same-origin',
    headers: { // Laravel only
        'X-CSRF-TOKEN': '<CSRF token>'
    },
    body: body
}).then(response => {
    return response.json();
}).then(data => {
    console.log(data);
});

Response:

{
  "data": {
    "deletePlugin": "13"
  }
}

Delete multiple plugins#

mutation {
  deletePlugins(id: ["14", "15"])
}
Aimeos.query(`mutation {
  deletePlugins(id: ["14", "15"])
}`).then(data => {
  console.log(data)
})
const body = JSON.stringify({'query':
`mutation {
  deletePlugins(id: ["14", "15"])
}`});

fetch('<GraphQL URL>', {
    method: 'POST',
    credentials: 'same-origin',
    headers: { // Laravel only
        'X-CSRF-TOKEN': '<CSRF token>'
    },
    body: body
}).then(response => {
    return response.json();
}).then(data => {
    console.log(data);
});

Response:

{
  "data": {
    "deletePlugins": [
      "14",
      "15"
    ]
  }
}

Comments

Become an Aimeos Partner

Aimeos partners are first-class specialists in creating or hosting your Aimeos e-commerce project. They have proven their expertise by building top level e-commerce applications using Aimeos.