sales_channels

Enables plugins to assign custom values to various properties of sales channels, to be displayed in the user interface.

Shop-Script

Input (passed by reference)

$params['missing_channel_ids']: List of specified sales channels not found among default channels, which is available in the case when the app requests information about a limited set of channels rather than all available ones.

$params['known_channels']: List of default sales channels; e.g.:
— 'storefront:...': a storefront with its address specified after the colon,
— 'buy_button': a “Buy button” widget.
… your plugin code …

Output

$return['id']
Sales channel ID being a value of the sales_channel parameter from the shop_order_params table.
$return['type']
Sales channel type from this list:
  • 'manager': order was added by the store staff;
  • 'storefront': order was placed by a customer in a storefront;
  • 'widget': order was placed by a customer via a widget published in a third-party website;
  • 'marketplace': order was placed via an online marketplace API;
  • 'unknown': another order source.
$return['name']
Localized sales channel name to be displayed in the user interface. If not specified then the identifier from the 'id' is used by default.
$return['icon_url']
Absolute URL of an icon image file associated with a sales channel. Maximum recommended icon dimensions are 192x192 pixels. As an example, the icon may be displayed in the order summary instead of a customer photo if no photo has been uploaded to the customer profile.
Shop-Script

Plugin code example

PHP

public function salesChannels($params)
{
    // $unrecognized_channels = $params['missing_channel_ids'];
    // $default_channels = $params['known_channels'];
    
    return [
        [
            'id' => 'marketplace:megastore',
            'name' => _wp('Mega Store'),
            'type' => 'megastore',
            'icon_url' => wa('shop')->getAppPath('plugins/myplugin/img/channels/megastore.png'),
        ],
    ];
}