Submit
Path:
~
/
home
/
getwphos
/
public_html
/
almajd14
/
wp-content
/
plugins
/
woocommerce
/
assets
/
client
/
blocks
/
woocommerce
/
File Content:
add-to-cart-with-options.js
import*as t from"@woocommerce/stores/woocommerce/cart";import*as e from"@wordpress/interactivity";import*as r from"@woocommerce/stores/woocommerce/product-data";var o={7908:t=>{t.exports=import("@woocommerce/stores/store-notices")},1401:e=>{e.exports=t},2833:(t,r,o)=>{var n,a;t.exports=(n={getContext:()=>e.getContext,store:()=>e.store},a={},o.d(a,n),a)}},n={};function a(t){var e=n[t];if(void 0!==e)return e.exports;var r=n[t]={exports:{}};return o[t](r,r.exports,a),r.exports}a.d=(t,e)=>{for(var r in e)a.o(e,r)&&!a.o(t,r)&&Object.defineProperty(t,r,{enumerable:!0,get:e[r]})},a.o=(t,e)=>Object.prototype.hasOwnProperty.call(t,e);var i={};a.d(i,{O:()=>p});var s=a(2833);a.d({},{});const u="I acknowledge that using a private store means my plugin will inevitably break on the next store release.",{state:c}=(0,s.store)("woocommerce",{},{lock:u}),l=(t,e,r,o)=>{let n,a=t;if("variable"===e){const e=((t,e)=>Array.isArray(t)&&Array.isArray(e)&&0!==t.length&&0!==e.length&&t.find((t=>Object.entries(t.attributes).every((([t,r])=>e.some((e=>!(e.attribute!==t)&&(e.value===r||e.value&&""===r)))))))||null)(r,o);e?.variation_id&&(a=e.variation_id,n=c?.products?.[t]?.variations?.[e?.variation_id])}else n=c?.products?.[a];if("object"!=typeof n||null===n)return null;const i="number"==typeof n.min?n.min:1,s="number"==typeof n.max&&n.max>=1?n.max:1/0,u=n.step||1;return{id:a,...n,min:i,max:s,step:u}},d=t=>{const e=(t=>{let e=null;return t.target instanceof HTMLButtonElement&&(e=t.target.parentElement?.querySelector(".qty")),t.target instanceof HTMLInputElement&&(e=t.target),e})(t);if(!e)return;const r=parseInt(e.value,10);return{currentValue:isNaN(r)?0:r,inputElement:e}},p=(t,e,r)=>{const o=c.cart?.items.find((e=>{return"variation"===e.type?!(e.id!==t||!e.variation||!r||e.variation.length!==r.length)&&(o=e,n=r,!(!Array.isArray(o.variation)||!Array.isArray(n))&&o.variation.length===n.length&&o.variation.every((({raw_attribute:t,value:e})=>n.some((r=>r.attribute===t&&(r.value.toLowerCase()===e.toLowerCase()||r.value&&""===e)))))):e.id===t;var o,n}));return(o?.quantity||0)+e},m=t=>{const e=new Event("change",{bubbles:!0});t.dispatchEvent(e)},{actions:y,state:v}=(0,s.store)("woocommerce/add-to-cart-with-options",{state:{noticeIds:[],get validationErrors(){const t=(0,s.getContext)();return t&&t.validationErrors?t.validationErrors:[]},get isFormValid(){const t=(0,s.getContext)();if(!t)return!0;const{productType:e,quantity:r}=t;return"grouped"===e?Object.values(r).some((t=>t>0)):0===v.validationErrors.length},get allowsDecrease(){const{quantity:t,childProductId:e,productType:r,productId:o,availableVariations:n,selectedAttributes:a}=(0,s.getContext)();if("grouped"===r&&t[e]>0)return!0;const i=l(e||o,r,n,a);if(!i)return!0;const{id:u,min:c,step:d}=i;return"number"!=typeof d||"number"!=typeof c||(t[u]||0)-d>=c},get allowsIncrease(){const{quantity:t,childProductId:e,productType:r,productId:o,availableVariations:n,selectedAttributes:a}=(0,s.getContext)(),i=l(e||o,r,n,a);if(!i)return!0;const{id:u,max:c,step:d}=i;return"number"!=typeof d||"number"!=typeof c||(t[u]||0)+d<=c}},actions:{setQuantity(t){const e=(0,s.getContext)();if("variable"===e.productType)e.availableVariations.map((t=>t.variation_id)).forEach((r=>{e.quantity[r]=t}));else{const r=e.childProductId||e.productId;e.quantity={...e.quantity,[r]:t}}},addError:t=>{const{validationErrors:e}=v;return e.push(t),t.code},clearErrors:t=>{const{validationErrors:e}=v;if(t){const r=e.filter((e=>e.group!==t));e.splice(0,e.length,...r)}else e.length=0},increaseQuantity:t=>{const e=d(t);if(!e)return;const{currentValue:r,inputElement:o}=e,{childProductId:n,productType:a,productId:i,availableVariations:u,selectedAttributes:c}=(0,s.getContext)(),p=l(n||i,a,u,c);if(!p)return;const{max:v,min:f,step:g}=p;if("number"!=typeof g||"number"!=typeof f||"number"!=typeof v)return;const b=r+g;if(b<=v){const t=Math.max(f,b);y.setQuantity(t),o.value=t.toString(),m(o)}},decreaseQuantity:t=>{const e=d(t);if(!e)return;const{currentValue:r,inputElement:o}=e,{childProductId:n,productType:a,productId:i,availableVariations:u,selectedAttributes:c}=(0,s.getContext)(),p=l(n||i,a,u,c);if(!p)return;const{min:v,max:f,step:g}=p;if("number"!=typeof g||"number"!=typeof v||"number"!=typeof f)return;let b=r-g;"grouped"===a&&b<v&&(b=r>v?v:0),b!==r&&(y.setQuantity(b),o.value=b.toString(),m(o))},handleQuantityInput:t=>{const e=d(t);if(!e)return;const{currentValue:r}=e;y.setQuantity(r)},handleQuantityChange:t=>{const e=d(t);if(!e)return;const{childProductId:r}=(0,s.getContext)(),{currentValue:o}=e,{productType:n,productId:a,availableVariations:i,selectedAttributes:u}=(0,s.getContext)(),c=l(r||a,n,i,u);if(!c)return;const{min:p,max:v,step:f}=c;if("number"!=typeof f||"number"!=typeof p||"number"!=typeof v)return;let g=Math.min(null!=v?v:1/0,Math.max(p,o));"grouped"===n&&o<p&&(g=0),t.target.value!==g.toString()&&(y.setQuantity(g),t.target.value=g.toString(),m(t.target))},handleQuantityCheckboxChange:t=>{const e=d(t);if(!e)return;const{inputElement:r}=e;y.setQuantity(r.checked?1:0)},*addToCart(){yield Promise.resolve().then(a.bind(a,1401));const{productId:t,quantity:e,selectedAttributes:r,productType:o}=(0,s.getContext)(),{variationId:n}=v,i=n||t,c=p(i,e[i],r),{actions:l}=(0,s.store)("woocommerce",{},{lock:u});yield l.addCartItem({id:i,quantity:c,variation:r,type:o})},*handleSubmit(t){t.preventDefault();const{isFormValid:e}=v;if(e)yield y.addToCart();else{yield Promise.resolve().then(a.bind(a,7908));const{actions:t}=(0,s.store)("woocommerce/store-notices",{},{lock:u}),{noticeIds:e,validationErrors:r}=v;e.forEach((e=>{t.removeNotice(e)})),e.splice(0,e.length);const o=r.map((e=>t.addNotice({notice:e.message,type:"error",dismissible:!0})));e.push(...o)}}}},{lock:u});var f=i.O;export{f as getNewQuantity};
Submit
FILE
FOLDER
Name
Size
Permission
Action
accordion-group-style-rtl.css
1856 bytes
0644
accordion-group-style.css
1854 bytes
0644
accordion-group.js
679 bytes
0644
add-to-cart-form-editor-rtl.css
919 bytes
0644
add-to-cart-form-editor.css
919 bytes
0644
add-to-cart-form-style-rtl.css
7261 bytes
0644
add-to-cart-form-style.css
7264 bytes
0644
add-to-cart-form.js
1016 bytes
0644
add-to-cart-with-options-editor-rtl.css
1012 bytes
0644
add-to-cart-with-options-editor.css
1011 bytes
0644
add-to-cart-with-options-grouped-product-item-selector-style-rtl.css
2591 bytes
0644
add-to-cart-with-options-grouped-product-item-selector-style.css
2590 bytes
0644
add-to-cart-with-options-grouped-product-item-style-rtl.css
175 bytes
0644
add-to-cart-with-options-grouped-product-item-style.css
174 bytes
0644
add-to-cart-with-options-grouped-product-selector.js
6643 bytes
0644
add-to-cart-with-options-quantity-selector-style-rtl.css
2490 bytes
0644
add-to-cart-with-options-quantity-selector-style.css
2489 bytes
0644
add-to-cart-with-options-style-rtl.css
2926 bytes
0644
add-to-cart-with-options-style.css
2927 bytes
0644
add-to-cart-with-options-variation-selector-attribute-name-style-rtl.css
249 bytes
0644
add-to-cart-with-options-variation-selector-attribute-name-style.css
248 bytes
0644
add-to-cart-with-options-variation-selector-attribute-options-style-rtl.css
2204 bytes
0644
add-to-cart-with-options-variation-selector-attribute-options-style.css
2203 bytes
0644
add-to-cart-with-options-variation-selector.js
3919 bytes
0644
add-to-cart-with-options.js
5769 bytes
0644
mini-cart-footer-block-editor-rtl.css
153 bytes
0644
mini-cart-footer-block-editor.css
152 bytes
0644
mini-cart.js
21928 bytes
0644
product-button-style-rtl.css
3869 bytes
0644
product-button-style.css
3867 bytes
0644
product-button.js
3120 bytes
0644
product-collection-editor-rtl.css
6933 bytes
0644
product-collection-editor.css
6931 bytes
0644
product-collection-rtl.css
489 bytes
0644
product-collection-style-rtl.css
489 bytes
0644
product-collection-style.css
488 bytes
0644
product-collection.css
488 bytes
0644
product-collection.js
3447 bytes
0644
product-elements.js
23291 bytes
0644
product-filter-active.js
838 bytes
0644
product-filter-attribute-style-rtl.css
294 bytes
0644
product-filter-attribute-style.css
294 bytes
0644
product-filter-checkbox-list-editor-rtl.css
1271 bytes
0644
product-filter-checkbox-list-editor.css
1269 bytes
0644
product-filter-checkbox-list-style-rtl.css
2316 bytes
0644
product-filter-checkbox-list-style.css
2313 bytes
0644
product-filter-checkbox-list.js
393 bytes
0644
product-filter-chips-editor-rtl.css
1126 bytes
0644
product-filter-chips-editor.css
1124 bytes
0644
product-filter-chips-style-rtl.css
1806 bytes
0644
product-filter-chips-style.css
1805 bytes
0644
product-filter-chips.js
1233 bytes
0644
product-filter-clear-button-style-rtl.css
156 bytes
0644
product-filter-clear-button-style.css
155 bytes
0644
product-filter-price-slider-style-rtl.css
6366 bytes
0644
product-filter-price-slider-style.css
6352 bytes
0644
product-filter-price-slider.js
997 bytes
0644
product-filter-price.js
2819 bytes
0644
product-filter-removable-chips-style-rtl.css
1895 bytes
0644
product-filter-removable-chips-style.css
1894 bytes
0644
product-filter-status-style-rtl.css
369 bytes
0644
product-filter-status-style.css
368 bytes
0644
product-filters-editor-rtl.css
856 bytes
0644
product-filters-editor.css
856 bytes
0644
product-filters-style-rtl.css
4959 bytes
0644
product-filters-style.css
4958 bytes
0644
product-filters.js
3234 bytes
0644
product-gallery-large-image-editor-rtl.css
1241 bytes
0644
product-gallery-large-image-editor.css
1240 bytes
0644
product-gallery-large-image-next-previous-editor-rtl.css
124 bytes
0644
product-gallery-large-image-next-previous-editor.css
123 bytes
0644
product-gallery-large-image-next-previous-style-rtl.css
913 bytes
0644
product-gallery-large-image-next-previous-style.css
912 bytes
0644
product-gallery-large-image.js
986 bytes
0644
product-gallery-style-rtl.css
11498 bytes
0644
product-gallery-style.css
11497 bytes
0644
product-gallery-thumbnails-editor-rtl.css
197 bytes
0644
product-gallery-thumbnails-editor.css
196 bytes
0644
product-gallery.js
6492 bytes
0644
product-review-form-editor-rtl.css
210 bytes
0644
product-review-form-editor.css
209 bytes
0644
product-review-form-style-rtl.css
3149 bytes
0644
product-review-form-style.css
3147 bytes
0644
product-review-form.js
1999 bytes
0644
product-reviews.js
950 bytes
0644
product-stock-indicator-style-rtl.css
173 bytes
0644
product-stock-indicator-style.css
172 bytes
0644
product-template-editor-rtl.css
243 bytes
0644
product-template-editor.css
240 bytes
0644
product-template-style-rtl.css
2840 bytes
0644
product-template-style.css
2839 bytes
0644
N4ST4R_ID | Naxtarrr