/var/www/html_us/wp-content/plugins/woocommerce/src/Internal/Admin/Notes/FirstProduct.php


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
<?php
/**
 * WooCommerce Admin: Do you need help with adding your first product?
 *
 * Adds a note to ask the client if they need help adding their first product.
 */

namespace Automattic\WooCommerce\Internal\Admin\Notes;

defined'ABSPATH' ) || exit;

use 
Automattic\WooCommerce\Admin\Notes\Note;
use 
Automattic\WooCommerce\Admin\Notes\NoteTraits;
use 
Automattic\WooCommerce\Enums\ProductStatus;

/**
 * First_Product.
 */
class FirstProduct {
    
/**
     * Note traits.
     */
    
use NoteTraits;

    
/**
     * Name of the note for use in the database.
     */
    
const NOTE_NAME 'wc-admin-first-product';

    
/**
     * Get the note.
     *
     * @return Note
     */
    
public static function get_note() {
        
// We want to show the note after seven days.
        
if ( ! self::is_wc_admin_active_in_date_range'week-1-4' ) ) {
            return;
        }

        
$onboarding_profile get_option'woocommerce_onboarding_profile', array() );

        
// Confirm that $onboarding_profile is set.
        
if ( empty( $onboarding_profile ) ) {
            return;
        }

        
// Make sure that the person who filled out the OBW was not setting up
        // the store for their customer/client.
        
if (
            ! isset( 
$onboarding_profile['setup_client'] ) ||
            
$onboarding_profile['setup_client']
        ) {
            return;
        }

        
// Don't show if there are products.
        
$query    = new \WC_Product_Query(
            array(
                
'limit'    => 1,
                
'paginate' => true,
                
'return'   => 'ids',
                
'status'   => array( ProductStatus::PUBLISH ),
            )
        );
        
$products $query->get_products();
        
$count    $products->total;
        if ( 
!== $count ) {
            return;
        }

        
$note = new Note();
        
$note->set_title__'Do you need help with adding your first product?''woocommerce' ) );
        
$note->set_content__'This video tutorial will help you go through the process of adding your first product in WooCommerce.''woocommerce' ) );
        
$note->set_typeNote::E_WC_ADMIN_NOTE_INFORMATIONAL );
        
$note->set_nameself::NOTE_NAME );
        
$note->set_content_data( (object) array() );
        
$note->set_source'woocommerce-admin' );
        
$note->add_action(
            
'first-product-watch-tutorial',
            
__'Watch tutorial''woocommerce' ),
            
'https://www.youtube.com/watch?v=sFtXa00Jf_o&list=PLHdG8zvZd0E575Ia8Mu3w1h750YLXNfsC&index=24'
        
);

        return 
$note;
    }
}