Replace place order text via WC_Gateway

This commit is contained in:
Alex P 2023-11-16 09:38:35 +02:00
parent 3672c5a651
commit 91c6e55f3d
No known key found for this signature in database
GPG key ID: 54487A734A204D71
10 changed files with 14 additions and 191 deletions

View file

@ -1,45 +0,0 @@
import {
getCurrentPaymentMethod,
ORDER_BUTTON_SELECTOR,
PaymentMethods
} from "../Helper/CheckoutMethodState";
class PlaceOrderButtonBootstrap {
constructor(config) {
this.config = config;
this.defaultButtonText = null;
}
init() {
jQuery(document.body).on('updated_checkout payment_method_selected', () => {
this.updateUi();
});
this.updateUi();
}
updateUi() {
const button = document.querySelector(ORDER_BUTTON_SELECTOR);
if (!button) {
return;
}
if (!this.defaultButtonText) {
this.defaultButtonText = button.innerText;
if (!this.defaultButtonText) {
return;
}
}
const currentPaymentMethod = getCurrentPaymentMethod();
if ([PaymentMethods.PAYPAL, PaymentMethods.CARD_BUTTON].includes(currentPaymentMethod)) {
button.innerText = this.config.buttonText;
} else {
button.innerText = this.defaultButtonText;
}
}
}
export default PlaceOrderButtonBootstrap

View file

@ -1,8 +0,0 @@
import PlaceOrderButtonBootstrap from "./modules/ContextBootstrap/PlaceOrderButtonBootstrap";
document.addEventListener(
'DOMContentLoaded',
() => {
const placeOrderButtonBootstrap = new PlaceOrderButtonBootstrap(PpcpPlaceOrderButton);
placeOrderButtonBootstrap.init();
});