PluginProbe
FluentCart A New Era of eCommerce – Faster, Lighter, and Simpler / 1.6.4
FluentCart A New Era of eCommerce – Faster, Lighter, and Simpler v1.6.4
1.6.4 1.6.3 1.6.2 1.6.1 1.6.0 1.5.4 1.5.5 1.5.3 1.5.2 1.5.1 1.5.0 1.4.2 1.4.1 1.4.0 1.3.28 1.3.27 1.3.26 1.3.25 1.3.23 1.3.22 1.3.21 1.3.20 1.3.19 trunk 1.2.0 All 47 releases
fluent-cart / assets / StockBlock.js

StockBlock.js in FluentCart A New Era of eCommerce – Faster, Lighter, and Simpler 1.6.4, at assets/StockBlock.js

2 lines 3.9 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 import{j as t}from"./chunks/jsx-runtime.js?ver=1.6.4";import{o as g}from"./chunks/Icons.js?ver=1.6.4";import{S as j}from"./chunks/SelectProductModal.js?ver=1.6.4";import{E as S}from"./chunks/EditorPanel.js?ver=1.6.4";import{E as N}from"./chunks/EditorPanelRow.js?ver=1.6.4";import{b as r}from"./chunks/BlockEditorTranslator.js?ver=1.6.4";import{a as E}from"./chunks/index5.js?ver=1.6.4";import{u as B}from"./chunks/SingleProductContext.js?ver=1.6.4";import{a as I}from"./chunks/add-query-args.js?ver=1.6.4";import"./chunks/ProductListItem.js?ver=1.6.4";import"./chunks/index6.js?ver=1.6.4";const{InspectorControls:A}=wp.blockEditor,C=({attributes:a,setAttributes:p,selectedProduct:o,setSelectedProduct:d,isInsideProductInfo:c})=>{var n;return c?null:t.jsx(A,{children:t.jsx("div",{className:"fct-inspector-control-wrap fct-inspector-control-wrap--product-card",children:t.jsx("div",{className:"fct-inspector-control-group",children:t.jsx("div",{className:"fct-inspector-control-body",children:t.jsx(S,{title:r("Product"),children:t.jsxs(N,{className:"flex-col",children:[t.jsx(j,{onModalClosed:i=>{p({product_id:i!=null&&i.ID?String(i.ID):""}),d(i)},selectedProduct:o,setSelectedProduct:d,isMultiple:!1}),(o==null?void 0:o.post_title)&&t.jsxs("div",{className:"fct-selected-products",children:[t.jsx("span",{className:"fct-selected-products__label",children:r("Selected Product")}),t.jsx("div",{className:"fct-selected-products__list",children:t.jsx("div",{className:"fct-product-chip-group",children:t.jsx("span",{className:"fct-product-chip fct-product-chip--parent",children:o.post_title})})}),((n=o==null?void 0:o.detail)==null?void 0:n.stock_availability)&&t.jsxs("div",{className:"fct-selected-products__preview",children:[t.jsxs("strong",{children:[r("Stock"),":"]})," ",o.detail.stock_availability==="in-stock"&&r("In Stock"),o.detail.stock_availability==="out-of-stock"&&r("Out of Stock"),o.detail.stock_availability==="backorder"&&r("Available on Backorder"),o.detail.stock_availability==="low-stock"&&r("Low Stock")]})]})]})})})})})})},{useBlockProps:L}=wp.blockEditor,{registerBlockType:M}=wp.blocks,{useEffect:m,useState:R}=wp.element,{useSelect:q}=wp.data,{store:F}=wp.blockEditor,u=window.fluent_cart_stock_data,k=window.fluentCartRestVars.rest;M(u.slug+"/"+u.name,{apiVersion:3,title:u.title,description:u.description,icon:{src:g},category:"fluent-cart",attributes:{product_id:{type:["string","number"],default:""},variant_id:{type:"string",default:""},query_type:{type:"string",default:"default"},inside_product_info:{type:"string",default:"-"}},edit:({attributes:a,setAttributes:p,clientId:o})=>{var f;const d=L(),[c,n]=R({}),i=k.url+"/products/"+a.product_id,s=B(),e=q(l=>{const{getBlockParents:y,getBlockName:v}=l(F);return y(o).some(w=>{const x=v(w);return["fluent-cart/product-info","fluent-cart/products","fluent-cart/shopapp-product-container","fluent-cart/shopapp-product-loop","fluent-cart/product-carousel"].includes(x)})},[o]);m(()=>{p({inside_product_info:e?"yes":"no",...e?{}:{query_type:"custom"}})},[e]);const _=l=>{switch(l){case"in-stock":return r("In Stock");case"out-of-stock":return r("Out of Stock");case"backorder":return r("Available on Backorder");case"low-stock":return r("Low Stock");default:return r("Stock Availability")}},h=()=>{E({path:I(i,{with:["block_product_detail"]}),headers:{"X-WP-Nonce":k.nonce}}).then(l=>{n(l.product||{})}).finally(()=>{})};m(()=>{s!=null&&s.product&&n(s.product),!e&&a.product_id&&h()},[a.product_id,s==null?void 0:s.product]);const b=_((f=c==null?void 0:c.detail)==null?void 0:f.stock_availability)||r("Stock Availability");return t.jsxs("div",{...d,children:[e?"":t.jsx(C,{attributes:a,setAttributes:p,selectedProduct:c,setSelectedProduct:n}),t.jsx("div",{className:"fct-stock-status",children:b})]})},save:function(a){return null},supports:{html:!1,align:["left","center","right"],__experimentalBorder:{color:!0,radius:!0,style:!0,width:!0},spacing:{margin:!0,padding:!0},shadow:!0,__experimentalFilter:{duotone:!0}}});
2