LLMS_Admin_Post_Table_Coupons

LLMS_Admin_Post_Table_Coupons class


Source Source

File: includes/admin/post-types/post-tables/class.llms.admin.post.table.coupons.php

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
101
class LLMS_Admin_Post_Table_Coupons {
 
    /**
     * Constructor
     *
     * @return void
     *
     * @since 3.0.0
     */
    public function __construct() {
 
        add_filter( 'manage_llms_coupon_posts_columns', array( $this, 'add_columns' ), 10, 1 );
        add_action( 'manage_llms_coupon_posts_custom_column', array( $this, 'manage_columns' ), 10, 2 );
 
    }
 
    /**
     * Add Custom Coupon Columns
     *
     * @param array $columns array of default columns
     * @return  array
     * @since  3.0.0
     */
    public function add_columns( $columns ) {
 
        $columns = array(
            'cb'     => '<input type="checkbox" />',
            'title'  => __( 'Code', 'lifterlms' ),
            'amount' => __( 'Coupon Amount', 'lifterlms' ),
            'desc'   => __( 'Description', 'lifterlms' ),
            'usage'  => __( 'Usage / Limit', 'lifterlms' ),
            'expiry' => __( 'Expiration Date', 'lifterlms' ),
        );
 
        return $columns;
    }
 
 
    /**
     * Manage content of custom coupon columns
     *
     * @param  string $column  column key/name
     * @param  int    $post_id WP Post ID of the coupon for the row
     * @return void
     */
    public function manage_columns( $column, $post_id ) {
 
        global $post;
        $c = new LLMS_Coupon( $post );
 
        switch ( $column ) {
 
            case 'amount':
                _e( 'Discount: ', 'lifterlms' );
                echo $c->get_formatted_amount();
                echo '<br>';
 
                if ( $c->has_trial_discount() ) {
                    _e( 'Trial Discount: ', 'lifterlms' );
                    echo $c->get_formatted_amount( 'trial_amount' );
                    echo '<br>';
                }
 
                break;
 
            case 'desc':
                echo $c->get( 'description' );
                break;
 
            case 'usage':
                echo $c->get_uses();
                echo ' / ';
                echo ( $c->get( 'usage_limit' ) ) ? $c->get( 'usage_limit' ) : '&infin;';
                break;
 
            case 'expiry':
                echo $c->get( 'expiration_date' ) ? $c->get_date( 'expiration_date', 'F d, Y' ) : '&ndash;';
                break;
 
        }
 
    }
 
}

Top ↑

Methods Methods


Top ↑

Changelog Changelog

Changelog
Version Description
3.0.0 Introduced.

Top ↑

User Contributed Notes User Contributed Notes

You must log in before being able to contribute a note or feedback.