respect merchant setting for Stripe CC `title`: (https://github.com/woocommerce/woocommerce-blocks/pull/3568)

- expose title setting to client and use in UI
This commit is contained in:
Rua Haszard 2020-12-23 08:52:37 +13:00 committed by GitHub
parent 0783108d19
commit 34f364e708
2 changed files with 15 additions and 5 deletions

View File

@ -36,11 +36,11 @@ const StripeComponent = ( props ) => {
const StripeLabel = ( props ) => { const StripeLabel = ( props ) => {
const { PaymentMethodLabel } = props.components; const { PaymentMethodLabel } = props.components;
return ( const labelText = getStripeServerData().title
<PaymentMethodLabel ? getStripeServerData().title
text={ __( 'Credit / Debit Card', 'woo-gutenberg-products-block' ) } : __( 'Credit / Debit Card', 'woo-gutenberg-products-block' );
/>
); return <PaymentMethodLabel text={ labelText } />;
}; };
const cardIcons = getStripeCreditCardIcons(); const cardIcons = getStripeCreditCardIcons();

View File

@ -84,6 +84,7 @@ final class Stripe extends AbstractPaymentMethodType {
'stripeTotalLabel' => $this->get_total_label(), 'stripeTotalLabel' => $this->get_total_label(),
'publicKey' => $this->get_publishable_key(), 'publicKey' => $this->get_publishable_key(),
'allowPrepaidCard' => $this->get_allow_prepaid_card(), 'allowPrepaidCard' => $this->get_allow_prepaid_card(),
'title' => $this->get_title(),
'button' => [ 'button' => [
'type' => $this->get_button_type(), 'type' => $this->get_button_type(),
'theme' => $this->get_button_theme(), 'theme' => $this->get_button_theme(),
@ -140,6 +141,15 @@ final class Stripe extends AbstractPaymentMethodType {
return apply_filters( 'wc_stripe_allow_prepaid_card', true ); return apply_filters( 'wc_stripe_allow_prepaid_card', true );
} }
/**
* Returns the title string to use in the UI (customisable via admin settings screen).
*
* @return string Title / label string
*/
private function get_title() {
return isset( $this->settings['title'] ) ? $this->settings['title'] : __( 'Credit / Debit Card', 'woo-gutenberg-products-block' );
}
/** /**
* Determine if store allows Payment Request buttons - e.g. Apple Pay / Chrome Pay. * Determine if store allows Payment Request buttons - e.g. Apple Pay / Chrome Pay.
* *