diff --git a/includes/Vendor/Vendor.php b/includes/Vendor/Vendor.php index 6ffad23b29..1b6dfb71a7 100644 --- a/includes/Vendor/Vendor.php +++ b/includes/Vendor/Vendor.php @@ -1386,7 +1386,7 @@ public function get_meta( $key, $single = false ) { * @since 2.9.11 * * @param string $key - * @param mix $value + * @param mixed $value * * @return void */ @@ -1550,7 +1550,8 @@ public function set_store_times_close_notice( $value ) { * @since 2.9.11 */ public function apply_changes() { - $this->update_meta( 'dokan_profile_settings', array_replace_recursive( $this->shop_data, $this->changes ) ); + $this->shop_data = array_replace_recursive( $this->shop_data, $this->changes ); + $this->update_meta( 'dokan_profile_settings', $this->shop_data ); $this->update_meta_data(); $this->changes = []; diff --git a/tests/Vendor/UserToVendorTest.php b/tests/Vendor/UserToVendorTest.php new file mode 100644 index 0000000000..b2ffcaee07 --- /dev/null +++ b/tests/Vendor/UserToVendorTest.php @@ -0,0 +1,41 @@ +factory()->user->create_and_get(); + + $data = [ + 'shopurl' => '', + 'fname' => 'John', + 'lname' => 'Doe', + 'shopname' => 'My Shop', + 'phone' => '+00000000000000', + 'address' => 'My Address', + ]; + + add_action( 'dokan_new_seller_created', function ( $user_id, $vendor_info ) use ( $data ) { + $this->assertEquals( $data['shopname'], $vendor_info['store_name'] ); + $this->assertEquals( $data['phone'], $vendor_info['phone'] ); + }, 10, 2); + + dokan_user_update_to_seller( $user, $data ); + + $vendor = new Vendor( $user->ID ); + $shop_info = $vendor->get_shop_info(); + $this->assertEquals( $data['shopname'], $shop_info['store_name'] ); + $this->assertEquals( $data['phone'], $shop_info['phone'] ); + + $this->assertTrue( !!did_action( 'dokan_new_seller_created' ) ); + } +} +