CustomizeStoreWithBlocks.php
2 years ago
CustomizingProductCatalog.php
1 year ago
EUVATNumber.php
2 years ago
EditProductsOnTheMove.php
2 years ago
EmailImprovements.php
1 year ago
FirstProduct.php
1 year ago
GivingFeedbackNotes.php
3 years ago
InstallJPAndWCSPlugins.php
4 weeks ago
LaunchChecklist.php
2 years ago
MagentoMigration.php
2 years ago
ManageOrdersOnTheGo.php
2 years ago
MarketingJetpack.php
4 weeks ago
MigrateFromShopify.php
2 years ago
MobileApp.php
2 years ago
NewSalesRecord.php
3 years ago
NoteActionForbiddenException.php
4 weeks ago
OnboardingPayments.php
2 years ago
OnlineClothingStore.php
2 years ago
OrderMilestones.php
2 years ago
PaymentsMoreInfoNeeded.php
5 months ago
PaymentsRemindMeLater.php
5 months ago
PerformanceOnMobile.php
2 years ago
PersonalizeStore.php
3 years ago
RealTimeOrderAlerts.php
2 years ago
ScheduledUpdatesPromotion.php
5 months ago
SellingOnlineCourses.php
2 years ago
TrackingOptIn.php
1 year ago
UnsecuredReportFiles.php
2 years ago
WooCommercePayments.php
2 years ago
WooCommerceSubscriptions.php
2 years ago
WooSubscriptionsNotes.php
1 year ago
MagentoMigration.php
101 lines
| 1 | <?php |
| 2 | /** |
| 3 | * WooCommerce Admin note on how to migrate from Magento. |
| 4 | */ |
| 5 | |
| 6 | namespace Automattic\WooCommerce\Internal\Admin\Notes; |
| 7 | |
| 8 | use Automattic\WooCommerce\Internal\Admin\Onboarding\OnboardingProfile; |
| 9 | |
| 10 | defined( 'ABSPATH' ) || exit; |
| 11 | |
| 12 | use Automattic\WooCommerce\Admin\Features\Onboarding; |
| 13 | use Automattic\WooCommerce\Admin\Notes\Note; |
| 14 | use Automattic\WooCommerce\Admin\Notes\NoteTraits; |
| 15 | |
| 16 | /** |
| 17 | * MagentoMigration |
| 18 | */ |
| 19 | class MagentoMigration { |
| 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-magento-migration'; |
| 29 | |
| 30 | /** |
| 31 | * Attach hooks. |
| 32 | */ |
| 33 | public function __construct() { |
| 34 | add_action( 'update_option_' . OnboardingProfile::DATA_OPTION, array( __CLASS__, 'possibly_add_note' ) ); |
| 35 | add_action( 'woocommerce_admin_magento_migration_note', array( __CLASS__, 'save_note' ) ); |
| 36 | } |
| 37 | |
| 38 | /** |
| 39 | * Add the note if it passes predefined conditions. |
| 40 | */ |
| 41 | public static function possibly_add_note() { |
| 42 | $onboarding_profile = get_option( OnboardingProfile::DATA_OPTION, array() ); |
| 43 | |
| 44 | if ( empty( $onboarding_profile ) ) { |
| 45 | return; |
| 46 | } |
| 47 | |
| 48 | if ( |
| 49 | ! isset( $onboarding_profile['other_platform'] ) || |
| 50 | 'magento' !== $onboarding_profile['other_platform'] |
| 51 | ) { |
| 52 | return; |
| 53 | } |
| 54 | |
| 55 | if ( |
| 56 | ! isset( $onboarding_profile['setup_client'] ) || |
| 57 | $onboarding_profile['setup_client'] |
| 58 | ) { |
| 59 | return; |
| 60 | } |
| 61 | |
| 62 | WC()->queue()->schedule_single( time() + ( 5 * MINUTE_IN_SECONDS ), 'woocommerce_admin_magento_migration_note' ); |
| 63 | } |
| 64 | |
| 65 | /** |
| 66 | * Save the note to the database. |
| 67 | */ |
| 68 | public static function save_note() { |
| 69 | $note = self::get_note(); |
| 70 | |
| 71 | if ( self::note_exists() ) { |
| 72 | return; |
| 73 | } |
| 74 | |
| 75 | $note->save(); |
| 76 | } |
| 77 | |
| 78 | /** |
| 79 | * Get the note. |
| 80 | * |
| 81 | * @return Note |
| 82 | */ |
| 83 | public static function get_note() { |
| 84 | $note = new Note(); |
| 85 | |
| 86 | $note->set_title( __( 'How to Migrate from Magento to WooCommerce', 'woocommerce' ) ); |
| 87 | $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' ) ); |
| 88 | $note->set_content_data( (object) array() ); |
| 89 | $note->set_type( Note::E_WC_ADMIN_NOTE_INFORMATIONAL ); |
| 90 | $note->set_name( self::NOTE_NAME ); |
| 91 | $note->set_source( 'woocommerce-admin' ); |
| 92 | $note->add_action( |
| 93 | 'learn-more', |
| 94 | __( 'Learn more', 'woocommerce' ), |
| 95 | 'https://woocommerce.com/posts/how-migrate-from-magento-to-woocommerce/?utm_source=inbox' |
| 96 | ); |
| 97 | |
| 98 | return $note; |
| 99 | } |
| 100 | } |
| 101 |