/var/www/html_us/wp-content/plugins/woocommerce/src/Internal/Admin/Notes/MagentoMigration.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
88
89
90
91
92
93
94
95
96
97
98
99
100
<?php
/**
 * WooCommerce Admin note on how to migrate from Magento.
 */

namespace Automattic\WooCommerce\Internal\Admin\Notes;

use 
Automattic\WooCommerce\Internal\Admin\Onboarding\OnboardingProfile;

defined'ABSPATH' ) || exit;

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

/**
 * MagentoMigration
 */
class MagentoMigration {
    
/**
     * Note traits.
     */
    
use NoteTraits;

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

    
/**
     * Attach hooks.
     */
    
public function __construct() {
        
add_action'update_option_' OnboardingProfile::DATA_OPTION, array( __CLASS__'possibly_add_note' ) );
        
add_action'woocommerce_admin_magento_migration_note', array( __CLASS__'save_note' ) );
    }

    
/**
     * Add the note if it passes predefined conditions.
     */
    
public static function possibly_add_note() {
        
$onboarding_profile get_optionOnboardingProfile::DATA_OPTION, array() );

        if ( empty( 
$onboarding_profile ) ) {
            return;
        }

        if (
            ! isset( 
$onboarding_profile['other_platform'] ) ||
            
'magento' !== $onboarding_profile['other_platform']
        ) {
            return;
        }

        if (
            ! isset( 
$onboarding_profile['setup_client'] ) ||
            
$onboarding_profile['setup_client']
        ) {
            return;
        }

        
WC()->queue()->schedule_singletime() + ( MINUTE_IN_SECONDS ), 'woocommerce_admin_magento_migration_note' );
    }

    
/**
     * Save the note to the database.
     */
    
public static function save_note() {
        
$note self::get_note();

        if ( 
self::note_exists() ) {
            return;
        }

        
$note->save();
    }

    
/**
     * Get the note.
     *
     * @return Note
     */
    
public static function get_note() {
        
$note = new Note();

        
$note->set_title__'How to Migrate from Magento to WooCommerce''woocommerce' ) );
        
$note->set_content__'Changing platforms might seem like a big hurdle to overcome, but it is easier than you might think to move your products, customers, and orders to WooCommerce. This article will help you with going through this process.''woocommerce' ) );
        
$note->set_content_data( (object) array() );
        
$note->set_typeNote::E_WC_ADMIN_NOTE_INFORMATIONAL );
        
$note->set_nameself::NOTE_NAME );
        
$note->set_source'woocommerce-admin' );
        
$note->add_action(
            
'learn-more',
            
__'Learn more''woocommerce' ),
            
'https://woocommerce.com/posts/how-migrate-from-magento-to-woocommerce/?utm_source=inbox'
        
);

        return 
$note;
    }
}