diff --git a/plugins/woocommerce/changelog/43096-fix-16504-vendor-notes-deletion b/plugins/woocommerce/changelog/43096-fix-16504-vendor-notes-deletion new file mode 100644 index 000000000000..bad5503ee37d --- /dev/null +++ b/plugins/woocommerce/changelog/43096-fix-16504-vendor-notes-deletion @@ -0,0 +1,4 @@ +Significance: minor +Type: dev + +Fix `is_read` value in Admin notes. \ No newline at end of file diff --git a/plugins/woocommerce/src/Admin/Notes/DataStore.php b/plugins/woocommerce/src/Admin/Notes/DataStore.php index 1e7f735123dd..470cb3f30d3e 100644 --- a/plugins/woocommerce/src/Admin/Notes/DataStore.php +++ b/plugins/woocommerce/src/Admin/Notes/DataStore.php @@ -37,6 +37,7 @@ public function create( &$note ) { 'layout' => $note->get_layout(), 'image' => $note->get_image(), 'is_deleted' => (int) $note->get_is_deleted(), + 'is_read' => (int) $note->get_is_read(), ); $note_to_be_inserted['content_data'] = wp_json_encode( $note->get_content_data() ); @@ -109,7 +110,7 @@ public function read( &$note ) { $note->set_source( $note_row->source ); $note->set_date_created( $note_row->date_created ); $note->set_date_reminder( $note_row->date_reminder ); - $note->set_is_snoozable( $note_row->is_snoozable ); + $note->set_is_snoozable( (bool) $note_row->is_snoozable ); $note->set_is_deleted( (bool) $note_row->is_deleted ); isset( $note_row->is_read ) && $note->set_is_read( (bool) $note_row->is_read ); $note->set_layout( $note_row->layout ); @@ -162,11 +163,11 @@ public function update( &$note ) { 'source' => $note->get_source(), 'date_created' => $date_created_to_db, 'date_reminder' => $date_reminder_to_db, - 'is_snoozable' => $note->get_is_snoozable(), + 'is_snoozable' => (int) $note->get_is_snoozable(), 'layout' => $note->get_layout(), 'image' => $note->get_image(), - 'is_deleted' => $note->get_is_deleted(), - 'is_read' => $note->get_is_read(), + 'is_deleted' => (int) $note->get_is_deleted(), + 'is_read' => (int) $note->get_is_read(), ), array( 'note_id' => $note->get_id() ) ); diff --git a/plugins/woocommerce/src/Admin/Notes/Note.php b/plugins/woocommerce/src/Admin/Notes/Note.php index 98995915cce3..8191b6aede7d 100644 --- a/plugins/woocommerce/src/Admin/Notes/Note.php +++ b/plugins/woocommerce/src/Admin/Notes/Note.php @@ -339,7 +339,7 @@ public function get_image( $context = 'view' ) { * Get deleted status. * * @param string $context What the value is for. Valid values are 'view' and 'edit'. - * @return array + * @return bool */ public function get_is_deleted( $context = 'view' ) { return $this->get_prop( 'is_deleted', $context ); @@ -349,7 +349,7 @@ public function get_is_deleted( $context = 'view' ) { * Get is_read status. * * @param string $context What the value is for. Valid values are 'view' and 'edit'. - * @return array + * @return bool */ public function get_is_read( $context = 'view' ) { return $this->get_prop( 'is_read', $context ); diff --git a/plugins/woocommerce/tests/legacy/unit-tests/woocommerce-admin/notes/class-wc-tests-notes-data-store.php b/plugins/woocommerce/tests/legacy/unit-tests/woocommerce-admin/notes/class-wc-tests-notes-data-store.php index fd232e36aae0..4f8ae24bc455 100644 --- a/plugins/woocommerce/tests/legacy/unit-tests/woocommerce-admin/notes/class-wc-tests-notes-data-store.php +++ b/plugins/woocommerce/tests/legacy/unit-tests/woocommerce-admin/notes/class-wc-tests-notes-data-store.php @@ -45,7 +45,7 @@ public function test_read() { $this->assertEquals( $note->get_type(), $read_note->get_type() ); $this->assertEquals( $note->get_name(), $read_note->get_name() ); $this->assertEquals( $note->get_source(), $read_note->get_source() ); - $this->assertEquals( $note->get_is_snoozable(), '0' !== $read_note->get_is_snoozable() ); + $this->assertEquals( $note->get_is_snoozable(), false !== $read_note->get_is_snoozable() ); $this->assertEquals( $note->get_layout(), $read_note->get_layout() ); $this->assertEquals( $note->get_image(), $read_note->get_image() ); $this->assertEquals( $note->get_actions(), $read_note->get_actions() );