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
FirstProduct.php
88 lines
| 1 | <?php |
| 2 | /** |
| 3 | * WooCommerce Admin: Do you need help with adding your first product? |
| 4 | * |
| 5 | * Adds a note to ask the client if they need help adding their first product. |
| 6 | */ |
| 7 | |
| 8 | namespace Automattic\WooCommerce\Internal\Admin\Notes; |
| 9 | |
| 10 | defined( 'ABSPATH' ) || exit; |
| 11 | |
| 12 | use Automattic\WooCommerce\Admin\Notes\Note; |
| 13 | use Automattic\WooCommerce\Admin\Notes\NoteTraits; |
| 14 | use Automattic\WooCommerce\Enums\ProductStatus; |
| 15 | |
| 16 | /** |
| 17 | * First_Product. |
| 18 | */ |
| 19 | class FirstProduct { |
| 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-first-product'; |
| 29 | |
| 30 | /** |
| 31 | * Get the note. |
| 32 | * |
| 33 | * @return Note |
| 34 | */ |
| 35 | public static function get_note() { |
| 36 | // We want to show the note after seven days. |
| 37 | if ( ! self::is_wc_admin_active_in_date_range( 'week-1-4' ) ) { |
| 38 | return; |
| 39 | } |
| 40 | |
| 41 | $onboarding_profile = get_option( 'woocommerce_onboarding_profile', array() ); |
| 42 | |
| 43 | // Confirm that $onboarding_profile is set. |
| 44 | if ( empty( $onboarding_profile ) ) { |
| 45 | return; |
| 46 | } |
| 47 | |
| 48 | // Make sure that the person who filled out the OBW was not setting up |
| 49 | // the store for their customer/client. |
| 50 | if ( |
| 51 | ! isset( $onboarding_profile['setup_client'] ) || |
| 52 | $onboarding_profile['setup_client'] |
| 53 | ) { |
| 54 | return; |
| 55 | } |
| 56 | |
| 57 | // Don't show if there are products. |
| 58 | $query = new \WC_Product_Query( |
| 59 | array( |
| 60 | 'limit' => 1, |
| 61 | 'paginate' => true, |
| 62 | 'return' => 'ids', |
| 63 | 'status' => array( ProductStatus::PUBLISH ), |
| 64 | ) |
| 65 | ); |
| 66 | $products = $query->get_products(); |
| 67 | $count = $products->total; |
| 68 | if ( 0 !== $count ) { |
| 69 | return; |
| 70 | } |
| 71 | |
| 72 | $note = new Note(); |
| 73 | $note->set_title( __( 'Do you need help with adding your first product?', 'woocommerce' ) ); |
| 74 | $note->set_content( __( 'This video tutorial will help you go through the process of adding your first product in WooCommerce.', 'woocommerce' ) ); |
| 75 | $note->set_type( Note::E_WC_ADMIN_NOTE_INFORMATIONAL ); |
| 76 | $note->set_name( self::NOTE_NAME ); |
| 77 | $note->set_content_data( (object) array() ); |
| 78 | $note->set_source( 'woocommerce-admin' ); |
| 79 | $note->add_action( |
| 80 | 'first-product-watch-tutorial', |
| 81 | __( 'Watch tutorial', 'woocommerce' ), |
| 82 | 'https://www.youtube.com/watch?v=sFtXa00Jf_o&list=PLHdG8zvZd0E575Ia8Mu3w1h750YLXNfsC&index=24' |
| 83 | ); |
| 84 | |
| 85 | return $note; |
| 86 | } |
| 87 | } |
| 88 |