See https://docs.connect.squareup.com/articles/adding-payment-form#stylingin...

Currently we do not provide any defaults for styling the interiors beyond placeholders. This should be alterable in some way so implementors can easily adjust.

CommentFileSizeAuthor
#3 2866502-support-styling.patch779 bytesac
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

mglaman created an issue. See original summary.

mglaman’s picture

This has to be done for both 8x. and 7x

ac’s picture

Status: Active » Needs review
FileSize
779 bytes

Patched attached. Allows overriding of styles in a module like so:

(function ($, Drupal) {
        Drupal.behaviors.example_module_square = {
                attach: function(context, settings) {
                        Drupal.commerceSquareInputStyles = [
                                {
                                        fontSize: '15px',
                                        backgroundColor: 'red',
                                }
                        ];
                }
        }
})(jQuery, Drupal);

For this to work, custom module must be executed before commerce_square. In the custom module's install file:

function example_module_install() {
        $square_weight = 0;
        $extension_config = \Drupal::configFactory()->getEditable('core.extension');
        $square_weight = $extension_config->get('module.commerce_square') ?? 0;
        module_set_weight('example_module', $square_weight - 1);
}