mirror of
https://github.com/woocommerce/woocommerce-paypal-payments.git
synced 2025-09-07 19:54:15 +08:00
Configure the button from the bootstrappers
This should give us the flexibility to overwrite default configuration option on context level
This commit is contained in:
parent
42fe525a0b
commit
4e0a4b8edb
9 changed files with 86 additions and 78 deletions
|
@ -1,8 +1,10 @@
|
|||
import ErrorHandler from './ErrorHandler';
|
||||
import CartActionHandler from './CartActionHandler';
|
||||
|
||||
class MiniCartBootstap {
|
||||
constructor(gateway, renderer, configurator) {
|
||||
constructor(gateway, renderer) {
|
||||
this.gateway = gateway;
|
||||
this.renderer = renderer;
|
||||
this.configurator = configurator;
|
||||
}
|
||||
|
||||
init() {
|
||||
|
@ -14,20 +16,27 @@ class MiniCartBootstap {
|
|||
}
|
||||
|
||||
shouldRender() {
|
||||
return document.querySelector(this.gateway.button.mini_cart_wrapper) !== null;
|
||||
return document.querySelector(this.gateway.button.mini_cart_wrapper) !==
|
||||
null;
|
||||
}
|
||||
|
||||
render() {
|
||||
// Compared to the other bootstrapper we need the checker inside the
|
||||
// renderer because the mini cart is refreshed with AJAX and the
|
||||
// wrapper DOM might not be there from the start
|
||||
if (!this.shouldRender()) {
|
||||
return;
|
||||
}
|
||||
|
||||
const actionHandler = new CartActionHandler(
|
||||
PayPalCommerceGateway,
|
||||
new ErrorHandler(),
|
||||
);
|
||||
|
||||
this.renderer.render(
|
||||
this.gateway.button.mini_cart_wrapper,
|
||||
this.configurator.configuration(),
|
||||
{
|
||||
style: {
|
||||
shape: 'rect',
|
||||
}, ...actionHandler.configuration(),
|
||||
},
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue