Skip to content

Conversation

@rjchow
Copy link
Contributor

@rjchow rjchow commented Apr 20, 2022

All Submissions:

Changes proposed in this Pull Request:

This PR makes a set of changes in order to implement the feature for a payment gateways banner.

There were two possible approaches to implement this - fully in PHP and the other to embed a React tree on a new element that is introduced on the PHP side.

The decision was made to embed a React tree for ease of future maintenance, and also to make the new mount point an experimental Slotfill so that we can add future items to it.

Explat post: pbxNRc-1yD-p2

Closes #32414 .

Control:

image

Treatment:

image

How to test the changes in this Pull Request:

There are 5 scenarios to test:

  • WCPay eligible and WCPay installed and setup completed and assigned to 'treatment' -> Should not see the banner
  • WCPay eligible and WCPay not installed -> Should not see the banner
  • WCPay eligible and WCPay installed but setup incomplete and assigned to 'treatment' -> Should see the banner
  • WCPay eligible and WCPay installed but setup incomplete and assigned to 'control' -> Should not see the banner
  • WCPay ineligible and/or WCPay not installed -> Should not see the banner
  1. Set up a fresh install of Wordpress with WooCommerce, and depending on the scenario you are testing, install WooCommerce Payments plugin (either as part of onboarding or otherwise)
  2. Install and activate wc-test-helper plugin
  3. Navigate to Tools -> WCA Test Helper
  4. Click Experiments
  5. Toggle the experiment assignment for 'woocommerce_payments_settings_banner_2022_04' to control or treatment depending on the scenario
  6. Visit WooCommerce > Settings, Payments tab, and check if the banner is visible or not

Other information:

  • Have you added an explanation of what your changes do and why you'd like us to include them?
  • Have you written new tests for your changes, as applicable?
  • Have you successfully run tests with your changes locally?
  • Have you created a changelog file by running pnpm nx affected --target=changelog?

FOR PR REVIEWER ONLY:

  • I have reviewed that everything is sanitized/escaped appropriately for any SQL or XSS injection possibilities. I made sure Linting is not ignored or disabled.

@github-actions github-actions bot added focus: react admin package: @woocommerce/data issues related to @woocommerce/data plugin: woocommerce Issues related to the WooCommerce Core plugin. labels Apr 20, 2022
@rjchow rjchow marked this pull request as ready for review April 21, 2022 02:59
@rjchow rjchow force-pushed the add/wc-payment-gateways-banner branch from cd644f3 to bbb1af4 Compare April 21, 2022 03:30
@github-actions github-actions bot added the package: @woocommerce/admin-e2e-tests issues related to @woocommerce/admin-e2e-tests label Apr 21, 2022
@github-actions github-actions bot removed the package: @woocommerce/admin-e2e-tests issues related to @woocommerce/admin-e2e-tests label Apr 21, 2022
@rjchow rjchow force-pushed the add/wc-payment-gateways-banner branch from 38059c9 to 6151f40 Compare April 21, 2022 06:09

const WcPayBanner = () => {
const WC_PAY_SETUP_URL =
'./admin.php?page=wc-settings&tab=checkout&section=woocommerce_payments';
Copy link
Member

Choose a reason for hiding this comment

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

I think we could use getAdminLink here:

href: getAdminLink(
'post-new.php?post_type=product&wc_onboarding_active_task=products&tutorial=true'
),

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Hmm... that's new to me... however I can't actually find the source for @woocommerce/settings and the only mention I've seen of it is in the changelog where it says its been removed

How does this work? 👀👀👀

Copy link
Member

Choose a reason for hiding this comment

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

Hmm...I think it's still injected into our code via the Dependency Extraction Webpack Plugin, though I also don't know how it exactly works.

Copy link
Contributor

Choose a reason for hiding this comment

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

however I can't actually find the source for @woocommerce/settings and the only mention I've seen of it is in the changelog where it says its been removed

The settings package used to be under WCAdmin, but now lives in blocks https://github.com/woocommerce/woocommerce-gutenberg-products-block/tree/trunk/assets/js/settings/shared

P2: p90Yrv-2B5-p2

Copy link
Member

Choose a reason for hiding this comment

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

Changed in 3ee2fca

Discover,
JCB,
UnionPay,
} from './cards';
Copy link
Member

Choose a reason for hiding this comment

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

Nice work for refactoring this!

};
} );

const supportsWCPayments =
Copy link
Member

Choose a reason for hiding this comment

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

Looks like payment-recommendations.tsx also has the same code. How about creating a util function for this?

const supportsWCPayments =
paymentGatewaySuggestions &&
paymentGatewaySuggestions.filter(
( paymentGatewaySuggestion: Plugin ) => {
return (
paymentGatewaySuggestion.id.indexOf(
'woocommerce_payments'
) === 0
);
}
).length === 1;

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yea good call! I was planning to extract the entire hook and everything but ended up realising I only needed a small part of the useSelect and forgot that there was this part below that's duplicated

Copy link
Member

Choose a reason for hiding this comment

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

Updated in 11f321a

Copy link
Member

@chihsuan chihsuan left a comment

Choose a reason for hiding this comment

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

Tested well on my local for all scenarios. 👍 Just left some suggestions.

Copy link
Contributor

@ilyasfoo ilyasfoo left a comment

Choose a reason for hiding this comment

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

Tested well for me. Great work, @rjchow! The only thing left I think is to finalize the experiment name if we intend to do it dynamically.

);

const [ isLoadingExperiment, experimentAssignment ] = useExperiment(
'woocommerce_payments_settings_banner_2022_04'
Copy link
Contributor

Choose a reason for hiding this comment

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

I think this is meant to be a dynamic experiment? If so, we should use dynamic month & year

Copy link
Contributor

Choose a reason for hiding this comment

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

Done in 2398fdf

@ilyasfoo
Copy link
Contributor

I'll be working on my own feedback soon. @chihsuan, would you like to address your feedback as well or would you think it's better to address it as a follow-up?

@chihsuan
Copy link
Member

I'll be working on my own feedback soon. @chihsuan, would you like to address your feedback as well or would you think it's better to address it as a follow-up?

@ilyasfoo Thanks for the ping. Since those are just small changes, I'll address my feedback today!

@adrianduffell
Copy link
Contributor

@ilyasfoo I think we need to dismiss your review to merge? 🤔

ilyasfoo
ilyasfoo previously approved these changes Apr 28, 2022
@ilyasfoo
Copy link
Contributor

The "Payments Methods" header flash of text looks a bit janky to me, and I have concerns that removing the header makes it inconsistent with the other tabs. However we could follow-up on that in another PR after getting design feedback about it.

Sounds good!

@ilyasfoo I think we need to dismiss your review to merge? 🤔

Oops sorry missed this, I've approved it instead!

@ilyasfoo
Copy link
Contributor

@adrianduffell do you think we should attempt to merge from trunk to see if it fixes checks? Or should we just merge it anyway?

@adrianduffell
Copy link
Contributor

adrianduffell commented Apr 28, 2022

do you think we should attempt to merge from trunk to see if it fixes checks?

@ilyasfoo Ah yep, I think we should run the checks. I'll push a commit with the merge from trunk.

@adrianduffell
Copy link
Contributor

Looks like the e2e tests are failing on the payments settings screen. I'll take a closer look tomorrow.

@ilyasfoo
Copy link
Contributor

@adrianduffell I think that may be related to the "Payment Methods" header missing. I'll take a look instead, I suspect changing it to detect its table is better as RJ suggested

@ilyasfoo ilyasfoo dismissed stale reviews from adrianduffell and themself via d947699 April 29, 2022 01:09
@github-actions github-actions bot added the package: @woocommerce/admin-e2e-tests issues related to @woocommerce/admin-e2e-tests label Apr 29, 2022
@ilyasfoo
Copy link
Contributor

I think I've fixed e2e with d947699, but it seems some checks are failing due to unrelated errors. I'm not sure yet what it is, but it may have come with merge from trunk.

@ilyasfoo ilyasfoo self-requested a review April 29, 2022 02:56
@ilyasfoo ilyasfoo self-requested a review April 29, 2022 02:57
@ilyasfoo
Copy link
Contributor

Checks are successful now, merging

@ilyasfoo ilyasfoo merged commit 8b9870b into trunk Apr 29, 2022
@ilyasfoo ilyasfoo deleted the add/wc-payment-gateways-banner branch April 29, 2022 02:58
@github-actions github-actions bot added this to the 6.6.0 milestone Apr 29, 2022
@github-actions
Copy link
Contributor

github-actions bot commented Apr 29, 2022

Hi @ilyasfoo, thanks for merging this pull request. Please take a look at these follow-up tasks you may need to perform:

  • Add the release: add testing instructions label

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

package: @woocommerce/admin-e2e-tests issues related to @woocommerce/admin-e2e-tests package: @woocommerce/data issues related to @woocommerce/data plugin: woocommerce Issues related to the WooCommerce Core plugin. release: add testing instructions PRs that have not had testing instructions added to the wiki. [auto]

Projects

None yet

Development

Successfully merging this pull request may close these issues.

A/B Test for Banner in Payment Settings

5 participants