mirror of
https://github.com/woocommerce/woocommerce-paypal-payments.git
synced 2025-09-05 08:59:14 +08:00
Replace place order text via WC_Gateway
This commit is contained in:
parent
3672c5a651
commit
91c6e55f3d
10 changed files with 14 additions and 191 deletions
|
@ -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
|
|
@ -1,8 +0,0 @@
|
|||
import PlaceOrderButtonBootstrap from "./modules/ContextBootstrap/PlaceOrderButtonBootstrap";
|
||||
|
||||
document.addEventListener(
|
||||
'DOMContentLoaded',
|
||||
() => {
|
||||
const placeOrderButtonBootstrap = new PlaceOrderButtonBootstrap(PpcpPlaceOrderButton);
|
||||
placeOrderButtonBootstrap.init();
|
||||
});
|
Loading…
Add table
Add a link
Reference in a new issue