Refactor GooglePay contect handlers to reuse action handlers.

This commit is contained in:
Pedro Silva 2023-09-06 17:54:08 +01:00
parent 318217acb9
commit c6379ca980
No known key found for this signature in database
GPG key ID: E2EE20C0669D24B3
8 changed files with 78 additions and 64 deletions

View file

@ -4,6 +4,9 @@ import SimulateCart from "../../../../ppcp-button/resources/js/modules/Helper/Si
import ErrorHandler from "../../../../ppcp-button/resources/js/modules/ErrorHandler";
import UpdateCart from "../../../../ppcp-button/resources/js/modules/Helper/UpdateCart";
import BaseHandler from "./BaseHandler";
import CheckoutActionHandler
from "../../../../ppcp-button/resources/js/modules/ActionHandler/CheckoutActionHandler";
import Spinner from "../../../../ppcp-button/resources/js/modules/Helper/Spinner";
class SingleProductHandler extends BaseHandler {
@ -48,23 +51,16 @@ class SingleProductHandler extends BaseHandler {
});
}
createOrder() {
const errorHandler = new ErrorHandler(
this.ppcpConfig.labels.error.generic,
document.querySelector('.woocommerce-notices-wrapper')
);
const actionHandler = new SingleProductActionHandler(
actionHandler() {
return new SingleProductActionHandler(
this.ppcpConfig,
new UpdateCart(
this.ppcpConfig.ajax.change_cart.endpoint,
this.ppcpConfig.ajax.change_cart.nonce,
),
document.querySelector('form.cart'),
errorHandler,
this.errorHandler(),
);
return actionHandler.configuration().createOrder();
}
}