Skip to content

Action button

Action button

Usage:

ts
import { location, ui } from '@shopware-ag/meteor-admin-sdk';

if (location.is(sw.location.MAIN_HIDDEN)) {
    ui.actionButton.add({
        action: 'your-app_customer-detail-action',
        entity: 'customer',
        view: 'detail',
        label: 'Test action',
        callback: (entity, entityIds) => {
            // TODO: do something
        },
    });
}

Parameters

NameRequiredDescription
actiontrueA unique name of your action
entitytrueThe entity this action is for possible values: product, order, category, promotion or customer
viewtrueDetermines if the action button appears on the listing or detail page, possible values: detail or list
labeltrueThe label of your action button
callbacktrueThe callback function where you receive the entity and the entityIds for further processing

Calling app actions

As an app developer you may want to receive the information of the callback function server side. The following example will render the same action button as the above example but once it gets clicked you will receive a POST request to your app server. This will only work for apps. Plugin developers need to use a api client directly in there callback..

ts
import { location, ui } from '@shopware-ag/meteor-admin-sdk';

if (location.is(sw.location.MAIN_HIDDEN)) {
    ui.actionButton.add({
        action: 'your-app_customer-detail-action',
        entity: 'customer',
        view: 'detail',
        label: 'Test action',
        callback: (entity /* "customer" */, entityIds /* ["..."] */) => {
            app.webhook.actionExecute({
                url: 'http://your-app.com/customer-detail-action',
                entityIds,
                entity,
            })
        },
    });
}

Example

Action button example