FileMaster
Search
Toggle Dark Mode
Home
/
.
/
wp-content
/
plugins
/
surecart
/
dist
/
components
/
components
Edit File: sc-cart-session-provider2.js
import{proxyCustomElement,HTMLElement,createEvent,h}from"@stencil/core/internal/client";import{s as state}from"./mutations2.js";import{c as updateCheckout}from"./index4.js";import{c as createErrorNotice}from"./mutations3.js";import{u as updateFormState}from"./mutations5.js";import{c as clearCheckout}from"./mutations4.js";import{d as defineCustomElement$1}from"./sc-line-items-provider2.js";const ScCartSessionProvider=proxyCustomElement(class extends HTMLElement{constructor(){super(),this.__registerHost(),this.__attachShadow(),this.scSetState=createEvent(this,"scSetState",7)}handleUpdateSession(e){const{data:t,options:o}=e.detail;(null==o?void 0:o.silent)?this.update(t):this.loadUpdate(t)}handleErrorResponse(e){var t,o;"readonly"!==(null==e?void 0:e.code)&&"checkout.customer.account_mismatch"!==(null===(o=null===(t=null==e?void 0:e.additional_errors)||void 0===t?void 0:t[0])||void 0===o?void 0:o.code)||clearCheckout(),"rest_cookie_invalid_nonce"!==(null==e?void 0:e.code)?((null==e?void 0:e.message)&&createErrorNotice(e),"http_request_failed"===(null==e?void 0:e.code)&&createErrorNotice(wp.i18n.__("Something went wrong. Please reload the page and try again.","surecart"))):updateFormState("EXPIRE")}async fetch(e={}){this.loadUpdate({status:"draft",...e})}async update(e={},t={}){var o;try{state.checkout=await updateCheckout({id:null===(o=state.checkout)||void 0===o?void 0:o.id,data:{...e},query:{...t}})}catch(e){throw console.error(e),e}}async loadUpdate(e={}){try{updateFormState("FETCH"),await this.update(e),updateFormState("RESOLVE")}catch(e){updateFormState("REJECT"),this.handleErrorResponse(e)}}render(){return h("sc-line-items-provider",{key:"487aeb5da88dc93549ebe56f29b29196c45d73f4",order:state.checkout,onScUpdateLineItems:e=>this.loadUpdate({line_items:e.detail})},h("slot",{key:"4c30b8b64591822f4aa0938ee3876e840d234a08"}))}get el(){return this}},[1,"sc-cart-session-provider",void 0,[[0,"scUpdateOrder","handleUpdateSession"]]]);function defineCustomElement(){"undefined"!=typeof customElements&&["sc-cart-session-provider","sc-line-items-provider"].forEach((e=>{switch(e){case"sc-cart-session-provider":customElements.get(e)||customElements.define(e,ScCartSessionProvider);break;case"sc-line-items-provider":customElements.get(e)||defineCustomElement$1()}}))}export{ScCartSessionProvider as S,defineCustomElement as d};
Save
Back