2020-06-18 01:28:27 +00:00
< ? php
/**
* WooCommerce Admin : Insight - First sale
*
* Adds a note to give insight about the first sale .
*
2020-08-11 19:18:47 +00:00
* @ package WooCommerce\Admin
2020-06-18 01:28:27 +00:00
*/
namespace Automattic\WooCommerce\Admin\Notes ;
defined ( 'ABSPATH' ) || exit ;
/**
2020-09-28 04:35:10 +00:00
* Insight_First_Sale .
2020-06-18 01:28:27 +00:00
*/
2020-10-28 17:12:14 +00:00
class InsightFirstSale {
2020-06-18 01:28:27 +00:00
/**
* Note traits .
*/
use NoteTraits ;
/**
* Name of the note for use in the database .
*/
const NOTE_NAME = 'wc-admin-insight-first-sale' ;
/**
* Get the note .
2020-09-28 04:35:10 +00:00
*
* @ return Note
2020-06-18 01:28:27 +00:00
*/
public static function get_note () {
// We want to show the note after eight days.
if ( ! self :: wc_admin_active_for ( 8 * DAY_IN_SECONDS ) ) {
return ;
}
2020-09-28 04:35:10 +00:00
$note = new Note ();
2020-07-02 18:56:06 +00:00
$note -> set_title ( __ ( 'Did you know?' , 'woocommerce-admin' ) );
2020-06-18 01:28:27 +00:00
$note -> set_content ( __ ( 'A WooCommerce powered store needs on average 31 days to get the first sale. You\'re on the right track! Do you find this type of insight useful?' , 'woocommerce-admin' ) );
2020-09-28 04:35:10 +00:00
$note -> set_type ( Note :: E_WC_ADMIN_NOTE_SURVEY );
2020-06-18 01:28:27 +00:00
$note -> set_name ( self :: NOTE_NAME );
$note -> set_content_data ( ( object ) array () );
$note -> set_source ( 'woocommerce-admin' );
// Note that there is no corresponding function called in response to
// this. Apart from setting the note to actioned a tracks event is
// sent in NoteActions.
$note -> add_action (
'affirm-insight-first-sale' ,
__ ( 'Yes' , 'woocommerce-admin' ),
false ,
2020-09-28 04:35:10 +00:00
Note :: E_WC_ADMIN_NOTE_ACTIONED ,
2020-06-18 01:28:27 +00:00
false ,
__ ( 'Thanks for your feedback' , 'woocommerce-admin' )
);
$note -> add_action (
'deny-insight-first-sale' ,
__ ( 'No' , 'woocommerce-admin' ),
false ,
2020-09-28 04:35:10 +00:00
Note :: E_WC_ADMIN_NOTE_ACTIONED ,
2020-06-18 01:28:27 +00:00
false ,
__ ( 'Thanks for your feedback' , 'woocommerce-admin' )
);
return $note ;
}
}