Skip to content

Commit 79f96a0

Browse files
authored
WooPay blocks default terms and conditions text (#10286)
1 parent 061cd75 commit 79f96a0

File tree

2 files changed

+44
-3
lines changed

2 files changed

+44
-3
lines changed
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
Significance: patch
2+
Type: fix
3+
4+
WooPay blocks checkout terms and condition default text

includes/woopay/class-woopay-session.php

Lines changed: 40 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -975,9 +975,11 @@ private static function get_option_fields_status() {
975975
}
976976
}
977977

978-
$fields_block = self::get_inner_block( $checkout_page_blocks[ $checkout_block_index ], 'woocommerce/checkout-fields-block' );
979-
$terms_block = self::get_inner_block( $fields_block, 'woocommerce/checkout-terms-block' );
980-
$show_terms_checkbox = isset( $terms_block['attrs']['checkbox'] ) && $terms_block['attrs']['checkbox'];
978+
$fields_block = self::get_inner_block( $checkout_page_blocks[ $checkout_block_index ], 'woocommerce/checkout-fields-block' );
979+
$terms_block = self::get_inner_block( $fields_block, 'woocommerce/checkout-terms-block' );
980+
$show_terms_checkbox = isset( $terms_block['attrs']['checkbox'] ) && $terms_block['attrs']['checkbox'];
981+
$below_place_order_button_text = self::get_blocks_terms_and_conditions_text( $terms_block );
982+
981983
}
982984

983985
return [
@@ -989,6 +991,41 @@ private static function get_option_fields_status() {
989991
];
990992
}
991993

994+
/**
995+
* Gets the blocks terms and conditions text.
996+
*
997+
* @param array $terms_block the terms block.
998+
* @return string
999+
*/
1000+
private static function get_blocks_terms_and_conditions_text( $terms_block ) {
1001+
1002+
if ( isset( $terms_block['attrs']['text'] ) ) {
1003+
return $terms_block['attrs']['text'];
1004+
}
1005+
1006+
$privacy_page_link = get_privacy_policy_url();
1007+
$privacy_page_link = $privacy_page_link
1008+
? '<a href="' . $privacy_page_link . '" target="_blank">' . __( 'Privacy Policy', 'woocommerce-payments' ) . '</a>'
1009+
: __( 'Privacy Policy', 'woocommerce-payments' );
1010+
1011+
$terms_page_id = wc_terms_and_conditions_page_id();
1012+
$terms_page_link = '';
1013+
if ( $terms_page_id ) {
1014+
$terms_page_link = get_permalink( $terms_page_id );
1015+
}
1016+
1017+
$terms_page_link = $terms_page_link
1018+
? '<a href="' . $terms_page_link . '" target="_blank">' . __( 'Terms and Conditions', 'woocommerce-payments' ) . '</a>'
1019+
: __( 'Terms and Conditions', 'woocommerce-payments' );
1020+
1021+
return sprintf(
1022+
/* translators: %1$s terms page link, %2$s privacy page link. */
1023+
__( 'You must accept our %1$s and %2$s to continue with your purchase.', 'woocommerce-payments' ),
1024+
$terms_page_link,
1025+
$privacy_page_link
1026+
);
1027+
}
1028+
9921029
/**
9931030
* Searches for an inner block with the given name.
9941031
*

0 commit comments

Comments
 (0)