2

Does anybody know if it is possible to add a column to the orders list page?

I can choose the 'Foo' label, but when the page want to show the orders list I get the following error:

"{"error":"An exception has been thrown during the rendering of a template (\"Getting unknown property: craft\commerce\elements\Order::foo\")."}"

I use this code:

Event::on(
    Element::class,
    Element::EVENT_REGISTER_TABLE_ATTRIBUTES,
    function(RegisterElementTableAttributesEvent $e) {
        $e->tableAttributes['foo'] = [
            'label' => "Foo"
        ];
});

Event::on(
    Order::class,
    Element::EVENT_SET_TABLE_ATTRIBUTE_HTML,
    function(SetElementTableAttributeHtmlEvent $e) {
        if($e->attribute === 'foo'){
            $e->html = 'BAR';
        }
    }
);

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.