Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /**
- * On submitting the form the OffCanvas shall open, the product has to be posted
- * against the storefront api and after that the current cart template needs to
- * be fetched and shown inside the OffCanvas
- * @param {Event} e
- * @private
- */
- _onFormSubmit(e) {
- e.preventDefault();
- const form = e.target;
- const requestUrl = DomAccess.getAttribute(form, 'action');
- // Open the OffCanvas first
- OffCanvas.open(LoadingIndicator.getTemplate(), () => {
- // Fire POST request for adding the product to cart
- this.client.post(requestUrl.toLowerCase(), this._convertFormDataToJSON(new FormData(form)), () => {
- // Update the CartWidget in the header
- CartWidget.fetch();
- // Fetch the current cart template and replace the OffCanvas content
- this.client.get(window.router["frontend.cart.detail"], (response) => {
- OffCanvas.setContent(response);
- this._registerRemoveProductTriggerEvents();
- });
- });
- }, CART_MINI_POSITION);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement