Event handling Billing module

Discuss about Group-Office development here

Moderator: Developers

Posts: 7
Joined: Mon Jan 28, 2013 12:40 pm

Event handling Billing module

Postby RobinvdA » Wed Nov 08, 2017 10:15 am

Is there a way to hook into the save event of the Order model?

I'm trying to save a value to, for example, customer_address when a new order is made, but it looks like the event doesn't fire. This is my module:

Code: Select all


namespace GO\Uniquekeygenerator;

use GO;

class UniquekeygeneratorModule extends \GO\Base\Module

    public function autoInstall()
        return true;

    public static function initListeners()
        \GO\Billing\Model\Order::model()->addListener('save', 'GO\Uniquekeygenerator\UniquekeygeneratorModule', 'save');

    public static function save(&$order)
        $attributes = $order->getAttributes();

        if (! $attributes['customer_address']) {
            $model = \GO\Billing\Model\Order::model()->findByPk($attributes['id']);
            $model->customer_address = 'THIS IS A TEST';
Thanks in advance.

Who is online

Users browsing this forum: No registered users and 2 guests