Automattic\WooCommerce\Internal\Admin\Notes
WooSubscriptionsNotes::find_note_for_product_id
Finds a note for a given product ID, if the note exists at all.
Method of the class: WooSubscriptionsNotes{}
No Hooks.
Returns
Note|false.
Usage
$WooSubscriptionsNotes = new WooSubscriptionsNotes(); $WooSubscriptionsNotes->find_note_for_product_id( $product_id );
- $product_id(int) (required)
- The product ID to search for.
WooSubscriptionsNotes::find_note_for_product_id() WooSubscriptionsNotes::find note for product id code WC 10.4.3
public function find_note_for_product_id( $product_id ) {
$product_id = intval( $product_id );
$data_store = Notes::load_data_store();
$note_ids = $data_store->get_notes_with_name( self::SUBSCRIPTION_NOTE_NAME );
foreach ( (array) $note_ids as $note_id ) {
$note = Notes::get_note( $note_id );
$found_product_id = $this->get_product_id_from_subscription_note( $note );
if ( $product_id === $found_product_id ) {
return $note;
}
}
return false;
}