Skip to content

Commit 8b7a1a4

Browse files
committed
add setting for theme
1 parent 764d61a commit 8b7a1a4

File tree

3 files changed

+19
-4
lines changed

3 files changed

+19
-4
lines changed

includes/class-thirdweb-blocks-support.php

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -83,16 +83,17 @@ public function get_payment_method_data() {
8383
'title' => $this->get_setting('title'),
8484
'description' => $this->get_setting('description'),
8585
'supports' => $this->get_supported_features(),
86-
86+
8787
// thirdweb configuration
8888
'clientId' => $this->get_setting('client_id'),
8989
'seller' => $this->get_setting('seller_wallet'),
9090
'chainId' => (int) $this->get_setting('chain_id'),
9191
'tokenAddress' => $this->get_setting('token_address'),
92-
92+
'theme' => $this->get_setting('theme') ?: 'light',
93+
9394
// Icons/branding
9495
'icon' => THIRDWEB_WC_PLUGIN_URL . 'assets/icon.svg',
95-
96+
9697
// Supported stablecoins display
9798
'supportedTokens' => $this->get_supported_tokens(),
9899
];

includes/class-thirdweb-payment-gateway.php

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ public function __construct() {
3939
$this->seller_wallet = $this->get_option('seller_wallet');
4040
$this->chain_id = $this->get_option('chain_id');
4141
$this->token_address = $this->get_option('token_address');
42+
$this->theme = $this->get_option('theme');
4243

4344
// Save settings hook
4445
add_action('woocommerce_update_options_payment_gateways_' . $this->id, [$this, 'process_admin_options']);
@@ -111,6 +112,17 @@ public function init_form_fields() {
111112
'default' => '0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913', // USDC on Base
112113
'placeholder' => __('0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913', 'thirdweb-wc'),
113114
],
115+
'theme' => [
116+
'title' => __('Widget Theme', 'thirdweb-wc'),
117+
'type' => 'select',
118+
'description' => __('Choose the color theme for the checkout widget. Light theme is recommended for most sites.', 'thirdweb-wc'),
119+
'default' => 'light',
120+
'desc_tip' => true,
121+
'options' => [
122+
'light' => __('Light', 'thirdweb-wc'),
123+
'dark' => __('Dark', 'thirdweb-wc'),
124+
],
125+
],
114126
];
115127
}
116128

@@ -227,6 +239,7 @@ public function get_frontend_config() {
227239
'tokenAddress' => $this->token_address,
228240
'title' => $this->title,
229241
'description' => $this->description,
242+
'theme' => $this->theme ?: 'light',
230243
];
231244
}
232245
}

src/checkout-block/ThirdwebCheckout.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ interface ThirdwebCheckoutProps {
1717
chainId: number;
1818
tokenAddress?: string;
1919
description?: string;
20+
theme?: 'light' | 'dark';
2021
supportedTokens?: Array<{ symbol: string; address: string }>;
2122
};
2223
billing: {
@@ -178,7 +179,7 @@ export const ThirdwebCheckout: React.FC<ThirdwebCheckoutProps> = ({
178179
onCancel={handleCancel}
179180

180181
// Theming
181-
theme="light"
182+
theme={settings.theme || 'light'}
182183
/>
183184
</div>
184185

0 commit comments

Comments
 (0)