PluginProbe
WooCommerce / 11.0.1
WooCommerce v11.0.1
11.1.0 11.1.0-rc.2 11.1.0-rc.1 11.1.0-beta.2 11.1.0-beta.1 11.0.1 11.0.0 11.0.0-rc.3 11.0.0-rc.2 11.0.0-rc.1 11.0.0-beta.2 11.0.0-beta.1 10.9.4 10.9.3 10.9.2 10.9.1 10.9.0 10.9.0-rc.1 10.9.0-beta.2 10.9.0-beta.1 10.8.1 10.8.0 10.8.0-rc.1 10.8.0-beta.2 10.8.0-beta.1 All 648 releases
woocommerce / src / Internal / Admin / Notes / FirstProduct.php
FirstProduct.php
88 lines 2.2 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * WooCommerce Admin: Do you need help with adding your first product?
4 *
5 * Adds a note to ask the client if they need help adding their first product.
6 */
7
8 namespace Automattic\WooCommerce\Internal\Admin\Notes;
9
10 defined( 'ABSPATH' ) || exit;
11
12 use Automattic\WooCommerce\Admin\Notes\Note;
13 use Automattic\WooCommerce\Admin\Notes\NoteTraits;
14 use Automattic\WooCommerce\Enums\ProductStatus;
15
16 /**
17 * First_Product.
18 */
19 class FirstProduct {
20 /**
21 * Note traits.
22 */
23 use NoteTraits;
24
25 /**
26 * Name of the note for use in the database.
27 */
28 const NOTE_NAME = 'wc-admin-first-product';
29
30 /**
31 * Get the note.
32 *
33 * @return Note
34 */
35 public static function get_note() {
36 // We want to show the note after seven days.
37 if ( ! self::is_wc_admin_active_in_date_range( 'week-1-4' ) ) {
38 return;
39 }
40
41 $onboarding_profile = get_option( 'woocommerce_onboarding_profile', array() );
42
43 // Confirm that $onboarding_profile is set.
44 if ( empty( $onboarding_profile ) ) {
45 return;
46 }
47
48 // Make sure that the person who filled out the OBW was not setting up
49 // the store for their customer/client.
50 if (
51 ! isset( $onboarding_profile['setup_client'] ) ||
52 $onboarding_profile['setup_client']
53 ) {
54 return;
55 }
56
57 // Don't show if there are products.
58 $query = new \WC_Product_Query(
59 array(
60 'limit' => 1,
61 'paginate' => true,
62 'return' => 'ids',
63 'status' => array( ProductStatus::PUBLISH ),
64 )
65 );
66 $products = $query->get_products();
67 $count = $products->total;
68 if ( 0 !== $count ) {
69 return;
70 }
71
72 $note = new Note();
73 $note->set_title( __( 'Do you need help with adding your first product?', 'woocommerce' ) );
74 $note->set_content( __( 'This video tutorial will help you go through the process of adding your first product in WooCommerce.', 'woocommerce' ) );
75 $note->set_type( Note::E_WC_ADMIN_NOTE_INFORMATIONAL );
76 $note->set_name( self::NOTE_NAME );
77 $note->set_content_data( (object) array() );
78 $note->set_source( 'woocommerce-admin' );
79 $note->add_action(
80 'first-product-watch-tutorial',
81 __( 'Watch tutorial', 'woocommerce' ),
82 'https://www.youtube.com/watch?v=sFtXa00Jf_o&list=PLHdG8zvZd0E575Ia8Mu3w1h750YLXNfsC&index=24'
83 );
84
85 return $note;
86 }
87 }
88