2020-04-08 18:50:29 +03:00
|
|
|
import Renderer from './Renderer';
|
|
|
|
|
|
|
|
class CartBootstrap {
|
|
|
|
constructor(configurator) {
|
|
|
|
this.configurator = configurator;
|
|
|
|
}
|
|
|
|
|
|
|
|
init() {
|
2020-04-09 10:49:37 +03:00
|
|
|
if (!this.shouldRender()) {
|
2020-04-08 18:50:29 +03:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2020-04-09 10:49:37 +03:00
|
|
|
const renderer = new Renderer(PayPalCommerceGateway.button.wrapper);
|
2020-04-08 18:50:29 +03:00
|
|
|
|
|
|
|
jQuery(document.body).on('updated_cart_totals updated_checkout', () => {
|
|
|
|
renderer.render(this.configurator.configuration());
|
|
|
|
});
|
|
|
|
|
|
|
|
renderer.render(this.configurator.configuration());
|
|
|
|
}
|
2020-04-09 10:49:37 +03:00
|
|
|
|
|
|
|
shouldRender() {
|
|
|
|
return document.querySelector(PayPalCommerceGateway.button.wrapper);
|
|
|
|
}
|
2020-04-08 18:50:29 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
export default CartBootstrap;
|