mirror of
https://github.com/woocommerce/woocommerce-paypal-payments.git
synced 2025-09-05 08:59:14 +08:00
render sandbox and live connect button and toggle between those depending on sandbox checkbox
This commit is contained in:
parent
b70819847b
commit
6f870ec7a5
3 changed files with 137 additions and 43 deletions
|
@ -25,3 +25,31 @@ function onboardingCallback(authCode, sharedId) {
|
|||
}
|
||||
);
|
||||
}
|
||||
|
||||
const sandboxSwitch = (element) => {
|
||||
|
||||
const toggleConnectButtons = (showProduction) => {
|
||||
if (showProduction) {
|
||||
document.querySelector('#connect-to-production').style.display = '';
|
||||
document.querySelector('#connect-to-sandbox').style.display = 'none';
|
||||
return;
|
||||
}
|
||||
document.querySelector('#connect-to-production').style.display = 'none';
|
||||
document.querySelector('#connect-to-sandbox').style.display = '';
|
||||
}
|
||||
toggleConnectButtons(! element.checked);
|
||||
|
||||
element.addEventListener(
|
||||
'change',
|
||||
(event) => {
|
||||
toggleConnectButtons(! element.checked);
|
||||
}
|
||||
);
|
||||
};
|
||||
|
||||
(() => {
|
||||
const sandboxSwitchElement = document.querySelector('#ppcp-sandbox_on');
|
||||
if (sandboxSwitchElement) {
|
||||
sandboxSwitch(sandboxSwitchElement);
|
||||
}
|
||||
})();
|
Loading…
Add table
Add a link
Reference in a new issue