# depicter/trunk/app/src/DataSources/HandPickedProducts.php

Depicter — Popup &amp; Slider Builder, version trunk. 84 lines.

- Page: https://pluginprobe.com/plugins/depicter/trunk/code/app/src/DataSources/HandPickedProducts.php
- Raw: https://pluginprobe.com/plugins/depicter/trunk/raw/app/src/DataSources/HandPickedProducts.php
- Modified: 2025-06-01T11:07:04+00:00

Line numbers below start at 1. Link to a line or a range by appending a fragment to the
page URL, for example `https://pluginprobe.com/plugins/depicter/trunk/code/app/src/DataSources/HandPickedProducts.php#L10-L20`.

```php
<?php
namespace Depicter\DataSources;

use Averta\Core\Utility\Data;

class HandPickedProducts extends Products {

	/**
	 * DataSource name
	 *
	 * @var string
	 */
	protected string $type = 'wooHandpicks';

	/**
	 * DataSource properties
	 *
	 * @var array
	 */
	protected array $properties = [
		'type'     => 'wooHandpicks',
		'postType' => 'product'
	];

	/**
	 * Default input params for retrieving dataSource records
	 *
	 * @var array
	 */
	protected array $defaultInputParams = [
		'postType' => 'product',
		'excerptLength' => 100,
		'linkSlides' => false,
		'orderBy' => 'post__in',
		'order' => 'DESC',
		'imageSource' => 'featured',
		'includedIds' => '',
		'excludeNonThumbnail' => true,
        'inStockOnly' => true
	];

    /**
	 * Retrieves the list of records based on query params
	 *
	 * @param $args
	 *
	 * @return \WP_Query
	 */
	protected function getRecords( $args ){

		$queryArgs = [
		    'post_type'       => $args['postType'],
		    'order'           => $args['order'],
		    'orderby'         => $args['orderBy'],
		    'post__in'        => $args['includedIds'],
		    'tax_query'       => [],
			'meta_query'      => []
	    ];

		if( Data::isTrue( $args['excludeNonThumbnail'] ) ){
			$queryArgs['meta_query'][] = [
	    		'key'     => '_thumbnail_id',
                'compare' => 'EXISTS'
		    ];
		}

	    if ( !empty( $args['excerptLength'] ) ) {
	    	add_filter( 'excerpt_length', function () use ($args) {
	    		return $args['excerptLength'];
		    });
	    }

        if ( Data::isTrue( $args['inStockOnly'] ) ) {
            $queryArgs['meta_query'][] = [
                'key' => '_stock_status',
                'value' => 'instock',
                'compare' => '=',
            ];
        }

		return new \WP_Query( $queryArgs );
	}
}

```
