PluginProbe ʕ •ᴥ•ʔ
Paid Membership Plugin, Ecommerce, User Registration Form, Login Form, User Profile & Restrict Content – ProfilePress / trunk
Paid Membership Plugin, Ecommerce, User Registration Form, Login Form, User Profile & Restrict Content – ProfilePress vtrunk
4.16.18 4.16.17 4.16.16 trunk 1.0 1.0.1 1.0.2 1.1 1.1.1 1.1.2 1.1.3 1.1.4 1.1.5 1.1.5a 1.1.6 1.1.7 1.2 1.2.1 1.2.2 1.2.3 1.2.4 1.2.5 1.2.6 1.3 1.3.1 1.3.2 1.3.3 1.3.4 1.3.5 1.3.6 1.4 1.4.1 1.4.2 1.5 1.5.1 1.5.2 1.5.3 1.5.4 1.5.5 1.5.6 1.5.7 1.5.8 1.6 1.6.1 1.6.2 1.6.3 1.6.4 1.6.5 1.6.6 1.6.7 1.6.8 1.7 1.7.1 1.7.2 1.8 1.8.1 1.8.10 1.8.2 1.8.3 1.8.4 1.8.5 1.8.6 1.8.7 1.8.8 1.8.9 1.9 1.9.1 1.9.10 1.9.11 1.9.12 1.9.13 1.9.2 1.9.3 1.9.4 1.9.5 1.9.6 1.9.7 1.9.8 1.9.9 2.1.9 2.2.10 2.2.11 2.2.12 2.2.13 2.2.14 2.2.15 2.2.16 2.2.2 2.2.5 2.2.6 2.2.7 2.2.8 2.2.9 3.0 3.1 3.1.1 3.1.10 3.1.11 3.1.12 3.1.13 3.1.14 3.1.15 3.1.16 3.1.17 3.1.18 3.1.19 3.1.2 3.1.3 3.1.4 3.1.5 3.1.6 3.1.7 3.1.8 3.1.9 3.2.0 3.2.1 3.2.10 3.2.11 3.2.12 3.2.13 3.2.14 3.2.15 3.2.16 3.2.2 3.2.3 3.2.4 3.2.5 3.2.6 3.2.7 3.2.8 3.2.9 4.0.0 4.0.1 4.0.2 4.0.3 4.1.0 4.1.1 4.1.2 4.1.3 4.1.4 4.10.0 4.10.1 4.10.2 4.10.3 4.11.0 4.12.0 4.13.0 4.13.1 4.13.2 4.13.3 4.13.4 4.14.0 4.14.1 4.14.2 4.14.3 4.14.4 4.15.0 4.15.1 4.15.10 4.15.11 4.15.12 4.15.13 4.15.14 4.15.15 4.15.16 4.15.17 4.15.18 4.15.19 4.15.2 4.15.20 4.15.20.1 4.15.21 4.15.22 4.15.23 4.15.24 4.15.25 4.15.3 4.15.4 4.15.5 4.15.6 4.15.7 4.15.8 4.15.9 4.16.0 4.16.1 4.16.10 4.16.11 4.16.12 4.16.13 4.16.14 4.16.15 4.16.2 4.16.3 4.16.4 4.16.5 4.16.6 4.16.7 4.16.8 4.16.9 4.2.0 4.3.0 4.3.1 4.3.2 4.4.0 4.4.1 4.5.0 4.5.1 4.5.2 4.5.3 4.5.4 4.5.5 4.6.0 4.7.0 4.8.0 4.9.0
wp-user-avatar / src / Admin / SettingsPages / Membership / views / add-edit-coupon.php
wp-user-avatar / src / Admin / SettingsPages / Membership / views Last commit date
customers 2 months ago orders 4 months ago subscriptions 3 months ago add-edit-coupon.php 2 years ago add-edit-plan-group.php 1 year ago add-edit-plan.php 1 month ago checkout-field-item.php 3 years ago checkout-fields.php 3 years ago coupons-page-sidebar.php 3 years ago groups-page-sidebar.php 3 years ago index.php 3 years ago payment-method-list.php 3 years ago plans-page-sidebar.php 3 years ago tax-rates-setup.php 3 years ago
add-edit-coupon.php
195 lines
1 <?php
2
3 use ProfilePress\Core\Admin\SettingsPages\Membership\SettingsFieldsParser;
4 use ProfilePress\Core\Membership\Models\Coupon\CouponFactory;
5 use ProfilePress\Core\Membership\Models\Plan\PlanEntity;
6 use ProfilePress\Core\Membership\Repositories\PlanRepository;
7
8 add_action('admin_footer', function () {
9 ?>
10 <script type="text/javascript">
11 jQuery(function () {
12 jQuery('#plan_ids').select2();
13 jQuery('#start_date, #end_date').flatpickr({dateFormat: "Y-m-d", allowInput: true});
14 });
15 </script>
16 <?php
17 });
18
19 $coupon_details = [
20 [
21 'id' => 'code',
22 'type' => 'text',
23 'label' => esc_html__('Coupon Code', 'wp-user-avatar'),
24 'description' => esc_html__('Enter a unique coupon code. Leave empty to generate a code for you on form submission.', 'wp-user-avatar')
25 ],
26 [
27 'id' => 'description',
28 'type' => 'textarea',
29 'label' => esc_html__('Description', 'wp-user-avatar'),
30 'description' => esc_html__('A description of this coupon.', 'wp-user-avatar')
31 ],
32 [
33 'id' => 'discount',
34 'type' => 'discount',
35 'label' => esc_html__('Discount', 'wp-user-avatar'),
36 ],
37 [
38 'id' => 'coupon_type',
39 'type' => 'select',
40 'label' => esc_html__('Coupon Type', 'wp-user-avatar'),
41 'options' => [
42 'recurring' => esc_html__('Recurring', 'wp-user-avatar'),
43 'one_time' => esc_html__('First Payment Only', 'wp-user-avatar')
44 ],
45 'description' => esc_html__('Selecting "First Payment Only" applies the coupon discount only to the first payment while "Recurring" applies the discount to all payments.', 'wp-user-avatar')
46 ],
47 [
48 'id' => 'coupon_application',
49 'type' => 'radio',
50 'label' => esc_html__('Coupon Application', 'wp-user-avatar'),
51 'options' => [
52 'acquisition' => esc_html__('To new purchases only', 'wp-user-avatar'),
53 'retention' => esc_html__('To existing purchase (upgrades & downgrades)', 'wp-user-avatar'),
54 'any' => esc_html__('To both new and existing purchases', 'wp-user-avatar')
55 ],
56 'description' => esc_html__('Select where members can apply this coupon.', 'wp-user-avatar')
57 ],
58 [
59 'id' => 'is_onetime_use',
60 'type' => 'checkbox',
61 'label' => esc_html__('Use Once Per Customer', 'wp-user-avatar'),
62 'checkbox_label' => esc_html__('Prevent customers from using this discount more than once.', 'wp-user-avatar')
63 ]
64 ];
65
66 $redemption_settings = [
67 [
68 'id' => 'plan_ids',
69 'type' => 'select',
70 'multiple' => true,
71 'label' => esc_html__('Membership Plans', 'wp-user-avatar'),
72 'options' => array_reduce(PlanRepository::init()->retrieveAll(), function ($carry, PlanEntity $plan) {
73 $carry[$plan->get_id()] = $plan->get_name();
74
75 return $carry;
76 }, []),
77 'description' => esc_html__('Select membership plans this coupon can only be applied to. Leave blank for all plans.', 'wp-user-avatar')
78 ],
79 [
80 'id' => 'start_date',
81 'type' => 'text',
82 'placeholder' => 'yyyy-mm-dd',
83 'label' => esc_html__('Start Date', 'wp-user-avatar'),
84 'description' => sprintf(
85 esc_html__('Enter the date that this coupon will be valid from. Leave blank for no start date. (UTC %s)', 'wp-user-avatar'),
86 (new DateTime())->setTimeZone(wp_timezone())->format('P')
87 )
88 ],
89 [
90 'id' => 'end_date',
91 'type' => 'text',
92 'placeholder' => 'yyyy-mm-dd',
93 'label' => esc_html__('End Date', 'wp-user-avatar'),
94 'description' => sprintf(
95 esc_html__('Enter the date that this coupon will expire on. Leave blank for no end date. (UTC %s)', 'wp-user-avatar'),
96 (new DateTime())->setTimeZone(wp_timezone())->format('P')
97 )
98 ],
99 [
100 'id' => 'usage_limit',
101 'type' => 'text',
102 'placeholder' => esc_html__('Unlimited', 'wp-user-avatar'),
103 'label' => esc_html__('Maximum Redemptions ', 'wp-user-avatar'),
104 'description' => esc_html__('Limit the total amount of redemptions for this coupon. Leave blank for unlimited.', 'wp-user-avatar')
105 ],
106 ];
107
108 $coupon_data = CouponFactory::fromId(absint(ppressGET_var('id')));
109
110 if (ppressGET_var('ppress_coupon_action') == 'edit' && ! $coupon_data->exists()) {
111 ppress_content_http_redirect(PPRESS_MEMBERSHIP_COUPONS_SETTINGS_PAGE);
112
113 return;
114 }
115
116 add_action('add_meta_boxes', function () use ($coupon_details, $redemption_settings, $coupon_data) {
117
118 add_meta_box(
119 'ppress-membership-coupon-content',
120 esc_html__('Coupon Details', 'wp-user-avatar'),
121 function () use ($coupon_details, $coupon_data) {
122 echo '<div class="ppress-membership-coupon-details">';
123 (new SettingsFieldsParser($coupon_details, $coupon_data, 'ppress-coupon-control'))->build();
124 echo '</div>';
125 },
126 'ppmembershipcoupon'
127 );
128
129 add_meta_box(
130 'ppress-subscription-coupon-settings',
131 esc_html__('Redemption Settings', 'wp-user-avatar'),
132 function () use ($redemption_settings, $coupon_data) {
133 echo '<div class="ppress-subscription-coupon-settings">';
134 (new SettingsFieldsParser($redemption_settings, $coupon_data))->build();
135 echo '</div>';
136 },
137 'ppmembershipcoupon'
138 );
139
140 add_meta_box(
141 'submitdiv',
142 __('Publish', 'wp-user-avatar'),
143 function () {
144 require dirname(__FILE__) . '/coupons-page-sidebar.php';
145 },
146 'ppmembershipcoupon',
147 'sidebar'
148 );
149 });
150
151 do_action('add_meta_boxes', 'ppmembershipcoupon', new WP_Post(new stdClass()));
152 ?>
153 <style type="text/css">
154 .ppview .postbox .ppress-amount-type-wrapper select {
155 border-top-left-radius: 0;
156 border-bottom-left-radius: 0;
157 width: 50px !important;
158 max-width: none !important;
159 }
160
161 .ppview .postbox .ppress-amount-type-wrapper input#amount {
162 width: 300px !important;
163 border-top-right-radius: 0;
164 border-bottom-right-radius: 0;
165 margin-right: -2px;
166 padding: 0 8px;
167 max-width: 125px !important;
168 }
169
170 .ppview .postbox .ppress-amount-type-wrapper {
171 position: relative;
172 display: flex
173 }
174
175 .ppview .postbox .ppress-amount-type-wrapper input:focus {
176 z-index: 2
177 }
178
179 .ppview #field-role-coupon_application label {
180 display: block;
181 margin: 10px 0;
182 }
183 </style>
184 <div id="poststuff">
185 <div id="post-body" class="metabox-holder columns-2">
186
187 <div id="postbox-container-1" class="postbox-container">
188 <?php do_meta_boxes('ppmembershipcoupon', 'sidebar', ''); ?>
189 </div>
190 <div id="postbox-container-2" class="postbox-container">
191 <?php do_meta_boxes('ppmembershipcoupon', 'advanced', ''); ?>
192 </div>
193 </div>
194 <br class="clear">
195 </div>