LLMS_Meta_Box_Coupon::get_fields()
This function is where extending classes can configure all the fields within the metabox.
Description Description
The function must return an array which can be consumed by the "output" function.
Return Return
(array)
Source Source
File: includes/admin/post-types/meta-boxes/class.llms.meta.box.coupon.php
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 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 | public function get_fields() { $courses = array (); $memberships = array (); if ( isset( $this ->post ) ) { $c = new LLMS_Coupon( $this ->post ); foreach ( $c ->get_array( 'coupon_courses' ) as $course_id ) { $courses [] = array ( 'key' => $course_id , 'title' => get_the_title( $course_id ) . ' (' . __( 'ID#' , 'lifterlms' ) . ' ' . $course_id . ')' , ); } foreach ( $c ->get_array( 'coupon_membership' ) as $membership_id ) { $memberships [] = array ( 'key' => $membership_id , 'title' => get_the_title( $membership_id ) . ' (' . __( 'ID#' , 'lifterlms' ) . ' ' . $membership_id . ')' , ); } } else { $c = false; } return array ( array ( 'title' => __( 'General' , 'lifterlms' ), 'fields' => array ( array ( 'allow_null' => false, 'class' => 'llms-select2' , 'data_attributes' => array ( 'minimum-results-for-search' => 5, ), 'desc' => __( 'Select a dollar or percentage discount.' , 'lifterlms' ), 'desc_class' => 'd-all' , 'id' => $this ->prefix . 'discount_type' , 'label' => __( 'Discount Type' , 'lifterlms' ), 'type' => 'select' , 'value' => array ( array ( 'key' => 'percent' , 'title' => __( 'Percentage Discount' , 'lifterlms' ), ), array ( 'key' => 'dollar' , 'title' => sprintf( __( '%s Discount' , 'lifterlms' ), get_lifterlms_currency_symbol() ), ), ), ), array ( 'type' => 'select' , 'label' => __( 'Access Plan Types' , 'lifterlms' ), 'desc' => __( 'Select which type of access plans this coupon can be used with.' , 'lifterlms' ), 'id' => $this ->prefix . 'plan_type' , 'class' => 'llms-select2' , 'value' => array ( array ( 'key' => 'any' , 'title' => __( 'Any Access Plan' , 'lifterlms' ), ), array ( 'key' => 'one-time' , 'title' => __( 'Only One-time Payment Access Plans' , 'lifterlms' ), ), array ( 'key' => 'recurring' , 'title' => sprintf( __( 'Only Recurring Access Plans' , 'lifterlms' ), get_lifterlms_currency_symbol() ), ), ), 'desc_class' => 'd-all' , 'allow_null' => false, 'data_attributes' => array ( 'minimum-results-for-search' => 5, ), ), array ( 'type' => 'number' , 'label' => __( 'Discount Amount' , 'lifterlms' ), 'desc' => sprintf( __( 'The amount to be subtracted from the "Price" of an applicable access plan. Do not include symbols such as %1$s.' , 'lifterlms' ), get_lifterlms_currency_symbol() ), 'id' => $this ->prefix . 'coupon_amount' , 'class' => 'code input-full' , 'desc_class' => 'd-all' , 'required' => true, 'step' => '0.01' , ), array ( 'type' => 'checkbox' , 'label' => __( 'Enable Trial Pricing Discount' , 'lifterlms' ), 'desc' => __( 'When checked, the coupon can apply a discount to the "Trial Price" of an access plan.' , 'lifterlms' ), 'id' => $this ->prefix . 'enable_trial_discount' , 'value' => 'yes' , 'desc_class' => 'd-3of4 t-3of4 m-1of2' , 'controls' => '#' . $this ->prefix . 'trial_amount' , ), array ( 'type' => 'number' , 'label' => __( 'Trial Discount Amount' , 'lifterlms' ), 'desc' => sprintf( __( 'The amount to be subtracted from the "Trial Price" of an applicable access plan. Do not include symbols such as %1$s.' , 'lifterlms' ), get_lifterlms_currency_symbol() ), 'id' => $this ->prefix . 'trial_amount' , 'class' => 'code input-full' , 'desc_class' => 'd-all' , 'group' => '' , 'value' => '' , 'step' => '0.01' , ), ), ), array ( 'title' => __( 'Restrictions' , 'lifterlms' ), 'fields' => array ( array ( 'type' => 'select' , 'label' => __( 'Courses' , 'lifterlms' ), 'desc' => __( 'Limit coupon to the following courses.' , 'lifterlms' ), 'id' => $this ->prefix . 'coupon_courses' , 'class' => 'input-full llms-select2-post' , 'value' => $courses , 'multi' => true, 'selected' => $c ? $c ->get_array( 'coupon_courses' ) : array (), 'data_attributes' => array ( 'post-type' => 'course' , 'post-statuses' => 'publish,draft,future' , ), ), array ( 'type' => 'select' , 'label' => __( 'Membership' , 'lifterlms' ), 'desc' => __( 'Limit coupon to the following memberships.' , 'lifterlms' ), 'id' => $this ->prefix . 'coupon_membership' , 'class' => 'input-full llms-select2-post' , 'value' => $memberships , 'multi' => true, 'selected' => $c ? $c ->get_array( 'coupon_membership' ) : array (), 'data_attributes' => array ( 'post-type' => 'llms_membership' , 'post-statuses' => 'publish,draft,future' , ), ), array ( 'type' => 'date' , 'label' => __( 'Coupon Expiration Date' , 'lifterlms' ), 'desc' => __( 'Coupon will no longer be usable after this date. Leave blank for no expiration.' , 'lifterlms' ), 'id' => $this ->prefix . 'expiration_date' , 'class' => 'llms-datepicker input-full' , 'value' => '' , 'desc_class' => 'd-all' , 'group' => '' , ), array ( 'type' => 'number' , 'label' => __( 'Usage Limit' , 'lifterlms' ), 'desc' => __( 'The amount of times this coupon can be used. Leave empty or enter 0 for unlimited uses.' , 'lifterlms' ), 'id' => $this ->prefix . 'usage_limit' , 'class' => 'code input-full' , 'desc_class' => 'd-all' , 'group' => '' , 'value' => '' , ), ), ), array ( 'title' => __( 'Description' , 'lifterlms' ), 'fields' => array ( array ( 'type' => 'textarea' , 'label' => __( 'Description' , 'lifterlms' ), 'desc' => __( 'Optional description for internal notes. This is never displayed to your students.' , 'lifterlms' ), 'id' => $this ->prefix . 'description' , 'desc_class' => 'd-all' , 'group' => '' , 'value' => '' , 'required' => false, ), ), ), ); } |
Expand full source code Collapse full source code View on GitHub
Changelog Changelog
Version | Description |
---|---|
6.9.0 | Add step definitions for discount amount and trial discount amount to allow float values to be used. |
3.37.19 | Localize strings that were missing translation functions. |
3.32.0 | Coupons can now be restricted also to a draft or scheduled Course/Membership via the <select /> data attribute 'post-statuses' (data-post-status). |
3.0.0 | Introduced. |