Automattic\WooCommerce\Internal\Admin\Notes
NewSalesRecord::get_note_with_record_data()
Get the note with record data.
Method of the class: NewSalesRecord{}
No Hooks.
Return
Note
.
Usage
$result = NewSalesRecord::get_note_with_record_data( $record_date, $record_amt, $yesterday, $total );
- $record_date(string) (required)
- record date Y-m-d.
- $record_amt(float) (required)
- record amount.
- $yesterday(string) (required)
- yesterday's date Y-m-d.
- $total(string) (required)
- total sales for yesterday.
NewSalesRecord::get_note_with_record_data() NewSalesRecord::get note with record data code WC 9.4.2
public static function get_note_with_record_data( $record_date, $record_amt, $yesterday, $total ) { // Use F jS (March 7th) format for English speaking countries. if ( substr( get_user_locale(), 0, 2 ) === 'en' ) { $date_format = 'F jS'; } else { // otherwise, fallback to the system date format. $date_format = get_option( 'date_format' ); } $formatted_yesterday = date_i18n( $date_format, strtotime( $yesterday ) ); $formatted_total = html_entity_decode( wp_strip_all_tags( wc_price( $total ) ) ); $formatted_record_date = date_i18n( $date_format, strtotime( $record_date ) ); $formatted_record_amt = html_entity_decode( wp_strip_all_tags( wc_price( $record_amt ) ) ); $content = sprintf( /* translators: 1 and 4: Date (e.g. October 16th), 2 and 3: Amount (e.g. $160.00) */ __( 'Woohoo, %1$s was your record day for sales! Net sales was %2$s beating the previous record of %3$s set on %4$s.', 'woocommerce' ), $formatted_yesterday, $formatted_total, $formatted_record_amt, $formatted_record_date ); $content_data = (object) array( 'old_record_date' => $record_date, 'old_record_amt' => $record_amt, 'new_record_date' => $yesterday, 'new_record_amt' => $total, ); $report_url = '?page=wc-admin&path=/analytics/revenue&period=custom&compare=previous_year&after=' . $yesterday . '&before=' . $yesterday; // And now, create our new note. $note = new Note(); $note->set_title( __( 'New sales record!', 'woocommerce' ) ); $note->set_content( $content ); $note->set_content_data( $content_data ); $note->set_type( Note::E_WC_ADMIN_NOTE_INFORMATIONAL ); $note->set_name( self::NOTE_NAME ); $note->set_source( 'woocommerce-admin' ); $note->add_action( 'view-report', __( 'View report', 'woocommerce' ), $report_url ); return $note; }