Skip to content

Commit

Permalink
use the email fields value if emails is empty
Browse files Browse the repository at this point in the history
  • Loading branch information
webzunft committed Sep 10, 2021
1 parent afa5f30 commit 0855ad0
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
7 changes: 6 additions & 1 deletion includes/class-endpoint.php
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,11 @@ private function parse_data() {
} else {
$data_string = file_get_contents( 'php://input' );
$data = json_decode( $data_string, true );

// populate the "emails" array if only "email" is given
if ( isset( $data['customer']['email'] ) && ! isset( $data['customer']['emails'] ) ) {
$data['customer']['emails'] = array( $data['customer']['email'] );
}
}

return $data;
Expand All @@ -108,7 +113,7 @@ private function parse_data() {
private function validate() {

// we need at least this
if ( ! isset( $this->data['customer']['email'] ) && ! isset( $this->data['customer']['emails'] ) ) {
if ( empty( $this->data['customer']['emails'] ) || ! is_array( $this->data['customer']['emails'] ) ) {
return false;
}

Expand Down
4 changes: 4 additions & 0 deletions readme.txt
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,10 @@ Make sure the "Secret Key" setting for your Help Scout application matches the v

== Changelog ==

= untagged =

- Improvement: check if emails field is empty and handle fallback to email field

= 2.1 =

- complete template refactoring, e.g., to show Customer, Licenses, Orders and Subscriptions separately, props @Spreeuw
Expand Down

0 comments on commit 0855ad0

Please sign in to comment.