diff --git a/Plugin.php b/Plugin.php index 66d93ae..2615bf9 100644 --- a/Plugin.php +++ b/Plugin.php @@ -80,6 +80,16 @@ public function registerNavigation() ]; } + public function registerFormWidgets() + { + return [ + 'Dshoreman\Shop\FormWidgets\ItemGrid' => [ + 'label' => 'Order Item Grid', + 'alias' => 'itemgrid', + ], + ]; + } + public function registerPermissions() { return [ diff --git a/formwidgets/ItemGrid.php b/formwidgets/ItemGrid.php new file mode 100644 index 0000000..fda52c2 --- /dev/null +++ b/formwidgets/ItemGrid.php @@ -0,0 +1,28 @@ + 'Item Grid', + 'description' => 'Renders a grid of items from an order', + ]; + } + + public function render() + { + $this->prepareVars(); + + return $this->makePartial('itemgrid'); + } + + public function prepareVars() + { + $this->vars['items'] = json_decode($this->formField->value); + } + +} diff --git a/formwidgets/itemgrid/partials/_itemgrid.htm b/formwidgets/itemgrid/partials/_itemgrid.htm new file mode 100644 index 0000000..ac5faa9 --- /dev/null +++ b/formwidgets/itemgrid/partials/_itemgrid.htm @@ -0,0 +1,22 @@ + + + + + + + + + + + + + + + + + + + + + +
Item #NamePriceQuantitySubtotal
id ?>name ?>price ?>qty ?>subtotal ?>
diff --git a/models/order/fields.yaml b/models/order/fields.yaml index 9520fbe..295c40c 100644 --- a/models/order/fields.yaml +++ b/models/order/fields.yaml @@ -82,8 +82,9 @@ tabs: tab: Addresses items: - label: Order Items + label: tab: Items + type: itemgrid total: label: Order Value span: right