From c285d7b08a3a0acc01cfa9e3ba989ccd0652a49a Mon Sep 17 00:00:00 2001 From: Zvonimir Maglica Date: Mon, 13 Jan 2025 13:37:31 +0100 Subject: [PATCH 01/81] Remove unused get transaction endpoint (#10131) --- ...961-remove-unused-get-transaction-endpoint | 4 ++++ ...-rest-payments-transactions-controller.php | 19 ------------------- 2 files changed, 4 insertions(+), 19 deletions(-) create mode 100644 changelog/dev-5961-remove-unused-get-transaction-endpoint 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/includes/admin/class-wc-rest-payments-transactions-controller.php b/includes/admin/class-wc-rest-payments-transactions-controller.php index 32f668dac94..9e7c10b76a4 100644 --- a/includes/admin/class-wc-rest-payments-transactions-controller.php +++ b/includes/admin/class-wc-rest-payments-transactions-controller.php @@ -98,15 +98,6 @@ public function register_routes() { 'permission_callback' => [ $this, 'check_permission' ], ] ); - register_rest_route( - $this->namespace, - '/' . $this->rest_base . '/(?P\w+)', - [ - 'methods' => WP_REST_Server::READABLE, - 'callback' => [ $this, 'get_transaction' ], - 'permission_callback' => [ $this, 'check_permission' ], - ] - ); } /** @@ -179,16 +170,6 @@ public function get_transactions_export( $request ) { return $this->forward_request( 'get_transactions_export', [ $filters, $user_email, $deposit_id, $locale ] ); } - /** - * Retrieve transaction to respond with via API. - * - * @param WP_REST_Request $request Full data about the request. - */ - public function get_transaction( $request ) { - $transaction_id = $request->get_param( 'transaction_id' ); - return $this->forward_request( 'get_transactions', [ 'transaction_id' ] ); - } - /** * Retrieve transactions summary to respond with via API. * From 53a30f64032c0dcffff041894054500e3646d88c Mon Sep 17 00:00:00 2001 From: Alfredo Sumaran Date: Mon, 13 Jan 2025 13:27:55 -0500 Subject: [PATCH 02/81] Set a default minimum height to the WooPay button. (#10132) --- changelog/as-fix-min-height-woopay-button | 4 ++++ client/checkout/woopay/style.scss | 1 + 2 files changed, 5 insertions(+) create mode 100644 changelog/as-fix-min-height-woopay-button 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/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; From 5ba021bbe15fbcade816bfb5d836caa7d47279ef Mon Sep 17 00:00:00 2001 From: Eric Jinks <3147296+Jinksi@users.noreply.github.com> Date: Tue, 14 Jan 2025 15:36:18 +1000 Subject: [PATCH 03/81] Fix WooCommerce hook comment phpcs errors in misc files (#10126) Co-authored-by: Shendy <73803630+shendy-a8c@users.noreply.github.com> --- ...x-8549-phpcs-errors-woocommerce-commenting | 5 +++ includes/admin/class-wc-payments-admin.php | 10 ++++++ templates/emails/customer-ipp-receipt.php | 32 +++++++++++++++---- .../emails/plain/customer-ipp-receipt.php | 24 ++++++++++++-- ...s-wc-payments-admin-sections-overwrite.php | 2 +- 5 files changed, 63 insertions(+), 10 deletions(-) create mode 100644 changelog/fix-8549-phpcs-errors-woocommerce-commenting 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/includes/admin/class-wc-payments-admin.php b/includes/admin/class-wc-payments-admin.php index 92010e4c302..f64df12c2b5 100644 --- a/includes/admin/class-wc-payments-admin.php +++ b/includes/admin/class-wc-payments-admin.php @@ -987,6 +987,11 @@ private function get_js_settings(): array { 'timeFormat' => get_option( 'time_format' ), ]; + /** + * Filter the WCPay JS settings. + * + * @since 6.1.0 + */ return apply_filters( 'wcpay_js_settings', $this->wcpay_js_settings ); } @@ -1000,6 +1005,11 @@ private function get_plugins_page_js_settings(): array { 'exitSurveyLastShown' => get_option( 'wcpay_exit_survey_last_shown', null ), ]; + /** + * Filter the plugins page settings. + * + * @since 7.8.0 + */ return apply_filters( 'wcpay_plugins_page_js_settings', $plugins_page_settings ); } diff --git a/templates/emails/customer-ipp-receipt.php b/templates/emails/customer-ipp-receipt.php index 45dad05f8d8..f5e78e28338 100644 --- a/templates/emails/customer-ipp-receipt.php +++ b/templates/emails/customer-ipp-receipt.php @@ -15,8 +15,11 @@ defined( 'ABSPATH' ) || exit; -/* +/** + * Output the email header. + * * @hooked WC_Emails::email_header() Output the email header + * @since 4.0.0 */ do_action( 'woocommerce_email_header', $email_heading, $email ); ?> @@ -25,12 +28,16 @@

get_order_number() ) ); ?>

get_order_number() ) ) . "\n\n"; +/** + * Outputs the store details section of the IPP receipt email. + * + * @since 4.0.0 + */ do_action( 'woocommerce_payments_email_ipp_receipt_store_details', $merchant_settings, $plain_text ); echo "\n----------------------------------------\n\n"; -/* +/** + * Outputs the order details section of the email. + * * @hooked WC_Emails::order_details() Shows the order details table. * @hooked WC_Structured_Data::generate_order_data() Generates structured data. * @hooked WC_Structured_Data::output_structured_data() Outputs structured data. @@ -39,12 +46,20 @@ echo "\n----------------------------------------\n\n"; +/** + * Outputs the compliance details section of the IPP receipt email. + * + * @since 4.0.0 + */ do_action( 'woocommerce_payments_email_ipp_receipt_compliance_details', $charge, $plain_text ); echo "\n\n----------------------------------------\n\n"; -/* +/** + * Outputs the order meta data section of the email. + * * @hooked WC_Emails::order_meta() Shows order meta data. + * @since 4.0.0 */ do_action( 'woocommerce_email_order_meta', $order, $sent_to_admin, $plain_text, $email ); @@ -56,4 +71,9 @@ echo "\n\n----------------------------------------\n\n"; } +/** + * Outputs the footer text of the email. + * + * @since 4.0.0 + */ echo wp_kses_post( apply_filters( 'woocommerce_email_footer_text', get_option( 'woocommerce_email_footer_text' ) ) ); diff --git a/tests/unit/admin/test-class-wc-payments-admin-sections-overwrite.php b/tests/unit/admin/test-class-wc-payments-admin-sections-overwrite.php index 3a308511249..893cbf40433 100644 --- a/tests/unit/admin/test-class-wc-payments-admin-sections-overwrite.php +++ b/tests/unit/admin/test-class-wc-payments-admin-sections-overwrite.php @@ -53,7 +53,7 @@ public function test_checkout_sections_are_modified() { $this->assertEquals( $expected_sections, - apply_filters( 'woocommerce_get_sections_checkout', $sections ) + apply_filters( 'woocommerce_get_sections_checkout', $sections ) // phpcs:ignore WooCommerce.Commenting.CommentHooks.MissingHookComment ); } } From 8802c80c3c8254705d634aef8a035d6d97636bc6 Mon Sep 17 00:00:00 2001 From: Nagesh Pai <4162931+nagpai@users.noreply.github.com> Date: Tue, 14 Jan 2025 15:05:16 +0530 Subject: [PATCH 04/81] CSV Exports: Simplify localization by setting export language to that in user profile settings (#10003) Co-authored-by: Nagesh Pai Co-authored-by: Eric Jinks <3147296+Jinksi@users.noreply.github.com> --- ...date-9971-simplify-localization-csv-export | 4 + client/components/csv-export-modal/index.tsx | 227 ------------------ .../components/csv-export-modal/styles.scss | 51 ---- .../test/__snapshots__/index.test.tsx.snap | 7 - .../csv-export-modal/test/index.test.tsx | 72 ------ client/data/deposits/resolvers.js | 2 +- client/data/disputes/resolvers.js | 2 +- client/data/settings/actions.js | 6 - client/data/settings/hooks.js | 10 - client/data/settings/selectors.js | 4 - client/data/transactions/resolvers.js | 2 +- client/deposits/list/index.tsx | 49 +--- client/deposits/list/test/index.tsx | 25 +- client/disputes/index.tsx | 53 +--- client/disputes/test/index.tsx | 26 +- client/globals.d.ts | 36 ++- .../components/export-language/index.tsx | 55 ----- .../reporting-settings/components/index.ts | 6 - client/settings/reporting-settings/index.tsx | 35 --- .../settings/reporting-settings/interfaces.ts | 4 - client/settings/reporting-settings/style.scss | 17 -- .../test/__snapshots__/index.test.js.snap | 151 ------------ .../reporting-settings/test/index.test.js | 55 ----- client/settings/settings-manager/index.js | 28 --- client/transactions/list/index.tsx | 55 +---- client/transactions/list/test/index.tsx | 21 +- client/transactions/test/index.tsx | 8 - client/utils/index.js | 75 ------ includes/admin/class-wc-payments-admin.php | 5 +- ...s-wc-rest-payments-settings-controller.php | 21 -- 30 files changed, 75 insertions(+), 1037 deletions(-) create mode 100644 changelog/update-9971-simplify-localization-csv-export delete mode 100644 client/components/csv-export-modal/index.tsx delete mode 100644 client/components/csv-export-modal/styles.scss delete mode 100644 client/components/csv-export-modal/test/__snapshots__/index.test.tsx.snap delete mode 100644 client/components/csv-export-modal/test/index.test.tsx delete mode 100644 client/settings/reporting-settings/components/export-language/index.tsx delete mode 100644 client/settings/reporting-settings/components/index.ts delete mode 100644 client/settings/reporting-settings/index.tsx delete mode 100644 client/settings/reporting-settings/interfaces.ts delete mode 100644 client/settings/reporting-settings/style.scss delete mode 100644 client/settings/reporting-settings/test/__snapshots__/index.test.js.snap delete mode 100644 client/settings/reporting-settings/test/index.test.js 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/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`] = ` -