Add style settings for card button

This commit is contained in:
Alex P 2023-11-08 08:39:53 +02:00
parent 9bd9b2ede3
commit 47728a78ff
No known key found for this signature in database
GPG key ID: 54487A734A204D71
4 changed files with 131 additions and 3 deletions

View file

@ -1006,8 +1006,9 @@ document.querySelector("#payment").before(document.querySelector("#ppcp-messages
'id' => CardButtonGateway::ID,
'wrapper' => '#ppc-button-' . CardButtonGateway::ID,
'style' => array(
'shape' => $this->style_for_context( 'shape', $this->context() ),
// TODO: color black, white from the gateway settings.
'shape' => $this->style_for_apm( 'shape', 'card' ),
'color' => $this->style_for_apm( 'color', 'card', 'black' ),
'layout' => $this->style_for_apm( 'poweredby_tagline', 'card', false ) === $this->normalize_style_value( true ) ? 'vertical' : 'horizontal',
),
),
),
@ -1371,6 +1372,21 @@ document.querySelector("#payment").before(document.querySelector("#ppcp-messages
?? $this->normalize_style_value( $defaults[ $style ] ?? '' );
}
/**
* Determines the style for a given property in a given APM.
*
* @param string $style The name of the style property.
* @param string $apm The APM name, such as 'card'.
* @param ?mixed $default The default value.
*
* @return string
*/
private function style_for_apm( string $style, string $apm, $default = null ): string {
return $this->get_style_value( "${apm}_button_${style}" )
?? ( $default ? $this->normalize_style_value( $default ) : null )
?? $this->style_for_context( $style, 'checkout' );
}
/**
* Returns the style property value or null.
*