Sunday, September 11, 2022
HomeWordPress Developmentwarnings - Try to learn property "ID" on null"

warnings – Try to learn property “ID” on null”


I used to be utilizing under code to have customized order standing with php 7.4 My host will finish php 7.4 help thus I’ve to make use of php 8.0.

I obtained “Try to learn property “ID” on null” warning for this line.

if( get_post_type($post->ID) != ‘shop_order’ ) return; // Exit

How I can repair it?

    //Packed Standing
operate register_packed_order_status() {
    register_post_status( 'wc-packed', array(
        'label'                     => 'Packed',
        'public'                    => true,
        'show_in_admin_status_list' => true,
        'show_in_admin_all_list'    => true,
        'exclude_from_search'       => false,
        'label_count'               => _n_noop( 'Packed <span class="rely">(%s)</span>', 'Packed <span class="rely">(%s)</span>' )
    ) );
}
add_action( 'init', 'register_packed_order_status' );

operate add_packed_to_order_statuses( $order_statuses ) {
    $new_order_statuses = array();
    foreach ( $order_statuses as $key => $standing ) {
        $new_order_statuses[ $key ] = $standing;
        if ( 'wc-processing' === $key ) {
            $new_order_statuses['wc-packed'] = 'Packed';
        }
    }
    return $new_order_statuses;
}
add_filter( 'wc_order_statuses', 'add_packed_to_order_statuses' );
// 3. ADD COLOR TO IN PROGRESS BUTTON
add_action('admin_head', 'styling_packed_order_list' );
operate styling_packed_order_list() {
    international $pagenow, $put up;

    if( $pagenow != 'edit.php') return; // Exit
    if( get_post_type($post->ID) != 'shop_order' ) return; // Exit

    // HERE under set your customized standing
    $order_status="packed"; // <==== HERE
    ?>
    <fashion>
        .order-status.status-<?php echo sanitize_title( $order_status ); ?> {
            background: #0D98BA;
            colour: #ffffff;
        }
    </fashion>
    <?php
}

RELATED ARTICLES

LEAVE A REPLY

Please enter your comment!
Please enter your name here

- Advertisment -
Google search engine

Most Popular

Recent Comments