wc-quick-donation-functions.php 1.17 KB
Newer Older
Varun Sridharan's avatar
Varun Sridharan committed
1 2
<?php

3 4
if(! function_exists('wcqd_get_message')){
    function wcqd_get_message($id,$search_replace = array()){
Varun Sridharan's avatar
Varun Sridharan committed
5 6 7
        $message = WC_QD()->db()->get_message($id,$search_replace);
        return $message;
    }
8 9 10
} 

if(! function_exists('wcqd_project_limit')){
11
    function wcqd_project_limit($project_id = 0, $type = 'min'){
12 13 14 15 16 17
        if(empty($project_id)){return false; }
        if($type !== 'min' && $type !== 'max'){return false;}
        $function_toCal = $type.'_project';
        $limit = WC_QD()->db()->{$function_toCal}($project_id);
        return $limit;
}
Varun Sridharan's avatar
Varun Sridharan committed
18 19
}

20 21 22 23 24 25 26 27
if(! function_exists('wcqd_get_project')){
    function wcqd_get_project($order_id = ''){ 
        $is_donation = WC_QD()->db()->_is_donation($order_id);
        if($is_donation){
            $project = WC_QD()->db()->get_project_id($order_id);
            return $project;
        } 
        return false;
Varun Sridharan's avatar
Varun Sridharan committed
28 29 30
    }
}

31
if(! function_exists('wcqd_get_project_name')){
32 33
    function wcqd_get_project_name($order_id = '', $default_title = ''){  
        $project_id = wcqd_get_project($order_id); 
34
        $title = get_the_title($project_id);
35
        if(empty($title)){return $default_title;}
36
        return $title;
Varun Sridharan's avatar
Varun Sridharan committed
37 38
    }
}
39

Varun Sridharan's avatar
Varun Sridharan committed
40
   
Varun Sridharan's avatar
Varun Sridharan committed
41
?>