Fixes
This commit is contained in:
@@ -21,7 +21,7 @@ class Wiaas_DB_Update {
|
|||||||
'201810180345700' => 'wiaas_create_role_access_groups',
|
'201810180345700' => 'wiaas_create_role_access_groups',
|
||||||
'201810180444700' => 'wiaas_db_setup_create_customer_commercial_lead_table',
|
'201810180444700' => 'wiaas_db_setup_create_customer_commercial_lead_table',
|
||||||
'201810180544702' => 'wiaas_db_update_update_commercial_lead_capabilities',
|
'201810180544702' => 'wiaas_db_update_update_commercial_lead_capabilities',
|
||||||
'201810180644700' => 'wiaas_db_update_add_organization_info_ui_fields',
|
'201810180644703' => 'wiaas_db_update_add_organization_info_ui_fields',
|
||||||
);
|
);
|
||||||
|
|
||||||
public static function execute() {
|
public static function execute() {
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ function wiaas_db_update_add_organization_info_ui_fields() {
|
|||||||
|
|
||||||
$ui_json = json_decode( $ui_json, true );
|
$ui_json = json_decode( $ui_json, true );
|
||||||
|
|
||||||
acf_import_field_group($ui_json[0]);
|
_wiaas_import_field_group($ui_json);
|
||||||
}
|
}
|
||||||
|
|
||||||
function wiaas_db_update_add_user_organization_ui_fields() {
|
function wiaas_db_update_add_user_organization_ui_fields() {
|
||||||
@@ -15,5 +15,88 @@ function wiaas_db_update_add_user_organization_ui_fields() {
|
|||||||
|
|
||||||
$ui_json = json_decode( $ui_json, true );
|
$ui_json = json_decode( $ui_json, true );
|
||||||
|
|
||||||
acf_import_field_group($ui_json[0]);
|
_wiaas_import_field_group($ui_json);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// private helper function
|
||||||
|
|
||||||
|
function _wiaas_import_field_group($json) {
|
||||||
|
// vars
|
||||||
|
$ids = array();
|
||||||
|
$keys = array();
|
||||||
|
|
||||||
|
|
||||||
|
// populate keys
|
||||||
|
foreach( $json as $field_group ) {
|
||||||
|
|
||||||
|
// append key
|
||||||
|
$keys[] = $field_group['key'];
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// look for existing ids
|
||||||
|
foreach( $keys as $key ) {
|
||||||
|
|
||||||
|
// attempt find ID
|
||||||
|
$field_group = _acf_get_field_group_by_key( $key );
|
||||||
|
|
||||||
|
|
||||||
|
// bail early if no field group
|
||||||
|
if( !$field_group ) continue;
|
||||||
|
|
||||||
|
|
||||||
|
// append
|
||||||
|
$ids[ $key ] = $field_group['ID'];
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// enable local
|
||||||
|
acf_enable_local();
|
||||||
|
|
||||||
|
|
||||||
|
// reset local (JSON class has already included .json field groups which may conflict)
|
||||||
|
acf_reset_local();
|
||||||
|
|
||||||
|
|
||||||
|
// add local field groups
|
||||||
|
foreach( $json as $field_group ) {
|
||||||
|
|
||||||
|
// add field group
|
||||||
|
acf_add_local_field_group( $field_group );
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// loop over keys
|
||||||
|
foreach( $keys as $key ) {
|
||||||
|
|
||||||
|
// vars
|
||||||
|
$field_group = acf_get_local_field_group( $key );
|
||||||
|
|
||||||
|
|
||||||
|
// attempt get id
|
||||||
|
$id = acf_maybe_get( $ids, $key );
|
||||||
|
|
||||||
|
if( $id ) {
|
||||||
|
|
||||||
|
$field_group['ID'] = $id;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// append fields
|
||||||
|
if( acf_have_local_fields($key) ) {
|
||||||
|
|
||||||
|
$field_group['fields'] = acf_get_local_fields( $key );
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// import
|
||||||
|
acf_import_field_group( $field_group );
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -55,7 +55,6 @@ class Wiaas_Package_Pricing_Test extends Wiaas_Unit_Test_Case {
|
|||||||
$this->assertArrayHasKey('minimal_services_price', $configured_price);
|
$this->assertArrayHasKey('minimal_services_price', $configured_price);
|
||||||
|
|
||||||
$this->assertEquals($configured_price['id'], $type);
|
$this->assertEquals($configured_price['id'], $type);
|
||||||
$this->assertEquals($configured_price['commision_split'], $commision / 100);
|
|
||||||
|
|
||||||
$this->assertEquals($configured_price['minimal_fixed_price'], $pricing_rules[$type]['minimal_fixed_price']);
|
$this->assertEquals($configured_price['minimal_fixed_price'], $pricing_rules[$type]['minimal_fixed_price']);
|
||||||
$this->assertEquals($configured_price['principal_amount'], $pricing_rules[$type]['principal_amount']);
|
$this->assertEquals($configured_price['principal_amount'], $pricing_rules[$type]['principal_amount']);
|
||||||
|
|||||||
Reference in New Issue
Block a user