<p>I'm trying to add custom actions to the order page. Following the documentation on hooks and Element Actions, I did this</p>

<p>In my main plugin file (OrderExporterPlugin.php)</p>

<pre><code>public function commerce_addOrderActions($source)
{
    return array(
        new OrderExporter_ExportElementAction()
    );
}
</code></pre>

<p>In the folder elementactions (OrderExporter_ExportElementAction.php)</p>

<pre><code>class OrderExporter_ExportElementAction extends BaseElementAction {

   public function getName()
   {
    return Craft::t('Export file');
   }
</code></pre>

<p>}</p>

<p>The hook is active, but sends an error with the message "Class 'Craft\OrderExporter_ExportElementAction' not found" when trying to access that class</p>

<p>My IDE recognizes the class, so I think the namespaces are fine</p>

CC BY-SA 3.0
2017-01-18T21:07:37.017Z
Have you `require`'d the `OrderExporter_ExportElementAction` at some point in the request?  It won't get autoloaded for you.
Brad Bell
CC BY-SA 3.0
2017-12-23T12:40:56.290Z
Perhaps I’m just being an idiot but I think it would be useful to note in the docs that element actions need to be explicitly required, as most other plugin classes seem to autoload.
Dom Stubbs
<plugin-development><plugin-craftcommerce>
Adding custom actions to Craft Commerce orders page
# Adding custom actions to Craft Commerce orders page

(Asked by: username_0 on 2017-01-18)

I'm trying to add custom actions to the order page. Following the documentation on hooks and Element Actions, I did this
In my main plugin file (OrderExporterPlugin.php)
public function commerce_addOrderActions($source)
{
    return array(
        new OrderExporter_ExportElementAction()
    );
}

In the folder elementactions (OrderExporter_ExportElementAction.php)
class OrderExporter_ExportElementAction extends BaseElementAction {

   public function getName()
   {
    return Craft::t('Export file');
   }

}
The hook is active, but sends an error with the message "Class 'Craft\OrderExporter_ExportElementAction' not found" when trying to access that class
My IDE recognizes the class, so I think the namespaces are fine

**Tags:** plugin-development, plugin-craftcommerce
> **Comments:**
> **username_1**: Have you `require`'d the `OrderExporter_ExportElementAction` at some point in the request?  It won't get autoloaded for you.  
> **username_2**: Perhaps I’m just being an idiot but I think it would be useful to note in the docs that element actions need to be explicitly required, as most other plugin classes seem to autoload.  

---

## 0 answers

