Make ACDC default for China

This commit is contained in:
Alex P. 2024-09-18 16:27:32 +03:00
parent bf525bc7b8
commit eb625af36d
No known key found for this signature in database
GPG key ID: 54487A734A204D71
2 changed files with 13 additions and 7 deletions

View file

@ -54,9 +54,10 @@ class OnboardingOptionsRenderer {
* Renders the onboarding options. * Renders the onboarding options.
* *
* @param bool $is_shop_supports_dcc Whether the shop can use DCC (country, currency). * @param bool $is_shop_supports_dcc Whether the shop can use DCC (country, currency).
* @param bool $make_dcc_default Whether DCC should be selected by default.
*/ */
public function render( bool $is_shop_supports_dcc ): string { public function render( bool $is_shop_supports_dcc, bool $make_dcc_default ): string {
$checked = $is_shop_supports_dcc ? '' : 'checked'; $checked_cards = ( $is_shop_supports_dcc && ! $make_dcc_default ) ? '' : 'checked';
$on_boarding_options = ' $on_boarding_options = '
<li> <li>
@ -65,10 +66,10 @@ class OnboardingOptionsRenderer {
</label> </label>
</li> </li>
<li> <li>
<label><input type="checkbox" id="ppcp-onboarding-accept-cards" ' . $checked . '> ' . __( 'Securely accept all major credit & debit cards on the strength of the PayPal network', 'woocommerce-paypal-payments' ) . '</label> <label><input type="checkbox" id="ppcp-onboarding-accept-cards" ' . $checked_cards . '> ' . __( 'Securely accept all major credit & debit cards on the strength of the PayPal network', 'woocommerce-paypal-payments' ) . '</label>
</li> </li>
<li>' . <li>' .
$this->render_dcc( $is_shop_supports_dcc ) . $this->render_dcc( $is_shop_supports_dcc, $make_dcc_default ) .
'</li>' . '</li>' .
$this->render_pui_option(); $this->render_pui_option();
@ -107,8 +108,9 @@ class OnboardingOptionsRenderer {
* Renders the onboarding DCC options. * Renders the onboarding DCC options.
* *
* @param bool $is_shop_supports_dcc Whether the shop can use DCC (country, currency). * @param bool $is_shop_supports_dcc Whether the shop can use DCC (country, currency).
* @param bool $make_dcc_default Whether DCC should be selected by default.
*/ */
private function render_dcc( bool $is_shop_supports_dcc ): string { private function render_dcc( bool $is_shop_supports_dcc, bool $make_dcc_default ): string {
$items = array(); $items = array();
$is_us_shop = 'US' === $this->country; $is_us_shop = 'US' === $this->country;
@ -201,6 +203,7 @@ class OnboardingOptionsRenderer {
<li> <li>
<label> <label>
<input type="radio" id="ppcp-onboarding-dcc-acdc" name="ppcp_onboarding_dcc" value="acdc" ' . <input type="radio" id="ppcp-onboarding-dcc-acdc" name="ppcp_onboarding_dcc" value="acdc" ' .
( $make_dcc_default ? 'checked' : '' ) .
' data-screen-url="' . $this->get_screen_url( 'acdc' ) . '"> ' . ' data-screen-url="' . $this->get_screen_url( 'acdc' ) . '"> ' .
__( 'Advanced Card Processing', 'woocommerce-paypal-payments' ) . ' __( 'Advanced Card Processing', 'woocommerce-paypal-payments' ) . '
</label> </label>

View file

@ -105,7 +105,10 @@ return function ( ContainerInterface $container, array $fields ): array {
'ppcp_onboarading_options' => array( 'ppcp_onboarading_options' => array(
'type' => 'ppcp-text', 'type' => 'ppcp-text',
'classes' => array( 'ppcp-onboarding-element' ), 'classes' => array( 'ppcp-onboarding-element' ),
'text' => $onboarding_options_renderer->render( $is_shop_supports_dcc ), 'text' => $onboarding_options_renderer->render(
$is_shop_supports_dcc,
$container->get( 'api.shop.country' ) === 'CN'
),
'raw' => true, 'raw' => true,
'screens' => array( 'screens' => array(
State::STATE_START, State::STATE_START,