Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

PHP Fatal error: Uncaught Error: Undefined constant "monthly_orders" – in functions.php WordPress php 8 update

I am updating Php version of wordpress website to php 8.0. I am getting fatal errors of undefined variables.

PHP Fatal error: Uncaught Error: Undefined constant "monthly_orders" in /www/…./public/wp-content/themes/…../functions.php:1263

Here is the part of code.

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

function wc_new_monthly_orders_column($columns)
{
    
    $new_columns = array();
    foreach ($columns as $column_name => $column_info) {
        $new_columns[$column_name] = $column_info;
        if ('orders' === $column_name) {
        $new_columns[monthly_orders] = __('Monthly Orders', 'theme_domain');
        }
    }
return $new_columns;
}
add_filter('manage_edit-shop_subscription_columns', 'wc_new_monthly_orders_column');

I am not really sure how to fix this.

>Solution :

I think you need to use double quotes like $new_columns[monthly_orders] and if monthly_orders is a variable then use $new_columns[$monthly_orders]

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading