Jump to content

Creating default object from empty value in /override/controllers/front/OrderOpcController.php on li


Recommended Posts

Today, there were errors in the log file:


PHP Warning:  Creating default object from empty value in /override/controllers/front/OrderOpcController.php on line 673


I open this file, in line 673

     * Assign template vars related to page content
     * @see FrontController::initContent()
    public function initContent()
        if (Tools::getValue('ajax') == 'true')
        $this->name_file = Tools::substr(basename(__FILE__), 0, Tools::strlen(basename(__FILE__)) - 4);
        $id_country = Tools::GetValue('id_country') ? Tools::GetValue('id_country') : Configuration::get('PS_COUNTRY_DEFAULT');
        $id_tmp_addr = $this->context->cart->id_address_delivery;
        $address_delivery = NULL;
        $country = new Country($id_country);
        if (Validate::isLoadedObject($country) && !$country->contains_states){
673 >                $address->id_state = 0;



Does anyone know how to fix the error?


Link to comment
Share on other sites

It's actually not an ERROR - it's PHP warning you that it defaulted a value that was left empty. In practice this means someone didn't select a state (empty value), so the system is initializing the value so that the database will stay in sync - it defaulted to 0.


This is already, php warnings are what they are, warnings. This warning is expected. If you truly want to 'remove' the warning add additional validation to your Frontoffice / backoffice page to block "empty" state.

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...