/var/www/html_uk/wp-content/plugins/automatewoo/includes/Cart_Query.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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
<?php
// phpcs:ignoreFile

namespace AutomateWoo;

if ( ! 
defined'ABSPATH' ) ) exit;

/**
 * @class Cart_Query
 * @since 2.0
 */
class Cart_Query extends Query_Abstract {

    
/** @var string */
    
public $table_id 'carts';

    protected 
$model 'AutomateWoo\Cart';


    
/**
     * @since 3.8
     * @param string|array $status active, abandoned
     * @param $compare bool|string - defaults to '=' or 'IN' if array
     * @return $this
     */
    
function where_status$status$compare false ) {
        return 
$this->where'status'$status$compare );
    }


    
/**
     * @since 3.8
     * @param string|DateTime $date
     * @param $compare bool|string - defaults to '=' or 'IN' if array
     * @return $this
     */
    
function where_date_created$date$compare false ) {
        return 
$this->where'created'$date$compare );
    }


    
/**
     * @since 3.8
     * @param string|DateTime $start_date
     * @param string|DateTime $end_date
     * @return $this
     */
    
function where_date_created_between$start_date$end_date ) {
        
$this->where_date_created$start_date'>' );
        return 
$this->where_date_created$end_date'<' );
    }


    
/**
     * @since 3.8
     * @param string|DateTime $date
     * @param $compare bool|string - defaults to '=' or 'IN' if array
     * @return $this
     */
    
function where_date_modified$date$compare false ) {
        return 
$this->where'last_modified'$date$compare );
    }


    
/**
     * @since 3.8
     * @param string|DateTime $start_date
     * @param string|DateTime $end_date
     * @return $this
     */
    
function where_date_modified_between$start_date$end_date ) {
        
$this->where_date_modified$start_date'>' );
        return 
$this->where_date_modified$end_date'<' );
    }


    
/**
     * Filter results by user or guest ID.
     *
     * @since 5.2.0
     * @param Customer $customer
     * @return $this
     */
    
public function where_customerCustomer $customer ) {
        if ( 
$customer->is_registered() ) {
            return 
$this->where'user_id'$customer->get_user_id() );
        }

        return 
$this->where'guest_id'$customer->get_guest_id() );
    }


    
/**
     * @return Cart[]
     */
    
function get_results() {
        return 
parent::get_results();
    }

}