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 / BuyNowButtonBlockEditor.js

BuyNowButtonBlockEditor.js in FluentCart A New Era of eCommerce – Faster, Lighter, and Simpler 1.6.4, at assets/BuyNowButtonBlockEditor.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{b as r}from"./chunks/BlockEditorTranslator.js?ver=1.6.4";import{a as w}from"./chunks/index5.js?ver=1.6.4";import{S as B}from"./chunks/SelectVariationModal.js?ver=1.6.4";import{q as P,B as C}from"./chunks/Icons.js?ver=1.6.4";import{a as E}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:D}=wp.blockEditor,{PanelBody:I,CheckboxControl:F,Button:M,Card:N,CardBody:z,Flex:O,FlexItem:R,FlexBlock:T}=wp.components,{useState:W}=wp.element,q=({attributes:s,setAttributes:o,selectedVariant:e})=>{const[a,l]=W(!1),f=()=>e?t.jsx(N,{size:"small",style:{marginTop:"12px"},children:t.jsx(z,{children:t.jsxs(O,{align:"flex-start",gap:3,children:[t.jsxs(T,{children:[t.jsx("div",{style:{marginBottom:"4px",fontWeight:"600",fontSize:"13px"},children:e==null?void 0:e.variation_title}),t.jsxs("div",{style:{fontSize:"13px",color:"#757575",marginBottom:"2px"},children:[r("Price"),":",t.jsx("span",{style:{fontWeight:"600",color:"#000",marginLeft:"4px"},dangerouslySetInnerHTML:{__html:e==null?void 0:e.formatted_total}})]})]}),t.jsx(R,{children:t.jsx(M,{icon:P,label:r("Edit product selection"),isSmall:!0,onClick:()=>l(!0)})})]})})}):null;return t.jsx(D,{children:t.jsxs(I,{title:r("Product Settings"),initialOpen:!0,children:[t.jsx(F,{label:r("Enable Instant Modal Checkout"),checked:s.enable_modal_checkout||!1,onChange:i=>o({enable_modal_checkout:i}),help:r("Open checkout in a modal instead of navigating to the product page.")}),t.jsxs(t.Fragment,{children:[t.jsx("p",{children:r("Select a specific product variation for this button.","fluent-cart")}),(!e||a)&&t.jsx(B,{button:!0,isMultiple:!1,setAttributes:o,onModalClosed:i=>{let c={...i},u=Object.keys(c);o({variationsData:{...c}}),o({variant_ids:u}),l(!1)}}),e&&!a&&f()]})]})})},{useBlockProps:A,RichText:H}=wp.blockEditor,{registerBlockType:L}=wp.blocks,{useEffect:g,useState:Q}=wp.element,{useSelect:U,useDispatch:X}=wp.data,{store:x}=wp.blockEditor,p=window.fluent_cart_buy_now_button_data,y=window.fluentCartRestVars.rest,$=y.url+"/products/variants/";L(p.slug+"/"+p.name,{apiVersion:3,title:p.title,description:p.description,icon:{src:C},example:{attributes:{}},category:"fluent-cart",attributes:{variant_ids:[],variationsData:{type:[Array,Object],default:[]},query_type:{type:"string",default:"default"},enable_modal_checkout:{type:"boolean",default:!1},text:{type:"string",default:"Buy Now"},placeholder:{type:"string"}},supports:{html:!1,align:["left","center","right"],alignWide:!1,typography:{fontSize:!0,lineHeight:!0},spacing:{margin:!0,padding:!0},color:{text:!0},__experimentalBorder:{color:!0,radius:!0,style:!0,width:!0},reusable:!1,shadow:!0},edit:s=>{const{attributes:o,setAttributes:e,clientId:a}=s,{text:l,placeholder:f}=o,i=A(),c=["fluent-cart/product-info","fluent-cart/products","fluent-cart/shopapp-product-container","fluent-cart/shopapp-product-loop","fluent-cart/product-carousel"],u=U(n=>{const{getBlockParents:m,getBlockName:d}=n(x);return m(a).some(S=>c.includes(d(S)))},[a]),{removeBlock:b}=X(x);g(()=>{u&&b(a)},[u]);const[_,h]=Q({});let k=(Array.isArray(o.variationsData)?o.variationsData:[])[0]||null,v={variant_ids:o.variant_ids,with_product:!0,per_page:10,page:1,order_by:"ID",order_type:"DESC"};const j=()=>{var n;if(!((n=o.variant_ids)!=null&&n.length)){h([]),e({variationsData:[]});return}w({path:E($,{params:v}),headers:{"X-WP-Nonce":y.nonce}}).then(m=>{const d=m.variants||[];h(d),e({variationsData:d})}).finally(()=>{})};return g(()=>{j()},[o.variant_ids]),t.jsxs("div",{children:[t.jsx(q,{attributes:o,setAttributes:e,preSelectedVariations:_,selectedVariant:k}),t.jsx(H,{...s,...i,tagName:"a",className:"wp-block-button__link wp-element-button",value:l,onChange:n=>e({text:n}),placeholder:f||r("Add text…","fluent-cart"),allowedFormats:["core/bold","core/italic"]})]})},save:function(s){return null}});
2