| @@ -136,8 +136,58 @@ | ||
| 136 | 136 | 'checked' => '1' === get_option( 'wp_subscription_auto_renewal_toggle', '1' ), |
| 137 | 137 | ], |
| 138 | 138 | ], |
| 139 | 139 | [ |
| 140 | + 'type' => 'heading', | |
| 141 | + 'group' => 'stock_management', | |
| 142 | + 'priority' => 0, | |
| 143 | + 'field_data' => [ | |
| 144 | + 'title' => __( 'Stock Management', 'subscription' ), | |
| 145 | + ], | |
| 146 | + ], | |
| 147 | + [ | |
| 148 | + 'type' => 'toggle', | |
| 149 | + 'group' => 'stock_management', | |
| 150 | + 'priority' => 1, | |
| 151 | + 'field_data' => [ | |
| 152 | + 'id' => 'wp_subscription_stock_pause', | |
| 153 | + 'title' => __( 'Pause on Low Stock', 'subscription' ), | |
| 154 | + 'label' => __( 'Pause subscriptions when the product runs low on stock', 'subscription' ), | |
| 155 | + 'description' => __( 'Active subscriptions of a product are put on hold when its stock reaches the threshold, and the customer is emailed, so no renewal is charged for something you cannot ship.', 'subscription' ), | |
| 156 | + 'value' => '1', | |
| 157 | + 'checked' => '1' === get_option( 'wp_subscription_stock_pause', '' ), | |
| 158 | + ], | |
| 159 | + ], | |
| 160 | + [ | |
| 161 | + 'type' => 'input', | |
| 162 | + 'group' => 'stock_management', | |
| 163 | + 'priority' => 2, | |
| 164 | + 'field_data' => [ | |
| 165 | + 'id' => 'wp_subscription_stock_pause_threshold', | |
| 166 | + 'title' => __( 'Stock Threshold', 'subscription' ), | |
| 167 | + 'description' => __( 'Pause when the stock quantity is at or below this number. Products that do not manage a quantity pause only when out of stock.', 'subscription' ), | |
| 168 | + 'type' => 'number', | |
| 169 | + 'value' => esc_attr( get_option( 'wp_subscription_stock_pause_threshold', 0 ) ), | |
| 170 | + 'attributes' => [ | |
| 171 | + 'min' => 0, | |
| 172 | + 'step' => 1, | |
| 173 | + ], | |
| 174 | + ], | |
| 175 | + ], | |
| 176 | + [ | |
| 177 | + 'type' => 'toggle', | |
| 178 | + 'group' => 'stock_management', | |
| 179 | + 'priority' => 3, | |
| 180 | + 'field_data' => [ | |
| 181 | + 'id' => 'wp_subscription_stock_auto_resume', | |
| 182 | + 'title' => __( 'Auto Resume', 'subscription' ), | |
| 183 | + 'label' => __( 'Resume paused subscriptions when stock recovers', 'subscription' ), | |
| 184 | + 'description' => __( 'Only subscriptions paused because of stock are resumed; ones you put on hold yourself stay on hold.', 'subscription' ), | |
| 185 | + 'value' => '1', | |
| 186 | + 'checked' => '1' === get_option( 'wp_subscription_stock_auto_resume', '1' ), | |
| 187 | + ], | |
| 188 | + ], | |
| 189 | + [ | |
| 140 | 190 | 'type' => 'select', |
| 141 | 191 | 'group' => 'role_based_settings', |
| 142 | 192 | 'priority' => 2, |
| 143 | 193 | 'field_data' => [ |
| @@ -263,8 +313,32 @@ | ||
| 263 | 313 | ); |
| 264 | 314 | register_setting( |
| 265 | 315 | 'wp_subscription_settings', |
| 266 | 316 | 'wp_subscription_stripe_auto_renew', |
| 317 | + array( | |
| 318 | + 'type' => 'string', | |
| 319 | + 'sanitize_callback' => 'sanitize_text_field', | |
| 320 | + ) | |
| 321 | + ); | |
| 322 | + register_setting( | |
| 323 | + 'wp_subscription_settings', | |
| 324 | + 'wp_subscription_stock_pause', | |
| 325 | + array( | |
| 326 | + 'type' => 'string', | |
| 327 | + 'sanitize_callback' => 'sanitize_text_field', | |
| 328 | + ) | |
| 329 | + ); | |
| 330 | + register_setting( | |
| 331 | + 'wp_subscription_settings', | |
| 332 | + 'wp_subscription_stock_pause_threshold', | |
| 333 | + array( | |
| 334 | + 'type' => 'integer', | |
| 335 | + 'sanitize_callback' => 'absint', | |
| 336 | + ) | |
| 337 | + ); | |
| 338 | + register_setting( | |
| 339 | + 'wp_subscription_settings', | |
| 340 | + 'wp_subscription_stock_auto_resume', | |
| 267 | 341 | array( |
| 268 | 342 | 'type' => 'string', |
| 269 | 343 | 'sanitize_callback' => 'sanitize_text_field', |
| 270 | 344 | ) |