Forum Replies Created

Viewing 3 replies - 1 through 3 (of 3 total)
  • Thread Starter tandow

    (@tandow)

    It seems like outputting only post/product IDs is not possible since PVC expects all wp_posts table columns to be selected in the SQL query.

    Moreover, it seems like WooCommerce’s wc_get_products function can be used together with PVC’s query variables like this:

    $output = wc_get_products(
      array(
        'type'   => array('simple'),
        'status' => 'publish',
        'return' => 'objects',
    
        // Required by PVC.
        'fields'           => 'all',
        'suppress_filters' => false,
        'orderby'          => 'post_views',
        'views_query'      => array(
          'after' => '2 weeks ago'
        )
      )
    );

    Setting 'return' => 'objects' outputs an array with product objects.

    Setting 'return' => 'ids' doesn’t output IDs but an array with post objects.

    Please feel free to comment if I am doing something wrong here.

    Thread Starter tandow

    (@tandow)

    I looked through the source code of the plugin and it seems like a time period for the pvc_get_most_viewed_posts function can be specified by using the following query argument:

    'views_query' => array(
      'year'   => '',
      'month'  => '',
      'week'   => '',
      'day'    => '',
      'after'  => '', // can be string or array
      'before' => '', // can be string or array
    }

    By using after and before, it is possible to define a custom time period. The strtotime() function is applied to them when value is a string, i.e. if I want the views from the past 2 weeks:

    'views_query' => array(
      'after'  => '2 weeks ago'
    )

    See includes/class-query.php file for more details.

    Thread Starter tandow

    (@tandow)

    After going through the woocommerce code a bit (trying to understand what the notices/error.php file expects), I’ve rewritten the line above to the following:

    'outbid_message' =>  wc_get_template_html( "notices/error.php", array(
      'notices' => array(
        array(
          'notice' => __("You have been overbidded!", 'ultimate-woocommerce-auction'),
          'data'   => '',
        ),
      ),
    )),

    PHP warning message is gone now. But not sure if it really works like this. I am also not really sure what to set the data key to, hence, I set it to an empty string for now.

    I’d appreciate it, if you could verify the possible solution and then rework your code since my change in your code would get overwritten on the next update. Thank you!

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