PluginProbe
FluentCart A New Era of eCommerce – Faster, Lighter, and Simpler / 1.5.5
FluentCart A New Era of eCommerce – Faster, Lighter, and Simpler v1.5.5
1.6.6 1.6.5 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 All 49 releases
fluent-cart / assets / BuySectionBlockEditor.js

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

2 lines 5.8 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 import{j as t,b as a}from"./chunks/BlockEditorTranslator.js?ver=1.5.5";import{a as B}from"./chunks/index5.js?ver=1.5.5";import{E as C}from"./chunks/EditorPanel.js?ver=1.5.5";import{E as v}from"./chunks/EditorPanelRow.js?ver=1.5.5";import{C as E}from"./chunks/CustomSelect.js?ver=1.5.5";import{S as q}from"./chunks/SelectProductModal.js?ver=1.5.5";import{B as L}from"./chunks/Icons.js?ver=1.5.5";import{a as M}from"./chunks/add-query-args.js?ver=1.5.5";import"./chunks/index6.js?ver=1.5.5";import"./chunks/ProductListItem.js?ver=1.5.5";const{InspectorControls:I}=wp.blockEditor,$=({attributes:r,setAttributes:c,selectedProduct:o,setSelectedProduct:d})=>t.jsx(I,{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.jsxs(C,{title:a("Product"),children:[t.jsxs(v,{children:[t.jsx("span",{className:"fct-inspector-control-label",children:a("Query type")}),t.jsx("div",{className:"actions",children:t.jsx(E,{customKeys:{key:"value",label:"label"},defaultValue:r.query_type,options:[{label:a("Default"),value:"default"},{label:a("Custom"),value:"custom"}],onChange:function(e){c({query_type:e})}})})]}),r.query_type==="custom"&&t.jsxs(v,{className:"flex-col",children:[t.jsx(q,{onModalClosed:e=>{c({product_id:e.ID||""}),d(e)},selectedProduct:o,setSelectedProduct:d,isMultiple:!1}),o&&t.jsxs("div",{className:"fct-selected-variation-info w-full",children:[t.jsx("strong",{children:a("Selected product:")}),t.jsx("p",{children:o.post_title})]})]})]})})})})}),{createContext:R,useContext:D}=wp.element,g=R();g.Provider;const F=()=>{const r=D(g);return r||(console.warn("useSingleProductData must be used within a SingleProductDataProvider"),null)},Q=""+new URL("assets/BuySection.png",import.meta.url).href,{useBlockProps:V}=wp.blockEditor,{registerBlockType:W}=wp.blocks,{useEffect:j,useState:U}=wp.element,{useSelect:z}=wp.data,{store:K}=wp.blockEditor,l=window.fluent_cart_buy_section_data,y=l.placeholder_image,w=window.fluentCartRestVars.rest;W(l.slug+"/"+l.name,{apiVersion:3,title:l.title,description:l.description,icon:{src:L},example:{attributes:{},innerBlocks:[{name:"core/image",attributes:{url:Q,alt:"Buy Section Preview",style:{width:"100%",height:"auto"}}}]},category:"fluent-cart",attributes:{product_id:{type:["string","number"],default:""},query_type:{type:"string",default:"default"},inside_product_info:{type:"string",default:"-"}},edit:({attributes:r,setAttributes:c,clientId:o})=>{var m,f,h,x;const d=V(),[e,u]=U({}),N=w.url+"/products/"+r.product_id,i=F(),p=z(s=>{const{getBlockParents:n,getBlockName:b}=s(K);return n(o).some(k=>{const S=b(k);return["fluent-cart/product-info","fluent-cart/product-carousel"].includes(S)})},[o]);c({inside_product_info:p?"yes":"no"});const _=()=>{B({path:M(N,{with:["variants"]}),headers:{"X-WP-Nonce":w.nonce}}).then(s=>{u(s.product||{})}).finally(()=>{})};return j(()=>{i!=null&&i.product&&u(i.product)},[i==null?void 0:i.product]),j(()=>{p||_()},[r.product_id]),t.jsxs("div",{...d,children:[p?"":t.jsx($,{attributes:r,setAttributes:c,selectedProduct:e,setSelectedProduct:u}),t.jsxs("div",{className:"fct_buy_section",children:[(e==null?void 0:e.variants)&&new Set(e.variants.map(s=>{var n;return(n=s.other_info)==null?void 0:n.payment_type})).size>1&&t.jsx("div",{className:"fct-product-tab-nav",children:[...new Set(e.variants.map(s=>{var n;return(n=s.other_info)==null?void 0:n.payment_type}))].filter(Boolean).map((s,n)=>t.jsx("div",{className:`fct-product-tab-nav-item ${n===0?"active":""}`,children:s},s))}),t.jsx("div",{className:"fct-product-variants",children:(m=e==null?void 0:e.variants)!=null&&m.length?e.variants.map((s,n)=>t.jsx("div",{className:`fct-product-variant-item ${n===0?"selected":""}`,children:t.jsxs("div",{className:"variant-content",children:[t.jsx("div",{className:"fct-product-variant-image",children:t.jsx("img",{src:s.thumbnail??y,alt:s.variation_title??""})}),t.jsx("div",{className:"fct-product-variant-title",children:s.variation_title??a("Select a product")})]})},s.id??n)):t.jsx("div",{className:"fct-product-variant-item",children:t.jsxs("div",{className:"variant-content",children:[t.jsx("div",{className:"fct-product-variant-image",children:t.jsx("img",{src:((h=(f=e==null?void 0:e.detail)==null?void 0:f.featured_media)==null?void 0:h.url)??y,alt:(e==null?void 0:e.post_title)??""})}),t.jsx("div",{className:"fct-product-variant-title",children:(e==null?void 0:e.post_title)??a("Select a product")})]})})}),t.jsx("div",{className:"fct-product-item-price",children:(x=e==null?void 0:e.variants)!=null&&x[0]?`$${parseFloat((e.variants[0].item_price/100).toFixed(2))}`:"$0"}),t.jsxs("div",{className:"fct-product-quantity-container",children:[t.jsx("h5",{className:"quantity-title",children:a("Quantity")}),t.jsxs("div",{className:"fct-product-quantity",children:[t.jsx("button",{className:"fct-quantity-decrease-button",children:t.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",width:"14",height:"2",viewBox:"0 0 14 2",fill:"none",children:t.jsx("path",{d:"M12.3333 1L1.66659 1",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})})}),t.jsx("input",{type:"text",className:"fct-quantity-input",value:"1",min:"1",max:"10000"}),t.jsx("button",{className:"fct-quantity-increase-button",children:t.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",width:"14",height:"14",viewBox:"0 0 14 14",fill:"none",children:t.jsx("path",{d:"M6.99996 1.66666L6.99996 12.3333M12.3333 6.99999L1.66663 6.99999",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})})})]})]}),t.jsxs("div",{className:"fct-product-buttons-wrap",children:[t.jsx("button",{className:"fluent-cart-direct-checkout-button",children:a("Buy Now")}),t.jsx("button",{className:"fluent-cart-add-to-cart-button",children:a("Add To Cart")})]})]})]})},save:function(r){return null}});
2