diff --git a/changelog.txt b/changelog.txt index d6ecbad8a2c..148a96e8062 100644 --- a/changelog.txt +++ b/changelog.txt @@ -1,5 +1,8 @@ *** WooPayments Changelog *** += 8.7.1 - 2025-01-14 = +* Fix - Broaden billing field queries from form-scoped to document-scoped + = 8.7.0 - 2024-12-25 = * Add - Add seller_message to failed order notes * Add - Add WooPay Klaviyo newsletter integration. diff --git a/changelog/add-2253-clickwrap-terms-and-conditions-2 b/changelog/add-2253-clickwrap-terms-and-conditions-2 new file mode 100644 index 00000000000..2a796e9a2e4 --- /dev/null +++ b/changelog/add-2253-clickwrap-terms-and-conditions-2 @@ -0,0 +1,4 @@ +Significance: minor +Type: add + +Falback terms and conditions for WooPay diff --git a/changelog/as-fix-min-height-woopay-button b/changelog/as-fix-min-height-woopay-button new file mode 100644 index 00000000000..ff43c088aef --- /dev/null +++ b/changelog/as-fix-min-height-woopay-button @@ -0,0 +1,4 @@ +Significance: minor +Type: fix + +Set a default minimum height to the WooPay button. diff --git a/changelog/dev-10071-convert-shopper-pay-for-order-e2e-spec b/changelog/dev-10071-convert-shopper-pay-for-order-e2e-spec new file mode 100644 index 00000000000..b6a0d24707a --- /dev/null +++ b/changelog/dev-10071-convert-shopper-pay-for-order-e2e-spec @@ -0,0 +1,4 @@ +Significance: patch +Type: dev + +Add the Playwright Pay for Order spec and remove the equivalent Puppeteer spec. diff --git a/changelog/dev-5961-remove-unused-get-transaction-endpoint b/changelog/dev-5961-remove-unused-get-transaction-endpoint new file mode 100644 index 00000000000..a6a4b299cbc --- /dev/null +++ b/changelog/dev-5961-remove-unused-get-transaction-endpoint @@ -0,0 +1,4 @@ +Significance: patch +Type: dev + +Removed unused get single transaction endpoint diff --git a/changelog/fix-8549-phpcs-errors-woocommerce-commenting b/changelog/fix-8549-phpcs-errors-woocommerce-commenting new file mode 100644 index 00000000000..051d08959ea --- /dev/null +++ b/changelog/fix-8549-phpcs-errors-woocommerce-commenting @@ -0,0 +1,5 @@ +Significance: patch +Type: dev +Comment: Not user-facing: fix WC Commenting phpcs errors in misc files + + diff --git a/changelog/fix-scope-out-billing-fields-selectors b/changelog/fix-scope-out-billing-fields-selectors new file mode 100644 index 00000000000..2d064e70aab --- /dev/null +++ b/changelog/fix-scope-out-billing-fields-selectors @@ -0,0 +1,4 @@ +Significance: minor +Type: fix + +Broaden billing field queries from form-scoped to document-scoped diff --git a/changelog/update-9971-simplify-localization-csv-export b/changelog/update-9971-simplify-localization-csv-export new file mode 100644 index 00000000000..f7384ad3968 --- /dev/null +++ b/changelog/update-9971-simplify-localization-csv-export @@ -0,0 +1,4 @@ +Significance: minor +Type: update + +Simplify localization of CSV exports to use user language settings from WP Admin, allowing the CSV export to match the localization of the data presented in the admin UI. diff --git a/client/checkout/classic/event-handlers.js b/client/checkout/classic/event-handlers.js index 2ad729113f0..4ed1912250f 100644 --- a/client/checkout/classic/event-handlers.js +++ b/client/checkout/classic/event-handlers.js @@ -76,7 +76,7 @@ jQuery( function ( $ ) { } ); $checkoutForm.on( generateCheckoutEventNames(), function () { - if ( isBillingInformationMissing( this ) ) { + if ( isBillingInformationMissing() ) { return; } diff --git a/client/checkout/utils/test/upe.test.js b/client/checkout/utils/test/upe.test.js index 91ad592d5cf..de5a870acc2 100644 --- a/client/checkout/utils/test/upe.test.js +++ b/client/checkout/utils/test/upe.test.js @@ -36,6 +36,7 @@ function buildForm( fields ) { input.value = field.value; form.appendChild( input ); } ); + document.body.appendChild( form ); return form; } @@ -57,6 +58,11 @@ describe( 'UPE checkout utils', () => { } ); beforeEach( () => { + const existingCheckoutForm = document.querySelector( 'form' ); + if ( existingCheckoutForm ) { + existingCheckoutForm.remove(); + } + getUPEConfig.mockImplementation( ( argument ) => { if ( argument === 'enabledBillingFields' ) { return { @@ -99,7 +105,7 @@ describe( 'UPE checkout utils', () => { } ); it( 'should return false when the billing information is not missing', () => { - const form = buildForm( [ + buildForm( [ { id: 'billing_first_name', value: 'Test' }, { id: 'billing_last_name', value: 'User' }, { id: 'billing_email', value: 'test@example.com' }, @@ -108,11 +114,11 @@ describe( 'UPE checkout utils', () => { { id: 'billing_city', value: 'Anytown' }, { id: 'billing_postcode', value: '12345' }, ] ); - expect( isBillingInformationMissing( form ) ).toBe( false ); + expect( isBillingInformationMissing() ).toBe( false ); } ); it( 'should return true when the billing information is missing', () => { - const form = buildForm( [ + buildForm( [ { id: 'billing_first_name', value: 'Test' }, { id: 'billing_last_name', value: 'User' }, { id: 'billing_email', value: 'test@example.com' }, @@ -121,11 +127,11 @@ describe( 'UPE checkout utils', () => { { id: 'billing_city', value: 'Anytown' }, { id: 'billing_postcode', value: '' }, ] ); - expect( isBillingInformationMissing( form ) ).toBe( true ); + expect( isBillingInformationMissing() ).toBe( true ); } ); it( 'should use the defaults when there is no specific locale data for a country', () => { - const form = buildForm( [ + buildForm( [ { id: 'billing_first_name', value: 'Test' }, { id: 'billing_last_name', value: 'User' }, { id: 'billing_email', value: 'test@example.com' }, @@ -134,11 +140,11 @@ describe( 'UPE checkout utils', () => { { id: 'billing_city', value: 'Anytown' }, { id: 'billing_postcode', value: '' }, ] ); - expect( isBillingInformationMissing( form ) ).toBe( true ); + expect( isBillingInformationMissing() ).toBe( true ); } ); it( 'should return false when the locale data for a country has no required fields', () => { - const form = buildForm( [ + buildForm( [ { id: 'billing_first_name', value: 'Test' }, { id: 'billing_last_name', value: 'User' }, { id: 'billing_email', value: 'test@example.com' }, @@ -147,7 +153,7 @@ describe( 'UPE checkout utils', () => { { id: 'billing_city', value: 'Anytown' }, { id: 'billing_postcode', value: '' }, ] ); - expect( isBillingInformationMissing( form ) ).toBe( true ); + expect( isBillingInformationMissing() ).toBe( true ); } ); } ); diff --git a/client/checkout/utils/upe.js b/client/checkout/utils/upe.js index c8201ff1ba1..61bcfb71334 100644 --- a/client/checkout/utils/upe.js +++ b/client/checkout/utils/upe.js @@ -404,17 +404,18 @@ function getParsedLocale() { } } -export const isBillingInformationMissing = ( form ) => { +export const isBillingInformationMissing = () => { const enabledBillingFields = getUPEConfig( 'enabledBillingFields' ); // first name and last name are kinda special - we just need one of them to be at checkout const name = `${ - form.querySelector( + document.querySelector( `#${ SHORTCODE_BILLING_ADDRESS_FIELDS.first_name }` )?.value || '' } ${ - form.querySelector( `#${ SHORTCODE_BILLING_ADDRESS_FIELDS.last_name }` ) - ?.value || '' + document.querySelector( + `#${ SHORTCODE_BILLING_ADDRESS_FIELDS.last_name }` + )?.value || '' }`.trim(); if ( ! name && @@ -435,14 +436,15 @@ export const isBillingInformationMissing = ( form ) => { const country = billingFieldsToValidate.includes( SHORTCODE_BILLING_ADDRESS_FIELDS.country ) - ? form.querySelector( `#${ SHORTCODE_BILLING_ADDRESS_FIELDS.country }` ) - ?.value + ? document.querySelector( + `#${ SHORTCODE_BILLING_ADDRESS_FIELDS.country }` + )?.value : null; // We need to just find one field with missing information. If even only one is missing, just return early. return Boolean( billingFieldsToValidate.find( ( fieldName ) => { - const field = form.querySelector( `#${ fieldName }` ); + const field = document.querySelector( `#${ fieldName }` ); let isRequired = enabledBillingFields[ fieldName ]?.required; const locale = getParsedLocale(); diff --git a/client/checkout/woopay/style.scss b/client/checkout/woopay/style.scss index 349ebb18f7f..587f4fcf405 100644 --- a/client/checkout/woopay/style.scss +++ b/client/checkout/woopay/style.scss @@ -142,6 +142,7 @@ white-space: nowrap; text-transform: none; list-style-type: none; + min-height: auto; &:not( :disabled ):hover { background: #e0e0e0 !important; diff --git a/client/components/csv-export-modal/index.tsx b/client/components/csv-export-modal/index.tsx deleted file mode 100644 index 2cddf0908ab..00000000000 --- a/client/components/csv-export-modal/index.tsx +++ /dev/null @@ -1,227 +0,0 @@ -/** @format */ -/** - * External dependencies - */ -import React, { useState } from 'react'; -import { __ } from '@wordpress/i18n'; -import { - Button, - SelectControl, - CheckboxControl, - ExternalLink, -} from '@wordpress/components'; -import interpolateComponents from '@automattic/interpolate-components'; -import { useDispatch } from '@wordpress/data'; -import DomainsIcon from 'gridicons/dist/domains'; - -/** - * Internal dependencies - */ -import { ReportingExportLanguageHook } from 'wcpay/settings/reporting-settings/interfaces'; -import { useReportingExportLanguage, useSettings } from 'wcpay/data'; -import ConfirmationModal from 'wcpay/components/confirmation-modal'; -import { getAdminUrl, getExportLanguageOptions } from 'wcpay/utils'; -import './styles.scss'; - -interface CSVExportModalProps { - totalItems: number; - exportType: 'transactions' | 'deposits' | 'disputes'; - onClose: () => void; - onSubmit: ( language: string ) => void; -} - -interface SettingsHook { - isSaving: boolean; - isLoading: boolean; - saveSettings: () => void; -} - -const CVSExportModal: React.FunctionComponent< CSVExportModalProps > = ( { - totalItems, - exportType, - onClose, - onSubmit, -} ) => { - const { updateOptions } = useDispatch( 'wc/admin/options' ); - const { saveSettings } = useSettings() as SettingsHook; - - const [ - exportLanguage, - updateExportLanguage, - ] = useReportingExportLanguage() as ReportingExportLanguageHook; - - const [ modalLanguage, setModalLanguage ] = useState( exportLanguage ); - const [ modalRemember, setModalRemember ] = useState( true ); - - const onDownload = async () => { - onSubmit( modalLanguage ); - - // If the Remember checkbox is checked, dismiss the modal. - if ( modalRemember ) { - await updateOptions( { - wcpay_reporting_export_modal_dismissed: modalRemember, - } ); - - updateExportLanguage( modalLanguage ); - saveSettings(); - - wcpaySettings.reporting.exportModalDismissed = true; - } - }; - - const buttonContent = ( - <> - - - - ); - - const getModalTitle = ( type: string ): string => { - switch ( type ) { - case 'transactions': - return __( - 'Export transactions report', - 'woocommerce-payments' - ); - case 'deposits': - return __( 'Export deposits report', 'woocommerce-payments' ); - case 'disputes': - return __( 'Export disputes report', 'woocommerce-payments' ); - default: - return __( 'Export report', 'woocommerce-payments' ); - } - }; - - const getExportNumberText = ( type: string ): string => { - switch ( type ) { - case 'transactions': - return __( - 'Exporting {{total/}} transactions…', - 'woocommerce-payments' - ); - case 'deposits': - return __( - 'Exporting {{total/}} deposits…', - 'woocommerce-payments' - ); - case 'disputes': - return __( - 'Exporting {{total/}} disputes…', - 'woocommerce-payments' - ); - default: - return __( - 'Exporting {{total/}} rows…', - 'woocommerce-payments' - ); - } - }; - - const getExportLabel = ( type: string ): string => { - switch ( type ) { - case 'transactions': - return __( - 'Export transactions report in', - 'woocommerce-payments' - ); - case 'deposits': - return __( - 'Export deposits report in', - 'woocommerce-payments' - ); - case 'disputes': - return __( - 'Export disputes report in', - 'woocommerce-payments' - ); - default: - return __( 'Export report in', 'woocommerce-payments' ); - } - }; - - const handleExportLanguageChange = ( language: string ) => { - setModalLanguage( language ); - }; - - const handleExportLanguageRememberChange = ( value: boolean ) => { - setModalRemember( value ); - }; - - return ( - { - return false; - } } - > -
- { interpolateComponents( { - mixedString: getExportNumberText( exportType ), - components: { - total: { totalItems }, - }, - } ) } -
- -
-

Settings

- -
-
- - - { getExportLabel( exportType ) } - -
-
- -
-
- -
- - ), - }, - } ) } - checked={ modalRemember } - onChange={ handleExportLanguageRememberChange } - data-testid="export-modal-remember" - /> -
-
-
- ); -}; - -export default CVSExportModal; diff --git a/client/components/csv-export-modal/styles.scss b/client/components/csv-export-modal/styles.scss deleted file mode 100644 index 600a6d2a18a..00000000000 --- a/client/components/csv-export-modal/styles.scss +++ /dev/null @@ -1,51 +0,0 @@ -.reporting-export-modal { - .components-modal__header { - border-bottom: 1px solid #dcdcde !important; - } - - .wcpay-confirmation-modal__footer { - .is-secondary { - box-shadow: none; - } - } - - &__items-number { - border-bottom: 1px solid #dcdcde; - padding: 15px 0; - } - - &__settings { - @include breakpoint( '>660px' ) { - min-width: 500px; - } - - &--language { - display: flex; - flex-wrap: wrap; - } - - &--language-label { - flex: 1 1 200px; - display: flex; - - .domains-icon { - width: 16px; - margin: 7px 0; - } - - .export-label { - padding: 10px 0 0 8px; - } - } - - &--language-select { - flex: 1 1 200px; - } - - &--remember { - p { - padding-top: 0 !important; - } - } - } -} diff --git a/client/components/csv-export-modal/test/__snapshots__/index.test.tsx.snap b/client/components/csv-export-modal/test/__snapshots__/index.test.tsx.snap deleted file mode 100644 index 251b5f8438f..00000000000 --- a/client/components/csv-export-modal/test/__snapshots__/index.test.tsx.snap +++ /dev/null @@ -1,7 +0,0 @@ -// Jest Snapshot v1, https://goo.gl/fbAQLP - -exports[`RefundModal it renders correctly 1`] = ` -