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
PaymentsRemindMeLater.php
81 lines
| 1 | <?php |
| 2 | /** |
| 3 | * WooCommerce Admin Payment Reminder Me later |
| 4 | */ |
| 5 | |
| 6 | namespace Automattic\WooCommerce\Internal\Admin\Notes; |
| 7 | |
| 8 | use Automattic\WooCommerce\Admin\Notes\Note; |
| 9 | use Automattic\WooCommerce\Admin\Notes\NoteTraits; |
| 10 | use Automattic\WooCommerce\Internal\Admin\WcPayWelcomePage; |
| 11 | |
| 12 | defined( 'ABSPATH' ) || exit; |
| 13 | |
| 14 | /** |
| 15 | * PaymentsRemindMeLater |
| 16 | */ |
| 17 | class PaymentsRemindMeLater { |
| 18 | /** |
| 19 | * Note traits. |
| 20 | */ |
| 21 | use NoteTraits; |
| 22 | |
| 23 | /** |
| 24 | * Name of the note for use in the database. |
| 25 | */ |
| 26 | const NOTE_NAME = 'wc-admin-payments-remind-me-later'; |
| 27 | |
| 28 | /** |
| 29 | * Should this note exist? |
| 30 | */ |
| 31 | public static function is_applicable() { |
| 32 | return self::should_display_note(); |
| 33 | } |
| 34 | |
| 35 | /** |
| 36 | * Returns true if we should display the note. |
| 37 | * |
| 38 | * @return bool |
| 39 | */ |
| 40 | public static function should_display_note() { |
| 41 | // A WooPayments incentive must be visible. |
| 42 | if ( ! WcPayWelcomePage::instance()->has_incentive() ) { |
| 43 | return false; |
| 44 | } |
| 45 | |
| 46 | // Less than 3 days since viewing welcome page. |
| 47 | $view_timestamp = get_option( 'wcpay_welcome_page_viewed_timestamp', false ); |
| 48 | if ( ! $view_timestamp || |
| 49 | ( time() - $view_timestamp < 3 * DAY_IN_SECONDS ) |
| 50 | ) { |
| 51 | return false; |
| 52 | } |
| 53 | return true; |
| 54 | } |
| 55 | |
| 56 | |
| 57 | /** |
| 58 | * Get the note. |
| 59 | * |
| 60 | * @return Note |
| 61 | */ |
| 62 | public static function get_note() { |
| 63 | if ( ! self::should_display_note() ) { |
| 64 | return; |
| 65 | } |
| 66 | /* translators: 1: Payment provider name. */ |
| 67 | $content = sprintf( __( 'Save up to $800 in fees by managing transactions with %1$s. With %1$s, you can securely accept major cards, Apple Pay, and payments in over 100 currencies.', 'woocommerce' ), 'WooPayments' ); |
| 68 | |
| 69 | $note = new Note(); |
| 70 | /* translators: %s: Payment provider name. */ |
| 71 | $note->set_title( sprintf( __( 'Save big with %s', 'woocommerce' ), 'WooPayments' ) ); |
| 72 | $note->set_content( $content ); |
| 73 | $note->set_content_data( (object) array() ); |
| 74 | $note->set_type( Note::E_WC_ADMIN_NOTE_INFORMATIONAL ); |
| 75 | $note->set_name( self::NOTE_NAME ); |
| 76 | $note->set_source( 'woocommerce-admin' ); |
| 77 | $note->add_action( 'learn-more', __( 'Learn more', 'woocommerce' ), admin_url( 'admin.php?page=wc-admin&path=/wc-pay-welcome-page' ) ); |
| 78 | return $note; |
| 79 | } |
| 80 | } |
| 81 |