mirror of
https://github.com/woocommerce/woocommerce-paypal-payments.git
synced 2025-09-06 18:16:38 +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,6 +1,3 @@
|
|||
import ErrorHandler from './modules/ErrorHandler';
|
||||
import CartConfig from './modules/CartConfig';
|
||||
import CheckoutConfig from "./modules/CheckoutConfig";
|
||||
import MiniCartBootstap from './modules/MiniCartBootstap';
|
||||
import SingleProductBootstap from './modules/SingleProductBootstap';
|
||||
import CartBootstrap from './modules/CartBootstap';
|
||||
|
@ -8,42 +5,31 @@ import CheckoutBootstap from './modules/CheckoutBootstap';
|
|||
import Renderer from './modules/Renderer';
|
||||
|
||||
const bootstrap = () => {
|
||||
const renderer = new Renderer;
|
||||
const errorHandler = new ErrorHandler();
|
||||
const cartConfig = new CartConfig(
|
||||
PayPalCommerceGateway,
|
||||
errorHandler,
|
||||
);
|
||||
const checkoutConfig = new CheckoutConfig(
|
||||
PayPalCommerceGateway,
|
||||
errorHandler
|
||||
);
|
||||
const renderer = new Renderer(PayPalCommerceGateway);
|
||||
const context = PayPalCommerceGateway.context;
|
||||
|
||||
if (context === 'mini-cart' || context === 'product') {
|
||||
const miniCartBootstap = new MiniCartBootstap(
|
||||
const miniCartBootstrap = new MiniCartBootstap(
|
||||
PayPalCommerceGateway,
|
||||
renderer,
|
||||
cartConfig,
|
||||
renderer
|
||||
);
|
||||
|
||||
miniCartBootstap.init();
|
||||
miniCartBootstrap.init();
|
||||
}
|
||||
|
||||
if (context === 'product') {
|
||||
const singleProductBootstap = new SingleProductBootstap(
|
||||
const singleProductBootstrap = new SingleProductBootstap(
|
||||
PayPalCommerceGateway,
|
||||
renderer,
|
||||
);
|
||||
|
||||
singleProductBootstap.init();
|
||||
singleProductBootstrap.init();
|
||||
}
|
||||
|
||||
if (context === 'cart') {
|
||||
const cartBootstrap = new CartBootstrap(
|
||||
PayPalCommerceGateway,
|
||||
renderer,
|
||||
cartConfig,
|
||||
);
|
||||
|
||||
cartBootstrap.init();
|
||||
|
@ -52,8 +38,7 @@ const bootstrap = () => {
|
|||
if (context === 'checkout') {
|
||||
const checkoutBootstap = new CheckoutBootstap(
|
||||
PayPalCommerceGateway,
|
||||
renderer,
|
||||
checkoutConfig,
|
||||
renderer
|
||||
);
|
||||
|
||||
checkoutBootstap.init();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue