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

Update international IP address rule card behavior when the rule is being affected by another configuration #7827

Merged

Conversation

allie500
Copy link
Contributor

@allie500 allie500 commented Dec 4, 2023

Fixes #6320

Changes proposed in this Pull Request

This PR modifies the behavior and display of the international IP address rule card if the rule is being affected by the WooCommerce core selling locations general option. Previously, if the WooCommerce core selling locations option was set to 'sell to all countries' we'd show a notice at the bottom of the card but still display the toggle to enable the rule as shown in the screenshot below:

275852485-4e80f817-04e9-415a-ab7a-4baa484daf8f

The changes in this PR have updated the rule card display to not show the rule toggle and instead show the notice in the toggle's place with updated text indicating that filter is disabled because the WooCommerce core selling locations option is set to 'sell to all countries'. See the screenshot below:

Screenshot on 2023-12-04 at 11_35_30

The behavior and display of the rule card has not been changed if the the WooCommerce core selling locations option is set to the 'specific countries' or 'all countries except' options.

Testing instructions

  • Check out this branch.
  • All tests should pass.
  • Go to WooCommerce > Settings
  • Select 'Sell to all countries' in the Selling location(s) dropdown.
  • Save.
  • Go to Payments > Settings
  • Scroll down to the fraud protection section, click advanced, then click configure.
  • Scroll down to the International IP Address card and confirm that it looks like the second screenshot above.
  • Next, bring up your Jurassic Tube tunnel and confirm that the card looks okay on mobile.
  • Go back to WooCommerce > Settings
  • Select 'Sell to specific countries' in the Selling location(s) dropdown.
  • Add a country or two to the 'Sell to specific countries' field if needed.
  • Save.
  • Scroll down to the fraud protection section, click advanced, then click configure.
  • Scroll down to the International IP Address card and confirm that the toggle is present and that you have an info notice stating that orders from outside your specific countries will be blocked by the filter.
  • Go back to WooCommerce > Settings
  • Select 'Sell to all countries, except for...' in the Selling location(s) dropdown.
  • Add a country or two to the 'Sell to all countries, except for...' field if needed.
  • Save.
  • Scroll down to the fraud protection section, click advanced, then click configure.
  • Scroll down to the International IP Address card and confirm that the toggle is present and that you have an info notice stating that orders from the following countries will be blocked by the filter.

  • 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 Dec 4, 2023

Test the build

Option 1. Jetpack Beta

  • Install and activate Jetpack Beta.
  • Use this build by searching for PR number 7827 or branch name update/6320-rule-card-behavior-if-affected-by-other-config 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: 9228baf
  • Build time: 2023-12-07 14:23:17 UTC

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

Copy link
Contributor

github-actions bot commented Dec 4, 2023

Size Change: +10 B (0%)

Total Size: 1.27 MB

Filename Size Change
release/woocommerce-payments/dist/index.js 287 kB +10 B (0%)
ℹ️ View Unchanged
Filename Size
release/woocommerce-payments/assets/css/admin.css 1.06 kB
release/woocommerce-payments/assets/css/success.css 158 B
release/woocommerce-payments/dist/blocks-checkout-rtl.css 1.8 kB
release/woocommerce-payments/dist/blocks-checkout.css 1.8 kB
release/woocommerce-payments/dist/blocks-checkout.js 85.6 kB
release/woocommerce-payments/dist/checkout-rtl.css 318 B
release/woocommerce-payments/dist/checkout.css 319 B
release/woocommerce-payments/dist/checkout.js 37.3 kB
release/woocommerce-payments/dist/index-rtl.css 36.8 kB
release/woocommerce-payments/dist/index.css 36.8 kB
release/woocommerce-payments/dist/multi-currency-analytics.js 1.05 kB
release/woocommerce-payments/dist/multi-currency-rtl.css 3.4 kB
release/woocommerce-payments/dist/multi-currency-switcher-block.js 60.5 kB
release/woocommerce-payments/dist/multi-currency.css 3.4 kB
release/woocommerce-payments/dist/multi-currency.js 55.7 kB
release/woocommerce-payments/dist/order-rtl.css 676 B
release/woocommerce-payments/dist/order.css 679 B
release/woocommerce-payments/dist/order.js 41.7 kB
release/woocommerce-payments/dist/payment-gateways-rtl.css 1.31 kB
release/woocommerce-payments/dist/payment-gateways.css 1.31 kB
release/woocommerce-payments/dist/payment-gateways.js 39.3 kB
release/woocommerce-payments/dist/payment-request-rtl.css 153 B
release/woocommerce-payments/dist/payment-request.css 153 B
release/woocommerce-payments/dist/payment-request.js 13.7 kB
release/woocommerce-payments/dist/product-details.js 919 B
release/woocommerce-payments/dist/settings-rtl.css 10.5 kB
release/woocommerce-payments/dist/settings.css 10.5 kB
release/woocommerce-payments/dist/settings.js 234 kB
release/woocommerce-payments/dist/subscription-edit-page.js 669 B
release/woocommerce-payments/dist/subscription-product-onboarding-modal-rtl.css 519 B
release/woocommerce-payments/dist/subscription-product-onboarding-modal.css 519 B
release/woocommerce-payments/dist/subscription-product-onboarding-modal.js 20.4 kB
release/woocommerce-payments/dist/subscription-product-onboarding-toast.js 710 B
release/woocommerce-payments/dist/subscriptions-empty-state-rtl.css 117 B
release/woocommerce-payments/dist/subscriptions-empty-state.css 117 B
release/woocommerce-payments/dist/subscriptions-empty-state.js 19.5 kB
release/woocommerce-payments/dist/tos-rtl.css 230 B
release/woocommerce-payments/dist/tos.css 231 B
release/woocommerce-payments/dist/tos.js 22 kB
release/woocommerce-payments/dist/woopay-express-button-rtl.css 153 B
release/woocommerce-payments/dist/woopay-express-button.css 153 B
release/woocommerce-payments/dist/woopay-express-button.js 52.7 kB
release/woocommerce-payments/dist/woopay-rtl.css 4.18 kB
release/woocommerce-payments/dist/woopay.css 4.19 kB
release/woocommerce-payments/dist/woopay.js 71.8 kB
release/woocommerce-payments/includes/subscriptions/assets/css/plugin-page.css 622 B
release/woocommerce-payments/includes/subscriptions/assets/js/plugin-page.js 812 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.03 kB
release/woocommerce-payments/vendor/woocommerce/subscriptions-core/assets/css/admin-empty-state.css 291 B
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.6 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.4 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 781 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.05 kB

compressed-size-action

@allie500 allie500 self-assigned this Dec 4, 2023
@allie500 allie500 marked this pull request as ready for review December 4, 2023 21:02
@allie500 allie500 requested a review from a team December 4, 2023 21:02
Copy link
Contributor

@jessepearson jessepearson left a comment

Choose a reason for hiding this comment

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

I had a question about a variable declaration that was done. I tested and it works either way, so it's not a necessary change if it's better for clarity.

There's the issue of the country names with extended ascii characters not displaying correctly. Do you think you can fix that in this PR without much hassle, or do you think it needs another issue and separate PR?

Screenshot 2023-12-05 at 11 22 27 AM

@allie500
Copy link
Contributor Author

allie500 commented Dec 5, 2023

There's the issue of the country names with extended ascii characters not displaying correctly. Do you think you can fix that in this PR without much hassle, or do you think it needs another issue and separate PR?

Screenshot 2023-12-05 at 11 22 27 AM

Thanks for catching this! I looked in to this and it needs to be fixed in Woo core. In the WooPayments code we are getting the countries from wcSettings.countries.

...
return (
		<FraudProtectionRuleCardNotice type={ 'info' }>
			{ getNoticeText( supportedCountriesType, isBlocking ) }
			<strong>
				{ settingCountries
					.map(
						( countryCode ) =>
							wcSettings.countries[ countryCode ] ?? false
					)
					.filter( ( element ) => element )
					.join( ', ' ) }
			</strong>
		</FraudProtectionRuleCardNotice>
	);
...

If you run wcSettings.countries['ST'] in the browser console, you get the following value returned:
'S&atilde;o Tom&eacute; and Pr&iacute;ncipe'

That is hardcoded in the core countries file:
https://github.com/woocommerce/woocommerce/blob/trunk/plugins/woocommerce/i18n/countries.php#L208

I can open an issue in core to track this.

@allie500
Copy link
Contributor Author

allie500 commented Dec 5, 2023

If you run wcSettings.countries['ST'] in the browser console, you get the following value returned: 'S&atilde;o Tom&eacute; and Pr&iacute;ncipe'

That is hardcoded in the core countries file: https://github.com/woocommerce/woocommerce/blob/trunk/plugins/woocommerce/i18n/countries.php#L208

I can open an issue in core to track this.

Actually, it does look like something on our end as core does properly decode the entities on their end. I'll open a separate issue for it in this repo.

Copy link
Contributor

@jessepearson jessepearson left a comment

Choose a reason for hiding this comment

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

Thanks for updating the variable declaration and opening the issue related to the country display. This is good to go 😁

@allie500 allie500 added this pull request to the merge queue Dec 6, 2023
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to failed status checks Dec 6, 2023
@allie500 allie500 merged commit 2338bb0 into develop Dec 7, 2023
23 of 28 checks passed
@allie500 allie500 deleted the update/6320-rule-card-behavior-if-affected-by-other-config branch December 7, 2023 21:26
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.

Update rule card behavior when the rule is being affected by another configuration
3 participants