| @@ -17,16 +17,22 @@ | ||
| 17 | 17 | $fs = freemius( $VARS['id'] ); |
| 18 | 18 | |
| 19 | 19 | $slug = $fs->get_slug(); |
| 20 | 20 | |
| 21 | - $edit_text = fs_text_x_inline( 'Edit', 'verb', 'edit', $slug ); | |
| 22 | - $update_text = fs_text_x_inline( 'Update', 'verb', 'update', $slug ); | |
| 21 | + $payments = $fs->_fetch_payments(); | |
| 23 | 22 | |
| 24 | - $billing = $fs->_fetch_billing(); | |
| 25 | - $has_billing = ( $billing instanceof FS_Billing ); | |
| 26 | - if ( ! $has_billing ) { | |
| 27 | - $billing = new FS_Billing(); | |
| 28 | - } | |
| 23 | + $show_billing = ( is_array( $payments ) && 0 < count( $payments ) ); | |
| 24 | + | |
| 25 | + if ( $show_billing ) : | |
| 26 | + | |
| 27 | + $edit_text = fs_text_x_inline( 'Edit', 'verb', 'edit', $slug ); | |
| 28 | + $update_text = fs_text_x_inline( 'Update', 'verb', 'update', $slug ); | |
| 29 | + | |
| 30 | + $billing = $fs->_fetch_billing(); | |
| 31 | + $has_billing = ( $billing instanceof FS_Billing ); | |
| 32 | + if ( ! $has_billing ) { | |
| 33 | + $billing = new FS_Billing(); | |
| 34 | + } | |
| 29 | 35 | ?> |
| 30 | 36 | <!-- Billing --> |
| 31 | 37 | <div class="postbox"> |
| 32 | 38 | <div id="fs_billing"> |
| @@ -34,18 +40,18 @@ | ||
| 34 | 40 | <table id="fs_billing_address"<?php if ( $has_billing ) { |
| 35 | 41 | echo ' class="fs-read-mode"'; |
| 36 | 42 | } ?>> |
| 37 | 43 | <tr> |
| 38 | - <td><label><span><?php fs_esc_html_echo_inline( 'Business name', 'business-name', $slug ) ?>:</span> <input id="business_name" value="<?php echo esc_attr( $billing->business_name ) ?>" placeholder="<?php fs_esc_attr_echo_inline( 'Business name', 'business-name', $slug ) ?>"></label></td> | |
| 39 | - <td><label><span><?php fs_esc_html_echo_inline( 'Tax / VAT ID', 'tax-vat-id', $slug ) ?>:</span> <input id="tax_id" value="<?php echo esc_attr( $billing->tax_id ) ?>" placeholder="<?php fs_esc_attr_echo_inline( 'Tax / VAT ID', 'tax-vat-id', $slug ) ?>"></label></td> | |
| 44 | + <td><label><span><?php fs_esc_html_echo_inline( 'Business name', 'business-name', $slug ) ?>:</span> <input id="business_name" value="<?php echo $billing->business_name ?>" placeholder="<?php fs_esc_attr_echo_inline( 'Business name', 'business-name', $slug ) ?>"></label></td> | |
| 45 | + <td><label><span><?php fs_esc_html_echo_inline( 'Tax / VAT ID', 'tax-vat-id', $slug ) ?>:</span> <input id="tax_id" value="<?php echo $billing->tax_id ?>" placeholder="<?php fs_esc_attr_echo_inline( 'Tax / VAT ID', 'tax-vat-id', $slug ) ?>"></label></td> | |
| 40 | 46 | </tr> |
| 41 | 47 | <tr> |
| 42 | - <td><label><span><?php printf( fs_esc_html_inline( 'Address Line %d', 'address-line-n', $slug ), 1 ) ?>:</span> <input id="address_street" value="<?php echo esc_attr( $billing->address_street ) ?>" placeholder="<?php printf( fs_esc_attr_inline( 'Address Line %d', 'address-line-n', $slug ), 1 ) ?>"></label></td> | |
| 43 | - <td><label><span><?php printf( fs_esc_html_inline( 'Address Line %d', 'address-line-n', $slug ), 2 ) ?>:</span> <input id="address_apt" value="<?php echo esc_attr( $billing->address_apt ) ?>" placeholder="<?php printf( fs_esc_attr_inline( 'Address Line %d', 'address-line-n', $slug ), 2 ) ?>"></label></td> | |
| 48 | + <td><label><span><?php printf( fs_esc_html_inline( 'Address Line %d', 'address-line-n', $slug ), 1 ) ?>:</span> <input id="address_street" value="<?php echo $billing->address_street ?>" placeholder="<?php printf( fs_esc_attr_inline( 'Address Line %d', 'address-line-n', $slug ), 1 ) ?>"></label></td> | |
| 49 | + <td><label><span><?php printf( fs_esc_html_inline( 'Address Line %d', 'address-line-n', $slug ), 2 ) ?>:</span> <input id="address_apt" value="<?php echo $billing->address_apt ?>" placeholder="<?php printf( fs_esc_attr_inline( 'Address Line %d', 'address-line-n', $slug ), 2 ) ?>"></label></td> | |
| 44 | 50 | </tr> |
| 45 | 51 | <tr> |
| 46 | - <td><label><span><?php fs_esc_html_echo_inline( 'City', 'city', $slug ) ?> / <?php fs_esc_html_echo_inline( 'Town', 'town', $slug ) ?>:</span> <input id="address_city" value="<?php echo esc_attr( $billing->address_city ) ?>" placeholder="<?php fs_esc_attr_echo_inline( 'City', 'city', $slug ) ?> / <?php fs_esc_attr_echo_inline( 'Town', 'town', $slug ) ?>"></label></td> | |
| 47 | - <td><label><span><?php fs_esc_html_echo_inline( 'ZIP / Postal Code', 'zip-postal-code', $slug ) ?>:</span> <input id="address_zip" value="<?php echo esc_attr( $billing->address_zip ) ?>" placeholder="<?php fs_esc_attr_echo_inline( 'ZIP / Postal Code', 'zip-postal-code', $slug ) ?>"></label></td> | |
| 52 | + <td><label><span><?php fs_esc_html_echo_inline( 'City', 'city', $slug ) ?> / <?php fs_esc_html_echo_inline( 'Town', 'town', $slug ) ?>:</span> <input id="address_city" value="<?php echo $billing->address_city ?>" placeholder="<?php fs_esc_attr_echo_inline( 'City', 'city', $slug ) ?> / <?php fs_esc_attr_echo_inline( 'Town', 'town', $slug ) ?>"></label></td> | |
| 53 | + <td><label><span><?php fs_esc_html_echo_inline( 'ZIP / Postal Code', 'zip-postal-code', $slug ) ?>:</span> <input id="address_zip" value="<?php echo $billing->address_zip ?>" placeholder="<?php fs_esc_attr_echo_inline( 'ZIP / Postal Code', 'zip-postal-code', $slug ) ?>"></label></td> | |
| 48 | 54 | </tr> |
| 49 | 55 | <tr> |
| 50 | 56 | <?php $countries = array( |
| 51 | 57 | 'AF' => 'Afghanistan', |
| @@ -304,13 +310,13 @@ | ||
| 304 | 310 | <option value="" selected><?php fs_esc_html_echo_inline( 'Select Country', 'select-country', $slug ) ?></option> |
| 305 | 311 | <?php endif ?> |
| 306 | 312 | <?php foreach ( $countries as $code => $country ) : ?> |
| 307 | 313 | <option |
| 308 | - value="<?php echo esc_attr( $code ) ?>" <?php selected( $billing->address_country_code, $code ) ?>><?php echo esc_html( $country ) ?></option> | |
| 314 | + value="<?php echo $code ?>" <?php selected( $billing->address_country_code, $code ) ?>><?php echo $country ?></option> | |
| 309 | 315 | <?php endforeach ?> |
| 310 | 316 | </select></label></td> |
| 311 | 317 | <td><label><span><?php fs_esc_html_echo_inline( 'State', 'state', $slug ) ?> / <?php fs_esc_html_echo_inline( 'Province', 'province', $slug ) ?>:</span> |
| 312 | - <input id="address_state" value="<?php echo esc_attr( $billing->address_state ) ?>" placeholder="<?php fs_esc_html_echo_inline( 'State', 'state', $slug ) ?> / <?php fs_esc_html_echo_inline( 'Province', 'province', $slug ) ?>"></label></td> | |
| 318 | + <input id="address_state" value="<?php echo $billing->address_state ?>" placeholder="<?php fs_esc_html_echo_inline( 'State', 'state', $slug ) ?> / <?php fs_esc_html_echo_inline( 'Province', 'province', $slug ) ?>"></label></td> | |
| 313 | 319 | </tr> |
| 314 | 320 | <tr> |
| 315 | 321 | <td colspan="2"> |
| 316 | 322 | <button |
| @@ -376,14 +382,14 @@ | ||
| 376 | 382 | } |
| 377 | 383 | }); |
| 378 | 384 | |
| 379 | 385 | $.ajax({ |
| 380 | - url : <?php echo Freemius::ajax_url() ?>, | |
| 386 | + url : ajaxurl, | |
| 381 | 387 | method : 'POST', |
| 382 | 388 | data : { |
| 383 | - action : <?php echo wp_json_encode( $fs->get_ajax_action( 'update_billing' ) ) ?>, | |
| 384 | - security : <?php echo wp_json_encode( $fs->get_ajax_security( 'update_billing' ) ) ?>, | |
| 385 | - module_id: <?php echo wp_json_encode( $fs->get_id() ) ?>, | |
| 389 | + action : '<?php echo $fs->get_ajax_action( 'update_billing' ) ?>', | |
| 390 | + security : '<?php echo $fs->get_ajax_security( 'update_billing' ) ?>', | |
| 391 | + module_id: '<?php echo $fs->get_id() ?>', | |
| 386 | 392 | billing : billing |
| 387 | 393 | }, |
| 388 | 394 | success: function (resultObj) { |
| 389 | 395 | if (resultObj.success) { |
| @@ -419,5 +425,7 @@ | ||
| 419 | 425 | .toggleClass('button-primary'); |
| 420 | 426 | } |
| 421 | 427 | }); |
| 422 | 428 | })(jQuery); |
| 423 | -</script> | |
| 429 | +</script> | |
| 430 | +<?php | |
| 431 | + endif; | |