• Resolved trungdavid

    (@trungdavid)


    Hi everyone,

    I’ve been trying to style the labels for the input cards using the following code, but it doesn’t seem to work as expected. Currently, the label color is very light (almost white), making it difficult for customers to see. Could someone point me in the right direction to fix this?
    Image: https://ibb.co/5swSXRj

    // Shortcode checkout delete_transient( ‘wc_stripe_appearance’ ); // Block checkout delete_transient( ‘wc_stripe_blocks_appearance’ );

    add_filter( ‘wc_stripe_upe_params’, function ( $stripe_params ) { $stripe_params[‘blocksAppearance’] = (object) [ ‘rules’ => (object) [ ‘.Label’ => (object) [ ‘fontWeight’ => ‘bold’, ‘color’ => ‘blue’ ] ], ]; return $stripe_params; } );

    The page I need help with: [log in to see the link]

Viewing 4 replies - 1 through 4 (of 4 total)
  • Plugin Support Mahfuzur Rahman(woo-hc)

    (@mahfuzurwp)

    Hi @trungdavid,

    To adjust the label color and make it more visible, please try adding the following code to your theme’s functions.php file:

    add_filter( 'wc_stripe_upe_params', function ( $stripe_params ) {
    $stripe_params['blocksAppearance'] = (object) [
    'rules' => (object) [
    '.Label' => (object) [
    'fontWeight' => 'bold',
    'color' => 'blue' // You can use any color here
    ]
    ],
    ];
    return $stripe_params;
    } );

    // Clear transients
    delete_transient( 'wc_stripe_appearance' );
    delete_transient( 'wc_stripe_blocks_appearance' );

    For further guidance on customizing your payment form’s appearance, you can also refer to this Stripe Customization guide.

    I hope this helps, let us know if you have any more questions.

    Thread Starter trungdavid

    (@trungdavid)

    Thank you for your suggestion. I’ve tried implementing the code both with the Code Snippets plugin and directly in my theme’s functions.php file, but unfortunately, it’s still not working. Do you have any additional suggestions or insights that might help resolve this issue?

    Plugin Support Moses M. (woo-hc)

    (@mosesmedh)

    Hi @trungdavid,

    I tested this on my test site and found that it works intermittently, depending on the theme and how your site is set up. Try using just CSS like this:

    .p-FieldLabel.Label.Label--empty {
    color: black !important;
    }

    Add this to your additional CSS. It seems to work better when the label box loads quickly. If that doesn’t solve it, you can test the following code by adding it to your functions.php:

    // Ensure that Stripe's appearance is properly configured
    add_filter( 'wc_stripe_upe_params', function ( $stripe_params ) {
        // Modify the appearance of the Stripe elements
        $stripe_params['appearance'] = [
            'theme' => 'flat', // Optional, you can specify the theme here
            'variables' => [
                'colorText' => '#000000', // Set the text color to black
                'colorBackground' => '#ffffff', // Set the background color to white
                'colorPrimary' => '#0000FF', // Set the primary color to blue (for highlights)
            ],
            'rules' => [
                // Style the input fields (card number, expiration, etc.)
                '.Input' => [
                    'fontSize' => '16px',
                    'fontWeight' => 'bold',
                    'color' => '#333333', // Dark color for input text
                ],
                // Style the labels (for the card fields like "Card Number")
                '.p-FieldLabel.Label' => [
                    'color' => '#333333', // Dark gray color for the label
                    'fontWeight' => '600', // Semi-bold labels
                ],
            ],
        ];
    
        return $stripe_params;
    } );
    

    If this still doesn’t work, it might be worth considering hiring an expert from Codeable.io to analyze your site setup and the classes in more detail.

    Thread Starter trungdavid

    (@trungdavid)

    I’m using the code that Mahfuzur provided, and after one day, it somehow started working. Thank you, Mahfuzur and Moses, for your help. ??

Viewing 4 replies - 1 through 4 (of 4 total)
  • You must be logged in to reply to this topic.