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
CustomizingProductCatalog.php
85 lines
| 1 | <?php |
| 2 | /** |
| 3 | * WooCommerce Admin: How to customize your product catalog note provider |
| 4 | * |
| 5 | * Adds a note with a link to the customizer a day after adding the 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 | * Class CustomizingProductCatalog |
| 18 | * |
| 19 | * @package Automattic\WooCommerce\Admin\Notes |
| 20 | */ |
| 21 | class CustomizingProductCatalog { |
| 22 | /** |
| 23 | * Note traits. |
| 24 | */ |
| 25 | use NoteTraits; |
| 26 | |
| 27 | /** |
| 28 | * Name of the note for use in the database. |
| 29 | */ |
| 30 | const NOTE_NAME = 'wc-admin-customizing-product-catalog'; |
| 31 | |
| 32 | /** |
| 33 | * Get the note. |
| 34 | * |
| 35 | * @return Note |
| 36 | */ |
| 37 | public static function get_note() { |
| 38 | $query = new \WC_Product_Query( |
| 39 | array( |
| 40 | 'limit' => 1, |
| 41 | 'paginate' => true, |
| 42 | 'status' => array( ProductStatus::PUBLISH ), |
| 43 | 'orderby' => 'post_date', |
| 44 | 'order' => 'DESC', |
| 45 | ) |
| 46 | ); |
| 47 | |
| 48 | $products = $query->get_products(); |
| 49 | |
| 50 | // we need at least 1 product. |
| 51 | if ( 0 === $products->total ) { |
| 52 | return; |
| 53 | } |
| 54 | |
| 55 | $product = $products->products[0]; |
| 56 | $created_timestamp = $product->get_date_created()->getTimestamp(); |
| 57 | $is_a_day_old = ( time() - $created_timestamp ) >= DAY_IN_SECONDS; |
| 58 | |
| 59 | // the product must be at least 1 day old. |
| 60 | if ( ! $is_a_day_old ) { |
| 61 | return; |
| 62 | } |
| 63 | |
| 64 | // store must not been active more than 14 days. |
| 65 | if ( self::wc_admin_active_for( DAY_IN_SECONDS * 14 ) ) { |
| 66 | return; |
| 67 | } |
| 68 | |
| 69 | $note = new Note(); |
| 70 | $note->set_title( __( 'How to customize your product catalog', 'woocommerce' ) ); |
| 71 | $note->set_content( __( 'You want your product catalog and images to look great and align with your brand. This guide will give you all the tips you need to get your products looking great in your store.', 'woocommerce' ) ); |
| 72 | $note->set_type( Note::E_WC_ADMIN_NOTE_INFORMATIONAL ); |
| 73 | $note->set_name( self::NOTE_NAME ); |
| 74 | $note->set_content_data( (object) array() ); |
| 75 | $note->set_source( 'woocommerce-admin' ); |
| 76 | $note->add_action( |
| 77 | 'day-after-first-product', |
| 78 | __( 'Learn more', 'woocommerce' ), |
| 79 | 'https://woocommerce.com/document/woocommerce-customizer/?utm_source=inbox&utm_medium=product' |
| 80 | ); |
| 81 | |
| 82 | return $note; |
| 83 | } |
| 84 | } |
| 85 |