| @@ -301,53 +301,19 @@ | ||
| 301 | 301 | 'pro_locked' => $pro_locked, |
| 302 | 302 | ), |
| 303 | 303 | ), |
| 304 | 304 | array( |
| 305 | - 'type' => 'join', | |
| 305 | + 'type' => 'input', | |
| 306 | 306 | 'field_data' => array( |
| 307 | + 'id' => 'subscrpt_cancellation_offer_percent', | |
| 307 | 308 | 'title' => __( 'Discount', 'subscription' ), |
| 308 | - 'description' => __( 'Percentage off, or a flat amount in the store currency, applied by the generated coupon.', 'subscription' ), | |
| 309 | - 'elements' => array( | |
| 310 | - SettingsHelper::inp_element( | |
| 311 | - array( | |
| 312 | - 'id' => 'subscrpt_cancellation_offer_percent', | |
| 313 | - 'value' => self::offer_percent(), | |
| 314 | - 'type' => 'number', | |
| 315 | - 'style' => 'min-width:170px;width:170px;' . ( 'fixed' === self::offer_type() ? 'display:none;' : '' ), | |
| 316 | - 'attributes' => array( | |
| 317 | - 'min' => '1', | |
| 318 | - 'max' => '100', | |
| 319 | - 'step' => '1', | |
| 320 | - ), | |
| 321 | - ), | |
| 322 | - true | |
| 323 | - ), | |
| 324 | - SettingsHelper::inp_element( | |
| 325 | - array( | |
| 326 | - 'id' => 'subscrpt_cancellation_offer_amount', | |
| 327 | - 'value' => wc_format_decimal( self::offer_amount(), wc_get_price_decimals() ), | |
| 328 | - 'type' => 'number', | |
| 329 | - 'style' => 'min-width:170px;width:170px;' . ( 'fixed' === self::offer_type() ? '' : 'display:none;' ), | |
| 330 | - 'attributes' => array( | |
| 331 | - 'min' => '0', | |
| 332 | - 'step' => (string) ( 1 / pow( 10, wc_get_price_decimals() ) ), | |
| 333 | - ), | |
| 334 | - ), | |
| 335 | - true | |
| 336 | - ), | |
| 337 | - SettingsHelper::select_element( | |
| 338 | - array( | |
| 339 | - 'id' => 'subscrpt_cancellation_offer_type', | |
| 340 | - 'class' => 'subscrpt-offer-type', | |
| 341 | - 'options' => array( | |
| 342 | - 'percent' => __( 'Percentage (%)', 'subscription' ), | |
| 343 | - /* translators: %s: store currency symbol. */ | |
| 344 | - 'fixed' => sprintf( __( 'Flat (%s)', 'subscription' ), get_woocommerce_currency_symbol() ), | |
| 345 | - ), | |
| 346 | - 'selected' => self::offer_type(), | |
| 347 | - ), | |
| 348 | - true | |
| 349 | - ), | |
| 309 | + 'type' => 'number', | |
| 310 | + 'description' => __( 'Percentage off, applied store-wide by the generated coupon.', 'subscription' ), | |
| 311 | + 'value' => self::offer_percent(), | |
| 312 | + 'attrs' => array( | |
| 313 | + 'min' => '1', | |
| 314 | + 'max' => '100', | |
| 315 | + 'step' => '1', | |
| 350 | 316 | ), |
| 351 | 317 | 'pro_locked' => $pro_locked, |
| 352 | 318 | ), |
| 353 | 319 | ), |
| @@ -383,29 +349,9 @@ | ||
| 383 | 349 | if ( ! subscrpt_pro_activated() ) { |
| 384 | 350 | return false; |
| 385 | 351 | } |
| 386 | 352 | |
| 387 | - $value = 'fixed' === self::offer_type() ? self::offer_amount() : self::offer_percent(); | |
| 388 | - | |
| 389 | - return '1' === get_option( 'subscrpt_cancellation_offer_enabled', '' ) && $value > 0; | |
| 390 | - } | |
| 391 | - | |
| 392 | - /** | |
| 393 | - * Configured discount type: `percent` or `fixed`. | |
| 394 | - * | |
| 395 | - * @return string | |
| 396 | - */ | |
| 397 | - public static function offer_type() { | |
| 398 | - return 'fixed' === get_option( 'subscrpt_cancellation_offer_type', 'percent' ) ? 'fixed' : 'percent'; | |
| 399 | - } | |
| 400 | - | |
| 401 | - /** | |
| 402 | - * Configured flat discount amount, in the store currency. | |
| 403 | - * | |
| 404 | - * @return float | |
| 405 | - */ | |
| 406 | - public static function offer_amount() { | |
| 407 | - return max( 0, (float) get_option( 'subscrpt_cancellation_offer_amount', 0 ) ); | |
| 353 | + return '1' === get_option( 'subscrpt_cancellation_offer_enabled', '' ) && self::offer_percent() > 0; | |
| 408 | 354 | } |
| 409 | 355 | |
| 410 | 356 | /** |
| 411 | 357 | * Configured discount percentage. |