Merge pull request #146 from woocommerce/fix/PCP-130-fix-cc-fields

Fix/pcp 130 fix cc fields
This commit is contained in:
Emili Castells 2021-05-17 11:09:14 +02:00 committed by GitHub
commit 437a6654c5
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 28 additions and 2 deletions

View file

@ -87,7 +87,7 @@ class CreditCardRenderer {
},
expirationDate: {
selector: '#ppcp-credit-card-gateway-card-expiry',
placeholder: this.defaultConfig.hosted_fields.labels.mm_yyyy,
placeholder: this.defaultConfig.hosted_fields.labels.mm_yy,
}
}
}).then(hostedFields => {

View file

@ -667,7 +667,7 @@ class SmartButton implements SmartButtonInterface {
'labels' => array(
'credit_card_number' => '',
'cvv' => '',
'mm_yyyy' => __( 'MM/YYYY', 'woocommerce-paypal-payments' ),
'mm_yy' => __( 'MM/YY', 'woocommerce-paypal-payments' ),
'fields_not_valid' => __(
'Unfortunately, your credit card details are not valid.',
'woocommerce-paypal-payments'

View file

@ -198,6 +198,32 @@ class CreditCardGateway extends \WC_Payment_Gateway_CC {
);
}
/**
* Render the credit card fields.
*/
public function form() {
add_action( 'gettext', array( $this, 'replace_credit_card_cvv_label' ), 10, 3 );
parent::form();
remove_action( 'gettext', 'replace_credit_card_cvv_label' );
}
/**
* Replace WooCommerce credit card field label.
*
* @param string $translation Translated text.
* @param string $text Original text to translate.
* @param string $domain Text domain.
*
* @return string Translated field.
*/
public function replace_credit_card_cvv_label( string $translation, string $text, string $domain ): string {
if ( 'woocommerce' !== $domain || 'Card code' !== $text ) {
return $translation;
}
return __( 'CVV', 'woocommerce-paypal-payments' );
}
/**
* Returns the title of the gateway.
*