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

fix: add ECE incompatibility notice with shipping settings #10152

Draft
wants to merge 1 commit into
base: develop
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions changelog/fix-ece-incompatibility-with-shipping-settings
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Significance: patch
Type: fix

update: add incompatibility notice for GooglePay/ApplePay with shipping settings.
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
/**
* External dependencies
*/
import { __ } from '@wordpress/i18n';
import interpolateComponents from '@automattic/interpolate-components';
import React from 'react';
import { useSelect } from '@wordpress/data';

/**
* Internal dependencies
*/
import { getAdminUrl } from '../../utils';
import { STORE_NAME } from 'wcpay/data/constants';
import InlineNotice from '../inline-notice';

const AppleGooglePayShippingSettingsCompatibilityNotice = () => {
const isRequiringFullAddressAtCheckout = useSelect( ( select ) =>
select( STORE_NAME ).getIsRequiringFullAddressAtCheckout()
);

if ( ! isRequiringFullAddressAtCheckout ) return null;

return (
<InlineNotice status="warning" icon={ true } isDismissible={ false }>
{ interpolateComponents( {
mixedString: __(
'The your shipping settings can cause conflicts with this payment method. To resolve this issue, please disable the "Hide shipping costs until an address is entered" option {{link}}in the shipping settings page{{/link}}.',
'woocommerce-payments'
),
components: {
link: (
<a
href={ getAdminUrl( {
page: 'wc-settings',
tab: 'shipping',
section: 'options',
} ) }
>
Review extensions
</a>
),
},
} ) }
</InlineNotice>
);
};

export default AppleGooglePayShippingSettingsCompatibilityNotice;
4 changes: 4 additions & 0 deletions client/data/settings/selectors.js
Original file line number Diff line number Diff line change
Expand Up @@ -272,3 +272,7 @@ export const getStripeBillingSubscriptionCount = ( state ) => {
export const getStripeBillingMigratedCount = ( state ) => {
return getSettings( state ).stripe_billing_migrated_count || 0;
};

export const getIsRequiringFullAddressAtCheckout = ( state ) => {
return getSettings( state ).is_requiring_full_address_checkout || false;
};
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import {
usePaymentRequestEnabledSettings,
usePaymentRequestLocations,
} from 'wcpay/data';
import AppleGooglePayShippingSettingsCompatibilityNotice from 'wcpay/components/google-pay-apple-pay-shipping-compatibility-notice';

const PaymentRequestSettings = ( { section } ) => {
const [
Expand Down Expand Up @@ -44,6 +45,7 @@ const PaymentRequestSettings = ( { section } ) => {
<Card>
{ section === 'enable' && (
<CardBody>
<AppleGooglePayShippingSettingsCompatibilityNotice />
<CheckboxControl
checked={ isPaymentRequestEnabled }
onChange={ updateIsPaymentRequestEnabled }
Expand Down
6 changes: 4 additions & 2 deletions client/settings/express-checkout/apple-google-pay-item.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,11 @@ import { PaymentRequestEnabledSettingsHook } from './interfaces';
import { ApplePayIcon, GooglePayIcon } from 'wcpay/payment-methods-icons';
import DuplicateNotice from 'wcpay/components/duplicate-notice';
import DuplicatedPaymentMethodsContext from '../settings-manager/duplicated-payment-methods-context';
import AppleGooglePayShippingSettingsCompatibilityNotice from 'wcpay/components/google-pay-apple-pay-shipping-compatibility-notice';

const AppleGooglePayExpressCheckoutItem = (): React.ReactElement => {
const id = 'apple_pay_google_pay';
const id = 'apple_pay_google_pay';

const AppleGooglePayExpressCheckoutItem = (): React.ReactElement => {
const [
isPaymentRequestEnabled,
updateIsPaymentRequestEnabled,
Expand Down Expand Up @@ -171,6 +172,7 @@ const AppleGooglePayExpressCheckoutItem = (): React.ReactElement => {
</div>
</div>
</div>
<AppleGooglePayShippingSettingsCompatibilityNotice />
{ isDuplicate && (
<DuplicateNotice
paymentMethod={ id }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -475,6 +475,7 @@ public function get_settings(): WP_REST_Response {
'available_payment_method_ids' => $available_upe_payment_methods,
'payment_method_statuses' => $this->wcpay_gateway->get_upe_enabled_payment_method_statuses(),
'duplicated_payment_method_ids' => $this->wcpay_gateway->find_duplicates(),
'is_requiring_full_address_checkout' => wc_shipping_enabled() && 'yes' === get_option( 'woocommerce_shipping_cost_requires_address' ),
'is_wcpay_enabled' => $this->wcpay_gateway->is_enabled(),
'is_manual_capture_enabled' => 'yes' === $this->wcpay_gateway->get_option( 'manual_capture' ),
'is_test_mode_enabled' => WC_Payments::mode()->is_test(),
Expand Down
Loading