Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WC Home active disputes task: improve wording and reduce due_by threshold to align with Payments Overview task #6548

Merged
merged 55 commits into from
Jun 23, 2023

Conversation

shendy-a8c
Copy link
Contributor

@shendy-a8c shendy-a8c commented Jun 17, 2023

Fixes #6505

Changes proposed in this Pull Request

This PR updates the WC → Home dispute resolution task with the same wording as the Payments → Overview dispute resolution task (see client/overview/task-list/dispute-tasks.ts). The task will now only appear when at least 1 dispute is due within 7 days.

Wc Home Task implemented in this PR:
image

I've also fixed some bugs with the Payments → Overview task that slipped through:

  • Show datetimes in local timezones.
  • Compare due_by datetimes with the current UTC datetime when determining within 1 or 7 days.
  • Fix wording to be consistent with design: 'Last week to respond forto %d of the disputes'.

Note
The dispute reason (e.g. fraudulent) is not part of this PR, to remain consistent with the Payments → Overview task wording.

image

Single/multiple disputes with > 7 days until due

  • Visibility: Not visible

Single dispute with < 7 days until due

  • Title: Respond to a dispute for $123.00
  • Subtitle: By Jun 30, 2023 – 1 week left to respond
  • Action redirect: Single dispute details page

Single dispute with < 24 hours until due

  • Title: Respond to a dispute for $123.00 – Last day
  • Subtitle: Respond today by 11:59 PM
  • Action redirect: Single dispute details page

Multiple disputes with at least one due within 7 days

  • Title: Respond to N active disputes for a total of $123.00, €123.00
  • Subtitle: Last week to respond to N of the disputes
  • Action redirect: Active disputes list screen

Multiple disputes with at least one due within 24 hours

  • Title: Respond to N active disputes for a total of $123.00, €123.00
  • Subtitle: Final day to respond to N of the disputes
  • Action redirect: Active disputes list screen

Testing instructions

Mocking disputes

Unfortunately, testing this organically requires waiting 7+ days after creating a disputed transaction.

I was able to mock disputes for both Payments → Overview and WC → Home by insertings the following code to the respective get_* functions and adjusting due_by dates as necessary.

$data = $this->send( $hook, ...$args );

if ( 'wcpay_list_disputes_request' === $hook ) {
	$json     = '
	[
			{
				"wcpay_disputes_cache_id": 398047,
				"stripe_account_id": "acct_1NIiMhCBu6Jj8nBr",
				"dispute_id": "dp_1NKx6XCBu6Jj8nBrO4UXe99M",
				"charge_id": "ch_3NKx6FCBu6Jj8nBr0pPOqaaW",
				"amount": 6000,
				"currency": "gbp",
				"reason": "product_not_received",
				"source": "visa",
				"order_number": 76,
				"customer_name": "Test Shopper",
				"customer_email": "[email protected]",
				"customer_country": "DE",
				"status": "needs_response",
				"created": "2023-06-20 05:27:49",
				"due_by": "2023-06-29 23:59:59",
				"order": {
					"number": "76",
					"url": "https:\/\/woo-delectably-sparkly-ninja.wpcomstaging.com\/wp-admin\/post.php?post=76&action=edit",
					"customer_url": "admin.php?page=wc-admin&path=\/customers&filter=single_customer&customers=1",
					"subscriptions": []
				}
			},
			{
				"wcpay_disputes_cache_id": 397238,
				"stripe_account_id": "acct_1NIiMhCBu6Jj8nBr",
				"dispute_id": "dp_1NKXStCBu6Jj8nBrs0B9G8uJ",
				"charge_id": "ch_3NKXSZCBu6Jj8nBr1awQDFbd",
				"amount": 12000,
				"currency": "eur",
				"reason": "fraudulent",
				"source": "visa",
				"order_number": 74,
				"customer_name": "Test Shopper",
				"customer_email": "[email protected]",
				"customer_country": "DE",
				"status": "warning_needs_response",
				"created": "2023-06-19 02:05:11",
				"due_by": "2023-06-28 23:59:59",
				"order": {
					"number": "74",
					"url": "https:\/\/woo-delectably-sparkly-ninja.wpcomstaging.com\/wp-admin\/post.php?post=74&action=edit",
					"customer_url": "admin.php?page=wc-admin&path=\/customers&filter=single_customer&customers=1",
					"subscriptions": []
				}
			},
			{
				"wcpay_disputes_cache_id": 397236,
				"stripe_account_id": "acct_1NIiMhCBu6Jj8nBr",
				"dispute_id": "dp_1NKXQMCBu6Jj8nBrlbISviVo",
				"charge_id": "ch_3NKXQLCBu6Jj8nBr0Ho9gWUZ",
				"amount": 7700,
				"currency": "usd",
				"reason": "product_not_received",
				"source": "visa",
				"order_number": 72,
				"customer_name": "Test Shopper",
				"customer_email": "[email protected]",
				"customer_country": "DE",
				"status": "needs_response",
				"created": "2023-06-19 02:02:34",
				"due_by": "2023-06-28 23:59:59",
				"order": {
					"number": "72",
					"url": "https:\/\/woo-delectably-sparkly-ninja.wpcomstaging.com\/wp-admin\/post.php?post=72&action=edit",
					"customer_url": "admin.php?page=wc-admin&path=\/customers&filter=single_customer&customers=1",
					"subscriptions": []
				}
			},
			{
				"wcpay_disputes_cache_id": 393773,
				"stripe_account_id": "acct_1NIiMhCBu6Jj8nBr",
				"dispute_id": "dp_1NImELCBu6Jj8nBrENWv168J",
				"charge_id": "ch_3NImEKCBu6Jj8nBr0y3I1qOL",
				"amount": 1400,
				"currency": "usd",
				"reason": "fraudulent",
				"source": "visa",
				"order_number": 70,
				"customer_name": "Test Shopper",
				"customer_email": "[email protected]",
				"customer_country": "DE",
				"status": "needs_response",
				"created": "2023-06-14 05:26:53",
				"due_by": "2023-06-23 23:59:59",
				"order": {
					"number": "70",
					"url": "https:\/\/woo-delectably-sparkly-ninja.wpcomstaging.com\/wp-admin\/post.php?post=70&action=edit",
					"customer_url": "admin.php?page=wc-admin&path=\/customers&filter=single_customer&customers=1",
					"subscriptions": [
						{
							"number": "71",
							"url": "https:\/\/woo-delectably-sparkly-ninja.wpcomstaging.com\/wp-admin\/post.php?post=71&action=edit"
						}
					]
				}
			},
			{
				"wcpay_disputes_cache_id": 393757,
				"stripe_account_id": "acct_1NIiMhCBu6Jj8nBr",
				"dispute_id": "dp_1NIm41CBu6Jj8nBrN9hCquFx",
				"charge_id": "ch_3NIm40CBu6Jj8nBr1DPP5oNx",
				"amount": 3800,
				"currency": "usd",
				"reason": "fraudulent",
				"source": "visa",
				"order_number": 68,
				"customer_name": "Test Shopper",
				"customer_email": "[email protected]",
				"customer_country": "DE",
				"status": "needs_response",
				"created": "2023-06-14 05:16:13",
				"due_by": "2023-06-23 23:59:59",
				"order": {
					"number": "68",
					"url": "https:\/\/woo-delectably-sparkly-ninja.wpcomstaging.com\/wp-admin\/post.php?post=68&action=edit",
					"customer_url": "admin.php?page=wc-admin&path=\/customers&filter=single_customer&customers=1",
					"subscriptions": []
				}
			},
			{
				"wcpay_disputes_cache_id": 393755,
				"stripe_account_id": "acct_1NIiMhCBu6Jj8nBr",
				"dispute_id": "dp_1NIm3aCBu6Jj8nBrSuSk19uU",
				"charge_id": "ch_3NIm3ZCBu6Jj8nBr0frWIrse",
				"amount": 6000,
				"currency": "gbp",
				"reason": "fraudulent",
				"source": "visa",
				"order_number": 67,
				"customer_name": "Test Shopper",
				"customer_email": "[email protected]",
				"customer_country": "DE",
				"status": "needs_response",
				"created": "2023-06-14 05:15:46",
				"due_by": "2023-06-23 23:59:59",
				"order": {
					"number": "67",
					"url": "https:\/\/woo-delectably-sparkly-ninja.wpcomstaging.com\/wp-admin\/post.php?post=67&action=edit",
					"customer_url": "admin.php?page=wc-admin&path=\/customers&filter=single_customer&customers=1",
					"subscriptions": []
				}
			},
			{
				"wcpay_disputes_cache_id": 393725,
				"stripe_account_id": "acct_1NIiMhCBu6Jj8nBr",
				"dispute_id": "dp_1NIihwCBu6Jj8nBrK18xCDFh",
				"charge_id": "ch_3NIihhCBu6Jj8nBr0fMTOywi",
				"amount": 7000,
				"currency": "eur",
				"reason": "fraudulent",
				"source": "visa",
				"order_number": 65,
				"customer_name": "Test Shopper",
				"customer_email": "[email protected]",
				"customer_country": "DE",
				"status": "needs_response",
				"created": "2023-06-14 01:41:12",
				"due_by": "2023-06-23 23:59:59",
				"order": {
					"number": "65",
					"url": "https:\/\/woo-delectably-sparkly-ninja.wpcomstaging.com\/wp-admin\/post.php?post=65&action=edit",
					"customer_url": "admin.php?page=wc-admin&path=\/customers&filter=single_customer&customers=1",
					"subscriptions": []
				}
			}]
		';
		$data = json_decode( $json, true );
		$data = array_map(
			function( $dispute ) {
				$dispute['due_by'] = '2023-06-21 23:59:59';
				return $dispute;
			},
			$data
		);
		// return just an array of one dispute.
		$data = array_slice( $data, 0, 1 );

		return [
			'data' => $data,
		];
}

return $this->request( $filters, self::DISPUTES_API, self::GET );

$json         = '
[
		{
			"wcpay_disputes_cache_id": 398047,
			"stripe_account_id": "acct_1NIiMhCBu6Jj8nBr",
			"dispute_id": "dp_1NKx6XCBu6Jj8nBrO4UXe99M",
			"charge_id": "ch_3NKx6FCBu6Jj8nBr0pPOqaaW",
			"amount": 6000,
			"currency": "gbp",
			"reason": "product_not_received",
			"source": "visa",
			"order_number": 76,
			"customer_name": "Test Shopper",
			"customer_email": "[email protected]",
			"customer_country": "DE",
			"status": "needs_response",
			"created": "2023-06-20 05:27:49",
			"due_by": "2023-06-29 23:59:59",
			"order": {
				"number": "76",
				"url": "https:\/\/woo-delectably-sparkly-ninja.wpcomstaging.com\/wp-admin\/post.php?post=76&action=edit",
				"customer_url": "admin.php?page=wc-admin&path=\/customers&filter=single_customer&customers=1",
				"subscriptions": []
			}
		},
		{
			"wcpay_disputes_cache_id": 397238,
			"stripe_account_id": "acct_1NIiMhCBu6Jj8nBr",
			"dispute_id": "dp_1NKXStCBu6Jj8nBrs0B9G8uJ",
			"charge_id": "ch_3NKXSZCBu6Jj8nBr1awQDFbd",
			"amount": 12000,
			"currency": "eur",
			"reason": "fraudulent",
			"source": "visa",
			"order_number": 74,
			"customer_name": "Test Shopper",
			"customer_email": "[email protected]",
			"customer_country": "DE",
			"status": "warning_needs_response",
			"created": "2023-06-19 02:05:11",
			"due_by": "2023-06-28 23:59:59",
			"order": {
				"number": "74",
				"url": "https:\/\/woo-delectably-sparkly-ninja.wpcomstaging.com\/wp-admin\/post.php?post=74&action=edit",
				"customer_url": "admin.php?page=wc-admin&path=\/customers&filter=single_customer&customers=1",
				"subscriptions": []
			}
		},
		{
			"wcpay_disputes_cache_id": 397236,
			"stripe_account_id": "acct_1NIiMhCBu6Jj8nBr",
			"dispute_id": "dp_1NKXQMCBu6Jj8nBrlbISviVo",
			"charge_id": "ch_3NKXQLCBu6Jj8nBr0Ho9gWUZ",
			"amount": 7700,
			"currency": "usd",
			"reason": "product_not_received",
			"source": "visa",
			"order_number": 72,
			"customer_name": "Test Shopper",
			"customer_email": "[email protected]",
			"customer_country": "DE",
			"status": "needs_response",
			"created": "2023-06-19 02:02:34",
			"due_by": "2023-06-28 23:59:59",
			"order": {
				"number": "72",
				"url": "https:\/\/woo-delectably-sparkly-ninja.wpcomstaging.com\/wp-admin\/post.php?post=72&action=edit",
				"customer_url": "admin.php?page=wc-admin&path=\/customers&filter=single_customer&customers=1",
				"subscriptions": []
			}
		},
		{
			"wcpay_disputes_cache_id": 393773,
			"stripe_account_id": "acct_1NIiMhCBu6Jj8nBr",
			"dispute_id": "dp_1NImELCBu6Jj8nBrENWv168J",
			"charge_id": "ch_3NImEKCBu6Jj8nBr0y3I1qOL",
			"amount": 1400,
			"currency": "usd",
			"reason": "fraudulent",
			"source": "visa",
			"order_number": 70,
			"customer_name": "Test Shopper",
			"customer_email": "[email protected]",
			"customer_country": "DE",
			"status": "needs_response",
			"created": "2023-06-14 05:26:53",
			"due_by": "2023-06-23 23:59:59",
			"order": {
				"number": "70",
				"url": "https:\/\/woo-delectably-sparkly-ninja.wpcomstaging.com\/wp-admin\/post.php?post=70&action=edit",
				"customer_url": "admin.php?page=wc-admin&path=\/customers&filter=single_customer&customers=1",
				"subscriptions": [
					{
						"number": "71",
						"url": "https:\/\/woo-delectably-sparkly-ninja.wpcomstaging.com\/wp-admin\/post.php?post=71&action=edit"
					}
				]
			}
		},
		{
			"wcpay_disputes_cache_id": 393757,
			"stripe_account_id": "acct_1NIiMhCBu6Jj8nBr",
			"dispute_id": "dp_1NIm41CBu6Jj8nBrN9hCquFx",
			"charge_id": "ch_3NIm40CBu6Jj8nBr1DPP5oNx",
			"amount": 3800,
			"currency": "usd",
			"reason": "fraudulent",
			"source": "visa",
			"order_number": 68,
			"customer_name": "Test Shopper",
			"customer_email": "[email protected]",
			"customer_country": "DE",
			"status": "needs_response",
			"created": "2023-06-14 05:16:13",
			"due_by": "2023-06-23 23:59:59",
			"order": {
				"number": "68",
				"url": "https:\/\/woo-delectably-sparkly-ninja.wpcomstaging.com\/wp-admin\/post.php?post=68&action=edit",
				"customer_url": "admin.php?page=wc-admin&path=\/customers&filter=single_customer&customers=1",
				"subscriptions": []
			}
		},
		{
			"wcpay_disputes_cache_id": 393755,
			"stripe_account_id": "acct_1NIiMhCBu6Jj8nBr",
			"dispute_id": "dp_1NIm3aCBu6Jj8nBrSuSk19uU",
			"charge_id": "ch_3NIm3ZCBu6Jj8nBr0frWIrse",
			"amount": 6000,
			"currency": "gbp",
			"reason": "fraudulent",
			"source": "visa",
			"order_number": 67,
			"customer_name": "Test Shopper",
			"customer_email": "[email protected]",
			"customer_country": "DE",
			"status": "needs_response",
			"created": "2023-06-14 05:15:46",
			"due_by": "2023-06-23 23:59:59",
			"order": {
				"number": "67",
				"url": "https:\/\/woo-delectably-sparkly-ninja.wpcomstaging.com\/wp-admin\/post.php?post=67&action=edit",
				"customer_url": "admin.php?page=wc-admin&path=\/customers&filter=single_customer&customers=1",
				"subscriptions": []
			}
		},
		{
			"wcpay_disputes_cache_id": 393725,
			"stripe_account_id": "acct_1NIiMhCBu6Jj8nBr",
			"dispute_id": "dp_1NIihwCBu6Jj8nBrK18xCDFh",
			"charge_id": "ch_3NIihhCBu6Jj8nBr0fMTOywi",
			"amount": 7000,
			"currency": "eur",
			"reason": "fraudulent",
			"source": "visa",
			"order_number": 65,
			"customer_name": "Test Shopper",
			"customer_email": "[email protected]",
			"customer_country": "DE",
			"status": "needs_response",
			"created": "2023-06-14 01:41:12",
			"due_by": "2023-06-23 23:59:59",
			"order": {
				"number": "65",
				"url": "https:\/\/woo-delectably-sparkly-ninja.wpcomstaging.com\/wp-admin\/post.php?post=65&action=edit",
				"customer_url": "admin.php?page=wc-admin&path=\/customers&filter=single_customer&customers=1",
				"subscriptions": []
			}
		}]
	';
$data = json_decode( $json, true );
$data = array_map(
	function( $dispute ) {
		$dispute['due_by'] = '2023-06-21 23:59:59';
		return $dispute;
	},
	$data
);
// return just an array of one dispute.
$data = array_slice( $data, 0, 1 );
return [
	'data' => $data,
];
  • Tip: To create a disputed transaction, purchase a product with the Stripe test card 4000000000000259.
  • View the WC → Home screen with the following configuration of disputes and confirm it matches the requirements above:
    • 0 active disputes (task not visible)
    • 1+ active disputes due more than 7 days in the future (task not visible)
    • 1 active dispute due within 7 days
    • 1 active dispute due within 24h
    • 2+ active disputes of multiple currencies due within 7 days
    • 2+ active disputes of multiple currencies due within 24h

  • Run npm run changelog to add a changelog file, choose patch to leave it empty if the change is not significant. You can add multiple changelog files in one PR by running this command a few times.
  • Covered with tests (or have a good reason not to test in description ☝️)
  • Tested on mobile (or does not apply)

Post merge

@botwoo
Copy link
Collaborator

botwoo commented Jun 17, 2023

Test the build

Option 1. Jetpack Beta

  • Install and activate Jetpack Beta.
  • Use this build by searching for PR number 6548 or branch name update/6505-dispute-task-wc-home in your-test.site/wp-admin/admin.php?page=jetpack-beta&plugin=woocommerce-payments

Option 2. Jurassic Ninja - available for logged-in A12s

🚀 Launch a JN site with this branch 🚀

ℹ️ Install this Tampermonkey script to get more options.


Build info:

  • Latest commit: b10377c
  • Build time: 2023-06-22 03:19:14 UTC

Note: the build is updated when a new commit is pushed to this PR.

@shendy-a8c
Copy link
Contributor Author

shendy-a8c commented Jun 17, 2023

As of current state, this PR should be functional with a hard-coded test data.

Screenshot 2023-06-17 at 12 18 09

Still many TODOs:

  • TODOs in the code.
  • Unit tests.
  • Changelog.
  • Fix Psalm errors
ERROR: UndefinedDocblockClass - �
		TaskLists::add_task( 'extended', new WC_Payments_Task_Disputes( \WC_Payments::create_api_client(), \WC_Payments::get_database_cache() ) );


ERROR: InvalidArgument - �
		TaskLists::add_task( 'extended', new WC_Payments_Task_Disputes( \WC_Payments::create_api_client(), \WC_Payments::get_database_cache() ) );
  • Add testing instructions to the PR description.

@github-actions
Copy link
Contributor

github-actions bot commented Jun 17, 2023

Size Change: +18 B (0%)

Total Size: 1.21 MB

Filename Size Change
release/woocommerce-payments/dist/index.js 272 kB +18 B (0%)
ℹ️ View Unchanged
Filename Size
release/woocommerce-payments/assets/css/admin.css 1.03 kB
release/woocommerce-payments/assets/css/success.css 401 B
release/woocommerce-payments/dist/blocks-checkout.css 1.4 kB
release/woocommerce-payments/dist/blocks-checkout.js 39.5 kB
release/woocommerce-payments/dist/checkout.css 444 B
release/woocommerce-payments/dist/checkout.js 28.3 kB
release/woocommerce-payments/dist/index.css 38.8 kB
release/woocommerce-payments/dist/multi-currency-analytics.js 1.05 kB
release/woocommerce-payments/dist/multi-currency-switcher-block.js 60.4 kB
release/woocommerce-payments/dist/multi-currency.css 2.9 kB
release/woocommerce-payments/dist/multi-currency.js 55 kB
release/woocommerce-payments/dist/order.css 248 B
release/woocommerce-payments/dist/order.js 20.8 kB
release/woocommerce-payments/dist/payment-gateways.css 704 B
release/woocommerce-payments/dist/payment-gateways.js 38.4 kB
release/woocommerce-payments/dist/payment-request.js 11.6 kB
release/woocommerce-payments/dist/product-details.js 595 B
release/woocommerce-payments/dist/settings.css 8.74 kB
release/woocommerce-payments/dist/settings.js 197 kB
release/woocommerce-payments/dist/subscription-edit-page.js 669 B
release/woocommerce-payments/dist/subscription-product-onboarding-modal.css 527 B
release/woocommerce-payments/dist/subscription-product-onboarding-modal.js 20.1 kB
release/woocommerce-payments/dist/subscription-product-onboarding-toast.js 688 B
release/woocommerce-payments/dist/subscriptions-empty-state.css 298 B
release/woocommerce-payments/dist/subscriptions-empty-state.js 19.3 kB
release/woocommerce-payments/dist/tos.css 236 B
release/woocommerce-payments/dist/tos.js 21.7 kB
release/woocommerce-payments/dist/upe_checkout.css 444 B
release/woocommerce-payments/dist/upe_checkout.js 33.6 kB
release/woocommerce-payments/dist/upe_split_checkout.css 444 B
release/woocommerce-payments/dist/upe_split_checkout.js 34.1 kB
release/woocommerce-payments/dist/upe_with_deferred_intent_creation_checkout.js 31.9 kB
release/woocommerce-payments/dist/upe-blocks-checkout.css 1.4 kB
release/woocommerce-payments/dist/upe-blocks-checkout.js 39.1 kB
release/woocommerce-payments/dist/upe-split-blocks-checkout.css 1.41 kB
release/woocommerce-payments/dist/upe-split-blocks-checkout.js 39.7 kB
release/woocommerce-payments/dist/woopay-express-button.js 16.6 kB
release/woocommerce-payments/dist/woopay.css 4.06 kB
release/woocommerce-payments/dist/woopay.js 70.3 kB
release/woocommerce-payments/includes/subscriptions/assets/css/plugin-page.css 633 B
release/woocommerce-payments/includes/subscriptions/assets/js/plugin-page.js 720 B
release/woocommerce-payments/vendor/automattic/jetpack-assets/build/i18n-loader.js 2.43 kB
release/woocommerce-payments/vendor/automattic/jetpack-assets/src/js/i18n-loader.js 1.01 kB
release/woocommerce-payments/vendor/automattic/jetpack-connection/dist/tracks-ajax.js 522 B
release/woocommerce-payments/vendor/automattic/jetpack-connection/dist/tracks-callables.js 581 B
release/woocommerce-payments/vendor/automattic/jetpack-identity-crisis/babel.config.js 160 B
release/woocommerce-payments/vendor/automattic/jetpack-identity-crisis/build/index.css 2.32 kB
release/woocommerce-payments/vendor/automattic/jetpack-identity-crisis/build/index.js 13.8 kB
release/woocommerce-payments/vendor/automattic/jetpack-identity-crisis/build/index.rtl.css 2.32 kB
release/woocommerce-payments/vendor/woocommerce/subscriptions-core/assets/css/about.css 1.2 kB
release/woocommerce-payments/vendor/woocommerce/subscriptions-core/assets/css/admin-order-statuses.css 403 B
release/woocommerce-payments/vendor/woocommerce/subscriptions-core/assets/css/admin.css 3.56 kB
release/woocommerce-payments/vendor/woocommerce/subscriptions-core/assets/css/checkout.css 299 B
release/woocommerce-payments/vendor/woocommerce/subscriptions-core/assets/css/modal.css 742 B
release/woocommerce-payments/vendor/woocommerce/subscriptions-core/assets/css/view-subscription.css 572 B
release/woocommerce-payments/vendor/woocommerce/subscriptions-core/assets/css/wcs-upgrade.css 411 B
release/woocommerce-payments/vendor/woocommerce/subscriptions-core/assets/js/admin/admin-pointers.js 544 B
release/woocommerce-payments/vendor/woocommerce/subscriptions-core/assets/js/admin/admin.js 9.07 kB
release/woocommerce-payments/vendor/woocommerce/subscriptions-core/assets/js/admin/jstz.js 6.8 kB
release/woocommerce-payments/vendor/woocommerce/subscriptions-core/assets/js/admin/jstz.min.js 3.83 kB
release/woocommerce-payments/vendor/woocommerce/subscriptions-core/assets/js/admin/meta-boxes-coupon.js 544 B
release/woocommerce-payments/vendor/woocommerce/subscriptions-core/assets/js/admin/meta-boxes-subscription.js 2.38 kB
release/woocommerce-payments/vendor/woocommerce/subscriptions-core/assets/js/admin/moment.js 22.1 kB
release/woocommerce-payments/vendor/woocommerce/subscriptions-core/assets/js/admin/moment.min.js 11.6 kB
release/woocommerce-payments/vendor/woocommerce/subscriptions-core/assets/js/admin/payment-method-restrictions.js 1.29 kB
release/woocommerce-payments/vendor/woocommerce/subscriptions-core/assets/js/admin/wcs-meta-boxes-order.js 502 B
release/woocommerce-payments/vendor/woocommerce/subscriptions-core/assets/js/frontend/payment-methods.js 355 B
release/woocommerce-payments/vendor/woocommerce/subscriptions-core/assets/js/frontend/single-product.js 429 B
release/woocommerce-payments/vendor/woocommerce/subscriptions-core/assets/js/frontend/view-subscription.js 1.38 kB
release/woocommerce-payments/vendor/woocommerce/subscriptions-core/assets/js/frontend/wcs-cart.js 387 B
release/woocommerce-payments/vendor/woocommerce/subscriptions-core/assets/js/modal.js 1.1 kB
release/woocommerce-payments/vendor/woocommerce/subscriptions-core/assets/js/wcs-upgrade.js 1.27 kB
release/woocommerce-payments/vendor/woocommerce/subscriptions-core/build/index.css 392 B
release/woocommerce-payments/vendor/woocommerce/subscriptions-core/build/index.js 3.06 kB

compressed-size-action

@Jinksi Jinksi self-assigned this Jun 19, 2023
@Jinksi Jinksi changed the title Show only disputes due within 7 days in WC home task list. WC Home active disputes task: improve wording and reduce due_by threshold to align with Payments Overview task Jun 19, 2023
@brucealdridge
Copy link
Contributor

I needed to delete option woocommerce_task_list_hidden_lists as the WC task list wasn't showing.

@Jinksi
Copy link
Member

Jinksi commented Jun 22, 2023

Note: I've implemented cache invalidation for the active disputes cache in 167f5f8.

@@ -354,7 +354,7 @@ describe( 'getTasks()', () => {
completed: false,
level: 1,
title: 'Respond to a dispute for $10.00 – Last day',
content: 'Respond today by 11:59 PM',
content: 'Respond today by 6:59 PM', // shown in local timezone.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I had a look and couldn't find the local timezone set anywhere. This could cause failures if the timezone is different from the expected (EST ?).

Copy link
Member

@Jinksi Jinksi Jun 22, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice catch! I've explicitly set this to America/New_York for this test suite, reverting afterAll.

You can check this is working by setting the TZ to e.g. Australia/Brisbane, tests will then fail.

moment.tz.setDefault( 'America/New_York' );

Updated in 02cbd09.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I realise this will be impacted by daylight savings... fix incoming.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Set to UTC-5 (EST / non-daylight-savings) in caac016.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't be affected by daylight savings as the dates are consistent.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, yes, right!

I'm having flashbacks of all of the failing GH checks last time we changed to/from daylight savings. I'll just leave it in, at least it's explicit.


$this->assertEquals( 'Respond to a dispute for 20,00 € – Last day', $disputes_task->get_title() );
// "Respond today by <time> <AM|PM>"
$this->assertMatchesRegularExpression( '/Respond today by \d{1,2}:\d{2} (AM|PM)/', $disputes_task->get_additional_info() );
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would be nice if there was an easy way to mock the datetime in PHP, without third party libraries.

includes/admin/tasks/class-wc-payments-task-disputes.php Outdated Show resolved Hide resolved
Comment on lines +264 to +266
if ( ! $dispute['due_by'] ) {
continue;
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This shouldn't happen, but worth being defensive here.

includes/admin/tasks/class-wc-payments-task-disputes.php Outdated Show resolved Hide resolved
*/
private function get_disputes_awaiting_response_count() {
$disputes_status_counts = \WC_Payments::get_database_cache()->get( Database_Cache::DISPUTE_STATUS_COUNTS_KEY );
private function get_disputes_needing_response_within_days( $num_days ) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If this task is rendered, this function is called six times, four times with 7 days, two with 1 day. This isn't too much overhead as we will be using the database cache.

But as the code does the same filtering multiple times it might be a good idea to cache the seven and one day results on the class?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good idea, thanks!

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've implemented this in 4efceec (and docblock correction in b10377c).

I'm keen for feedback on this commit! Let me know what you think.

return sprintf(
/* translators: %s is time, eg: 11:59 PM */
__( 'Respond today by %s', 'woocommerce-payments' ),
$due_by_local_time->format( 'g:i A' )
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this should be formatted using the time_format option. Likely wrapped with wc_format_datetime

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, TIL!

I'm thinking that these formats on the Overview task will have to be changes to use the time_format/date_format options as well:

? sprintf(
__( 'Respond today by %s', 'woocommerce-payments' ),
// Show due_by time in local timezone: e.g. "11:59 PM".
dateI18n(
'g:i A',
moment.utc( dispute.due_by ).local().toISOString()
)
)
: sprintf(
__(
'By %s – %s left to respond',
'woocommerce-payments'
),
// Show due_by date in local timezone: e.g. "Jan 1, 2021".
dateI18n(
'M j, Y',
moment.utc( dispute.due_by ).local().toISOString()
),
moment( dispute.due_by ).fromNow( true ) // E.g. "2 days".
);

Copy link
Member

@Jinksi Jinksi Jun 22, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated in f4bb038. I'll look at incorporating the store's formatting for the Overview task as well.

I couldn't find a single case where the frontend date is formatted using the store's date formatting, so I'll leave it for now.

This will result in inconsistencies across the 2 dispute task items, but it won't impact our goal of highlighting disputes, so happy to leave it.

includes/admin/tasks/class-wc-payments-task-disputes.php Outdated Show resolved Hide resolved
includes/admin/tasks/class-wc-payments-task-disputes.php Outdated Show resolved Hide resolved
@Jinksi Jinksi requested a review from brucealdridge June 22, 2023 03:15
@Jinksi
Copy link
Member

Jinksi commented Jun 22, 2023

@brucealdridge I think I've addressed all of your suggestions. Thanks for the thorough review, some TIL's in there for me.

Marking as ready for re-review 🚀

@brucealdridge brucealdridge added this pull request to the merge queue Jun 23, 2023
Merged via the queue into develop with commit def5c52 Jun 23, 2023
@brucealdridge brucealdridge deleted the update/6505-dispute-task-wc-home branch June 23, 2023 02:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Use same notice wording in WC home "Things to do next" disputes task list item
4 participants