/var/www/html/wp-content/plugins/woocommerce/src/Internal/Admin/Notes/CustomizeStoreWithBlocks.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
<?php
/**
 * WooCommerce Admin: Customize your online store with WooCommerce blocks.
 *
 * Adds a note to customize the client online store with WooCommerce blocks.
 *
 * @package WooCommerce\Admin
 */

namespace Automattic\WooCommerce\Internal\Admin\Notes;

defined'ABSPATH' ) || exit;

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

/**
 * Customize_Store_With_Blocks.
 */
class CustomizeStoreWithBlocks {
    
/**
     * Note traits.
     */
    
use NoteTraits;

    
/**
     * Name of the note for use in the database.
     */
    
const NOTE_NAME 'wc-admin-customize-store-with-blocks';

    
/**
     * Get the note.
     *
     * @return Note
     */
    
public static function get_note() {
        
$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;
        }

        
// We want to show the note after fourteen days.
        
if ( ! self::is_wc_admin_active_in_date_range'week-1-4'14 DAY_IN_SECONDS ) ) {
            return;
        }

        
// Don't show if there aren't products.
        
$query    = new \WC_Product_Query(
            array(
                
'limit'  => 1,
                
'return' => 'ids',
                
'status' => array( 'publish' ),
            )
        );
        
$products $query->get_products();
        if ( 
=== count$products ) ) {
            return;
        }

        
$note = new Note();
        
$note->set_title__'Customize your online store with WooCommerce blocks''woocommerce' ) );
        
$note->set_content__'With our blocks, you can select and display products, categories, filters, and more virtually anywhere on your site — no need to use shortcodes or edit lines of code. Learn more about how to use each one of them.''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(
            
'customize-store-with-blocks',
            
__'Learn more''woocommerce' ),
            
'https://woocommerce.com/posts/how-to-customize-your-online-store-with-woocommerce-blocks/?utm_source=inbox&utm_medium=product',
            
Note::E_WC_ADMIN_NOTE_ACTIONED
        
);
        return 
$note;
    }
}