<?php

add_filter('zcpri/get-product-rule-type-group-product_properties', 'zc_pri_get_product_rule_type_product_rating', 10, 2);
if (!function_exists('zc_pri_get_product_rule_type_product_rating')) {

    function zc_pri_get_product_rule_type_product_rating($list = array(), $args) {
        $list['average_rating'] = __('Product Average Rating', 'zc-woo-pricely');
        $list['rating_count'] = __('Product Rating Count', 'zc-woo-pricely');
        return $list;
    }

}


add_filter('zcpri/get-product-rule-type-fields', 'zc_pri_get_product_rule_type_product_average_rating_fields', 10, 2);

if (!function_exists('zc_pri_get_product_rule_type_product_average_rating_fields')) {

    function zc_pri_get_product_rule_type_product_average_rating_fields($fields, $args) {

        $fld = array(
            array(
                'id' => 'compare',
                'type' => 'select2',
                'default' => '>=',
                'options' => array(
                    '>=' => __('More than or equal to', 'zc-woo-pricely'),
                    '>' => __('More than', 'zc-woo-pricely'),
                    '<=' => __('Less than or equal to', 'zc-woo-pricely'),
                    '<' => __('Less than', 'zc-woo-pricely'),
                    '==' => __('Equal to', 'zc-woo-pricely'),
                    '!=' => __('Not equal to', 'zc-woo-pricely'),
                ),
                'width' => '190px',
            ),
            array(
                'id' => 'total_sold',
                'type' => 'textbox',
                'input_type' => 'number',
                'default' => '0.00',
                'placeholder' => __('0.00', 'zc-woo-pricely'),
                'width' => '173px',
                'attributes' => array(
                    'min' => '0',
                    'step' => '0.01',
                ),
            ),
        );


        $fields['average_rating'] = $fld;
        return $fields;
    }

}
