Jump to content

[SOLVED] Creating a new status on module install


Recommended Posts

I adapted the code below from the Paypal module's install file, but installing my module throws this: I "Property OrderState->name is not valid". It creates the status, but with no name. Why is that?

public function install()
        if (!parent::install() || !$this->registerHook('payment') || !$this->registerHook('paymentReturn'))
            return false;

            Configuration::updateValue('CHECKOUTFI_PASSWORD', "SAIPPUAKAUPPIAS");
            Configuration::updateValue('CHECKOUTFI_MERCHANT', 375917);
            if (!Configuration::get('PS_OS_DELAYED'))
            $orderState = new OrderState();
            $orderState->name = array();

            foreach (Language::getLanguages() as $language)
                if (strtolower($language['iso_code']) == 'fi')
                    $orderState->name[$language['id_lang']] = 'Checkout.fi-maksun tila viivästetty';
                    $orderState->name[$language['id_lang']] = 'Checkout.fi payment state: delayed';

            $orderState->send_email = false;
            $orderState->color = '#DDEEFF';
            $orderState->hidden = false;
            $orderState->delivery = false;
            $orderState->logable = true;
            $orderState->invoice = false;

            if ($orderState->add())
                $source = dirname(__FILE__).'/logo.gif';
                $destination = dirname(__FILE__).'/../../img/os/'.(int)$orderState->id.'.gif';
                copy($source, $destination);
            Configuration::updateValue('PS_OS_DELAYED', (int)$orderState->id);            
            return true;
Edited by Beluga (see edit history)
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Create New...