mirror of
https://github.com/woocommerce/woocommerce-paypal-payments.git
synced 2025-09-03 08:37:53 +08:00
🎨 Isolate condition for preview buttons
This step makes it easier to refactor/update the logic in the next step.
This commit is contained in:
parent
fa76f1a73c
commit
d1a93a1b55
2 changed files with 23 additions and 3 deletions
|
@ -47,6 +47,16 @@ import widgetBuilder from "../../../ppcp-button/resources/js/modules/Renderer/Wi
|
|||
}, 100);
|
||||
});
|
||||
|
||||
/**
|
||||
* Decides, whether to display the Google Pay preview button.
|
||||
*
|
||||
* @return {boolean}
|
||||
*/
|
||||
const shouldDisplayPreviewButton = function() {
|
||||
// TODO - original condition, which is wrong.
|
||||
return jQuery('#ppcp-googlepay_button_enabled').is(':checked');
|
||||
}
|
||||
|
||||
const applyConfigOptions = function (buttonConfig) {
|
||||
buttonConfig.button = buttonConfig.button || {};
|
||||
buttonConfig.button.style = buttonConfig.button.style || {};
|
||||
|
@ -58,7 +68,7 @@ import widgetBuilder from "../../../ppcp-button/resources/js/modules/Renderer/Wi
|
|||
const createButton = function (ppcpConfig) {
|
||||
const selector = ppcpConfig.button.wrapper + 'GooglePay';
|
||||
|
||||
if (!jQuery('#ppcp-googlepay_button_enabled').is(':checked')) {
|
||||
if (!shouldDisplayPreviewButton()) {
|
||||
jQuery(selector).remove();
|
||||
return;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue