Skip to content
This repository has been archived by the owner on Nov 10, 2023. It is now read-only.

Feature/add customer username #5

Merged
merged 2 commits into from
Jul 27, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 20 additions & 12 deletions includes/Customer.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ public static function collect() {
$guapi = self::get_account_info();
$mole = array( 'meta' => self::get_onboarding_info() );
$bh_cdata = array_merge( $guapi, $mole );
Transient::set( 'bh_cdata', $bh_cdata, WEEK_IN_SECONDS );
Transient::set( 'bh_cdata', $bh_cdata, WEEK_IN_SECONDS );
}

return $bh_cdata;
Expand Down Expand Up @@ -105,19 +105,27 @@ public static function get_account_info(){
}


if (
isset( $response->plan ) &&
is_object( $response->plan ) &&
if ( isset( $response->plan ) && is_object( $response->plan ) ) {

// using property_exists in case of null value
property_exists( $response->plan, 'term' ) &&
property_exists( $response->plan, 'type' ) &&
property_exists( $response->plan, 'subtype' )
) {
$info['plan_term'] = $response->plan->term;
$info['plan_type'] = $response->plan->type;
$info['plan_subtype'] = $response->plan->subtype;
if ( property_exists( $response->plan, 'term' ) {
$info['plan_term'] = $response->plan->term;
}

if ( property_exists( $response->plan, 'type' ) ) {
$info['plan_type'] = $response->plan->type;
}

if ( property_exists( $response->plan, 'subtype' ) ) {
$info['plan_subtype'] = $response->plan->subtype;
}

if ( property_exists( $response->plan, 'username' ) ) {
$info['username'] = $response->plan->username;
}

}

return $info;
}

Expand Down