• Resolved novusstd

    (@novusstd)


    Hello,

    i have updated the plugin and now my assign function not works. This is the funtcion

    add_filter( 'site-reviews/create/review-values', function( $reviewValues ) {
        if( !empty( $reviewValues['custom']['order']) && is_numeric( $reviewValues['custom']['order'] )) {
            $post = get_post( $reviewValues['custom']['order'] );
            if( $post instanceof \WP_Post && $post->post_type != 'site-review' ) {
                global $wpdb;
                $order_id =  $wpdb->get_results(
                             "SELECT order_id
                             FROM ".$wpdb->prefix."woocommerce_order_items
                             WHERE order_item_id = ".$post->ID.""
                             );
                $order = wc_get_order($order_id[0]->order_id);
                glsr_log("SONO IN ROTOLO");
                foreach ($order->get_items() as $item_key => $item_values){
                    $product = $item_values->get_product('attributes'); // the WC_Product object
                    switch ( $product->get_attributes()['tipologia']['options'][0] ) {
                        case 'rotolo':
                            $reviewValues['assigned_to'] = '8582';
                        break;
                        case 'foglio:':
                        case 'fogli':
                            $reviewValues['assigned_to'] = '8580';
                        break;
                        case 'cartellini':
                            $reviewValues['assigned_to'] = '8578';
                        break;
                    }
                }
            }
        }
        return $reviewValues;
    });

    How can i resolve it? i have insert glsr_log($order) but the console not show the variable

Viewing 4 replies - 1 through 4 (of 4 total)
  • Thread Starter novusstd

    (@novusstd)

    I have do some debug tests, and i founds that
    this $reviewValues['custom']['order'] contains value 3134
    but when this -> $post = get_post( $reviewValues['custom']['order'] );

    into $post there is nothing

    and not enter to the if( $post instanceof \WP_Post && $post->post_type != 'site-review' ) {

    Why $post don’t have the post id?

    • This reply was modified 5 years, 2 months ago by novusstd.
    Thread Starter novusstd

    (@novusstd)

    This is the content of $reviewValues

    'assigned_to' => '',
      'author' => 'xxxxxx',
      'avatar' => 'https://secure.gravatar.com/avatar/?s=96&d=mm&r=g',
      'content' => 'ssadsad',
      'custom' =>
      array (
        'order' => '3431',
      ),
      'date' => '2019-02-11 16:35:30',
      'email' => 'info@xxxxxx',
      'ip_address' => '195.x.x.x',
      'pinned' => false,
      'rating' => 5,
      'response' => '',
      'review_id' => '7c2e91724ef0a0728074f22c017126ce',
      'review_type' => 'local',
      'title' => 'sdasd',
      'url' => '',
    )
    Plugin Author Gemini Labs

    (@geminilabs)

    1. Please confirm that 3431 is an actual post ID.
    2. Next, use glsr_log after the get_post function to debug the $post object.

    $post = get_post( $reviewValues['custom']['order'] );
    glsr_log( $post );
    Plugin Author Gemini Labs

    (@geminilabs)

    @novusstd I have not heard back from you in a week so will close this topic.

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Error assigned_to’ is closed to new replies.