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
1 month ago
LaunchChecklist.php
2 years ago
MagentoMigration.php
2 years ago
ManageOrdersOnTheGo.php
2 years ago
MarketingJetpack.php
1 month ago
MigrateFromShopify.php
2 years ago
MobileApp.php
2 years ago
NewSalesRecord.php
3 years ago
NoteActionForbiddenException.php
1 month 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
CustomizeStoreWithBlocks.php
87 lines
| 1 | <?php |
| 2 | /** |
| 3 | * WooCommerce Admin: Customize your online store with WooCommerce blocks. |
| 4 | * |
| 5 | * Adds a note to customize the client online store with WooCommerce blocks. |
| 6 | * |
| 7 | * @package WooCommerce\Admin |
| 8 | */ |
| 9 | |
| 10 | namespace Automattic\WooCommerce\Internal\Admin\Notes; |
| 11 | |
| 12 | defined( 'ABSPATH' ) || exit; |
| 13 | |
| 14 | use Automattic\WooCommerce\Admin\Notes\Note; |
| 15 | use Automattic\WooCommerce\Admin\Notes\NoteTraits; |
| 16 | |
| 17 | /** |
| 18 | * Customize_Store_With_Blocks. |
| 19 | */ |
| 20 | class CustomizeStoreWithBlocks { |
| 21 | /** |
| 22 | * Note traits. |
| 23 | */ |
| 24 | use NoteTraits; |
| 25 | |
| 26 | /** |
| 27 | * Name of the note for use in the database. |
| 28 | */ |
| 29 | const NOTE_NAME = 'wc-admin-customize-store-with-blocks'; |
| 30 | |
| 31 | /** |
| 32 | * Get the note. |
| 33 | * |
| 34 | * @return Note |
| 35 | */ |
| 36 | public static function get_note() { |
| 37 | $onboarding_profile = get_option( 'woocommerce_onboarding_profile', array() ); |
| 38 | |
| 39 | // Confirm that $onboarding_profile is set. |
| 40 | if ( empty( $onboarding_profile ) ) { |
| 41 | return; |
| 42 | } |
| 43 | |
| 44 | // Make sure that the person who filled out the OBW was not setting up |
| 45 | // the store for their customer/client. |
| 46 | if ( |
| 47 | ! isset( $onboarding_profile['setup_client'] ) || |
| 48 | $onboarding_profile['setup_client'] |
| 49 | ) { |
| 50 | return; |
| 51 | } |
| 52 | |
| 53 | // We want to show the note after fourteen days. |
| 54 | if ( ! self::is_wc_admin_active_in_date_range( 'week-1-4', 14 * DAY_IN_SECONDS ) ) { |
| 55 | return; |
| 56 | } |
| 57 | |
| 58 | // Don't show if there aren't products. |
| 59 | $query = new \WC_Product_Query( |
| 60 | array( |
| 61 | 'limit' => 1, |
| 62 | 'return' => 'ids', |
| 63 | 'status' => array( 'publish' ), |
| 64 | ) |
| 65 | ); |
| 66 | $products = $query->get_products(); |
| 67 | if ( 0 === count( $products ) ) { |
| 68 | return; |
| 69 | } |
| 70 | |
| 71 | $note = new Note(); |
| 72 | $note->set_title( __( 'Customize your online store with WooCommerce blocks', 'woocommerce' ) ); |
| 73 | $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' ) ); |
| 74 | $note->set_type( Note::E_WC_ADMIN_NOTE_INFORMATIONAL ); |
| 75 | $note->set_name( self::NOTE_NAME ); |
| 76 | $note->set_content_data( (object) array() ); |
| 77 | $note->set_source( 'woocommerce-admin' ); |
| 78 | $note->add_action( |
| 79 | 'customize-store-with-blocks', |
| 80 | __( 'Learn more', 'woocommerce' ), |
| 81 | 'https://woocommerce.com/posts/how-to-customize-your-online-store-with-woocommerce-blocks/?utm_source=inbox&utm_medium=product', |
| 82 | Note::E_WC_ADMIN_NOTE_ACTIONED |
| 83 | ); |
| 84 | return $note; |
| 85 | } |
| 86 | } |
| 87 |