/var/www/html_uk/wp-content/plugins/automatewoo/includes/Rules/Order_Coupons.php


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
<?php

namespace AutomateWoo\Rules;

defined'ABSPATH' ) || exit;

/**
 * Class Order_Coupons.
 *
 * @package AutomateWoo\Rules
 */
class Order_Coupons extends Searchable_Select_Rule_Abstract {

    
/**
     * The rule's primary data item.
     *
     * @var string
     */
    
public $data_item 'order';

    
/**
     * The CSS class to use on the search field.
     *
     * @var string
     */
    
public $class 'wc-product-search';

    
/**
     * This rule supports multiple selections.
     *
     * @var bool
     */
    
public $is_multi true;

    
/**
     * Init the rule.
     */
    
public function init() {
        
parent::init();

        
$this->title __'Order - Coupons''automatewoo' );
    }

    
/**
     * Get the ajax action to use for the AJAX search.
     *
     * @return string
     */
    
public function get_search_ajax_action() {
        return 
'aw_json_search_coupons';
    }

    
/**
     * Validate the rule for a given order.
     *
     * @param \WC_Order $order
     * @param string    $compare
     * @param array     $expected_coupons
     *
     * @return bool
     */
    
public function validate$order$compare$expected_coupons ) {
        return 
$this->validate_select_case_insensitive$order->get_coupon_codes(), $compare$expected_coupons );
    }
}