• Resolved yatgirl

    (@yatgirl)


    Hi
    I have the below notice line in my php error log – it is occurring multiple times a day. I understand it be one of my code snippets that is causing this.
    I was wondering if you could possible point me in the right direction as I dont understand the 469 code in the error line.

    Are these numbers (ex 469) standard codes that I could look up somewhere or are they proprietary to the code snippets plugin ?

    ————-
    [13-May-2021 06:50:33 UTC] PHP Notice: Trying to get property of non-object in /home/xxremovedxx/public_html/wp-content/plugins/code-snippets/php/snippet-ops.php(469) : eval()’d code on line 48

Viewing 5 replies - 1 through 5 (of 5 total)
  • Plugin Author Shea Bunge

    (@bungeshea)

    Hi @yatgirl,

    The line in the snippet is line 49, not 469. You’re looking for something that contains the -> symbol.

    Thread Starter yatgirl

    (@yatgirl)

    Thanks! – thats what I needed the “->” (I didnt said it was on line 469.. – its on line 48)
    I have located the snippet – I wonder if have any thoughts on how to adjust it ? The snippet is part of a larger snippet which adds a custom Order status of ‘Processing’ for woocommerce orders.
    The offending line is on line 48 which adds color to the Order status button.

    
    01 // 1 New order status AFTER woo 2.2 IN PROGRESS be very careful IF YOU DELETE THIS SNIPPET - ANY ORDERS WITH THE IN PROGRESS STATUS WILL JUST DISAPPEAR
    02 add_action( 'init', 'register_my_new_order_statuses' );
    03 function register_my_new_order_statuses() {
    04     register_post_status( 'wc-in-progress', array(
    05         'label'                     => _x( 'In Progress', 'Order status', 'woocommerce' ),
    06         'public'                    => true,
    07         'exclude_from_search'       => false,
    08         'show_in_admin_all_list'    => true,
    09         'show_in_admin_status_list' => true,
    10         'label_count'               => _n_noop( 'In Progress <span class="count">(%s)</span>', 'In Progress<span class="count">(%s)</span>', 'woocommerce' )
    11     ) );
    12 }
    13 add_filter( 'wc_order_statuses', 'my_new_wc_order_statuses' );
    14 // Register in wc_order_statuses.
    15 function my_new_wc_order_statuses( $order_statuses ) {
    16     $order_statuses['wc-in-progress'] = _x( 'In Progress', 'Order status', 'woocommerce' );
    17     return $order_statuses;
    18 }
    19 
    20 /*
    21  * 2 CHANGE STATUSES ORDER IN DROPDOWN LIST
    22  * @param array $wc_statuses_arr Array of all order statuses on the website
    23  */
    24 function change_statuses_order( $wc_statuses_arr ){
    25  
    26 	$new_statuses_arr = array(
    27 		'wc-processing' => $wc_statuses_arr['wc-processing'], // 1
    28 		'wc-in-progress' => $wc_statuses_arr['wc-in-progress'], // 2
    29 		'wc-completed' => $wc_statuses_arr['wc-completed'], // 3
    30 		'wc-cancelled' => $wc_statuses_arr['wc-cancelled'], // 4
    31 		'wc-refunded' => $wc_statuses_arr['wc-refunded'], // 5
    32 		'wc-failed' => $wc_statuses_arr['wc-failed'], // 6
    33 		'wc-pending' => $wc_statuses_arr['wc-pending'], // 7
    34 		'wc-on-hold' => $wc_statuses_arr['wc-on-hold'] // 8
    35 	);
    36  
    37 	return $new_statuses_arr;
    38 }
    39  
    40 add_filter( 'wc_order_statuses', 'change_statuses_order' );
    41 
    42 // 3. ADD COLOR TO IN PROGRESS BUTTON
    43 add_action('admin_head', 'styling_admin_order_list' );
    44 function styling_admin_order_list() {
    45     global $pagenow, $post;
    46 
    47     if( $pagenow != 'edit.php') return; // Exit
    48     if( get_post_type($post->ID) != 'shop_order' ) return; // Exit
    49 
    50     // HERE below set your custom status
    51     $order_status = 'In Progress'; // <==== HERE
    52     ?>
    53     <style>
    54         .order-status.status-<?php echo sanitize_title( $order_status ); ?> {
    55             background: #cc0099;
    56             color: #ffffff;
    57         }
    58     </style>
    59     <?php
    60 }
    61 
    62 /** 4. ADD IN PROGRESS STATUS TO WOO SALES REPORTS **/
    63 add_filter( 'woocommerce_reports_order_statuses', 'include_custom_order_status_to_reports', 20, 1 );
    64 function include_custom_order_status_to_reports( $statuses ){
    65  // Adding the custom order status to the 3 default woocommerce order statuses
    66  return array( 'processing', 'in-progress', 'completed', 'on-hold' );
    67 }
    68 
    69 /** 5. Add In Progress to Admin Order List Bulk Edit Dropdown **/
    70 add_filter( 'bulk_actions-edit-shop_order', 'custom_dropdown_bulk_actions_shop_order', 20, 1 );
    71 function custom_dropdown_bulk_actions_shop_order( $actions ) {
    72     $actions['mark_in-progress'] = __( 'Mark In Progress', 'woocommerce' );
    73     return $actions;
    74 }
    
    Plugin Author Shea Bunge

    (@bungeshea)

    Changing that line (48) to this should do the trick:

    if ( empty( $post ) || get_post_type( $post->ID ) !== 'shop_order' ) return; // Exit

    Thread Starter yatgirl

    (@yatgirl)

    Thanks ! Worked perfectly. No error lines for 10 days. Really appreciate your time and expertise on this. Sent a small donation thru the plugin donation link as a thank you.

    Plugin Author Shea Bunge

    (@bungeshea)

    Thank you! Glad to hear that it worked

Viewing 5 replies - 1 through 5 (of 5 total)

The topic ‘php notice – help in tracking down pls’ is closed to new replies.