File "analytics-report-products.js"

Full Path: /home/siazco/grocery.siazco.se/wp-content/plugins/woocommerce/assets/client/admin/chunks/analytics-report-products.js
File size: 16.29 KB
MIME-type: text/plain
Charset: utf-8

"use strict";(globalThis.webpackChunk_wcAdmin_webpackJsonp=globalThis.webpackChunk_wcAdmin_webpackJsonp||[]).push([[6824],{5029:(e,t,r)=>{r.d(t,{Z:()=>l});var o=r(69307),a=r(92819),s=r(55609),i=r(22629),c=r(86020),n=r(10431);class l extends o.Component{getCategoryAncestorIds(e,t){const r=[];let o=e.parent;for(;o;)r.unshift(o),o=t.get(o).parent;return r}getCategoryAncestors(e,t){const r=this.getCategoryAncestorIds(e,t);if(r.length)return 1===r.length?t.get((0,a.first)(r)).name+" › ":2===r.length?t.get((0,a.first)(r)).name+" › "+t.get((0,a.last)(r)).name+" › ":t.get((0,a.first)(r)).name+" … "+t.get((0,a.last)(r)).name+" › "}render(){const{categories:e,category:t,query:r}=this.props,a=(0,n.getPersistedQuery)(r);return t?(0,o.createElement)("div",{className:"woocommerce-table__breadcrumbs"},(0,i.decodeEntities)(this.getCategoryAncestors(t,e)),(0,o.createElement)(c.Link,{href:(0,n.getNewPath)(a,"/analytics/categories",{filter:"single_category",categories:t.id}),type:"wc-admin"},(0,i.decodeEntities)(t.name))):(0,o.createElement)(s.Spinner,null)}}},25297:(e,t,r)=>{r.d(t,{O3:()=>l,be:()=>d,u8:()=>p});var o=r(65736),a=r(92694),s=r(9818),i=r(75606),c=r(20513);const{addCesSurveyForAnalytics:n}=(0,s.dispatch)(i.STORE_KEY),l=(0,a.applyFilters)("woocommerce_admin_products_report_charts",[{key:"items_sold",label:(0,o.__)("Items sold","woocommerce"),order:"desc",orderby:"items_sold",type:"number"},{key:"net_revenue",label:(0,o.__)("Net sales","woocommerce"),order:"desc",orderby:"net_revenue",type:"currency"},{key:"orders_count",label:(0,o.__)("Orders","woocommerce"),order:"desc",orderby:"orders_count",type:"number"}]),m={label:(0,o.__)("Show","woocommerce"),staticParams:["chartType","paged","per_page"],param:"filter",showFilters:()=>!0,filters:[{label:(0,o.__)("All products","woocommerce"),value:"all"},{label:(0,o.__)("Single product","woocommerce"),value:"select_product",chartMode:"item-comparison",subFilters:[{component:"Search",value:"single_product",chartMode:"item-comparison",path:["select_product"],settings:{type:"products",param:"products",getLabels:c.oC,labels:{placeholder:(0,o.__)("Type to search for a product","woocommerce"),button:(0,o.__)("Single product","woocommerce")}}}]},{label:(0,o.__)("Comparison","woocommerce"),value:"compare-products",chartMode:"item-comparison",settings:{type:"products",param:"products",getLabels:c.oC,labels:{helpText:(0,o.__)("Check at least two products below to compare","woocommerce"),placeholder:(0,o.__)("Search for products to compare","woocommerce"),title:(0,o.__)("Compare Products","woocommerce"),update:(0,o.__)("Compare","woocommerce")},onClick:n}}]},u={showFilters:e=>"single_product"===e.filter&&!!e.products&&e["is-variable"],staticParams:["filter","products","chartType","paged","per_page"],param:"filter-variations",filters:[{label:(0,o.__)("All variations","woocommerce"),chartMode:"item-comparison",value:"all"},{label:(0,o.__)("Single variation","woocommerce"),value:"select_variation",subFilters:[{component:"Search",value:"single_variation",path:["select_variation"],settings:{type:"variations",param:"variations",getLabels:c.uC,labels:{placeholder:(0,o.__)("Type to search for a variation","woocommerce"),button:(0,o.__)("Single variation","woocommerce")}}}]},{label:(0,o.__)("Comparison","woocommerce"),chartMode:"item-comparison",value:"compare-variations",settings:{type:"variations",param:"variations",getLabels:c.uC,labels:{helpText:(0,o.__)("Check at least two variations below to compare","woocommerce"),placeholder:(0,o.__)("Search for variations to compare","woocommerce"),title:(0,o.__)("Compare Variations","woocommerce"),update:(0,o.__)("Compare","woocommerce")}}}]},d=(0,a.applyFilters)("woocommerce_admin_products_report_advanced_filters",{filters:{},title:(0,o._x)("Products Match <select/> Filters","A sentence describing filters for Products. See screen shot for context: https://cloudup.com/cSsUY9VeCVJ","woocommerce")});Object.keys(d.filters).length&&(m.filters.push({label:(0,o.__)("Advanced Filters","woocommerce"),value:"advanced"}),u.filters.push({label:(0,o.__)("Advanced Filters","woocommerce"),value:"advanced"}));const p=(0,a.applyFilters)("woocommerce_admin_products_report_filters",[m,u])},80119:(e,t,r)=>{r.r(t),r.d(t,{default:()=>w});var o=r(69307),a=r(65736),s=r(94333),i=r(7862),c=r.n(i),n=r(67221),l=r(86020),m=r(9818),u=r(25297),d=r(83573),p=r(33863),_=r(47478),y=r(80272),g=r(5938),b=r(31511);class h extends o.Component{getChartMeta(){const{query:e,isSingleProductView:t,isSingleProductVariable:r}=this.props,o="compare-products"===e.filter&&e.products&&e.products.split(",").length>1||t&&r?"item-comparison":"time-comparison";return{compareObject:t&&r?"variations":"products",itemsLabel:t&&r?(0,a.__)("%d variations","woocommerce"):(0,a.__)("%d products","woocommerce"),mode:o}}render(){const{compareObject:e,itemsLabel:t,mode:r}=this.getChartMeta(),{path:a,query:s,isError:i,isRequesting:c,isSingleProductVariable:n}=this.props;if(i)return(0,o.createElement)(l.AnalyticsError,null);const m={...s};return"item-comparison"===r&&(m.segmentby="products"===e?"product":"variation"),(0,o.createElement)(o.Fragment,null,(0,o.createElement)(b.Z,{query:s,path:a,filters:u.u8,advancedFilters:u.be,report:"products"}),(0,o.createElement)(y.Z,{mode:r,charts:u.O3,endpoint:"products",query:m,selectedChart:(0,d.Z)(s.chart,u.O3),filters:u.u8,advancedFilters:u.be}),(0,o.createElement)(_.Z,{charts:u.O3,mode:r,filters:u.u8,advancedFilters:u.be,endpoint:"products",isRequesting:c,itemsLabel:t,path:a,query:m,selectedChart:(0,d.Z)(m.chart,u.O3)}),n?(0,o.createElement)(g.Z,{baseSearchQuery:{filter:"single_product"},isRequesting:c,query:s,filters:u.u8,advancedFilters:u.be}):(0,o.createElement)(p.Z,{isRequesting:c,query:s,filters:u.u8,advancedFilters:u.be}))}}h.propTypes={path:c().string.isRequired,query:c().object.isRequired};const w=(0,s.compose)((0,m.withSelect)(((e,t)=>{const{query:r,isRequesting:o}=t,a=!r.search&&r.products&&1===r.products.split(",").length,{getItems:s,isResolving:i,getItemsError:c}=e(n.ITEMS_STORE_NAME);if(o)return{query:{...r},isSingleProductView:a,isRequesting:o};if(a){const e=parseInt(r.products,10),t={include:e},o=s("products",t),n=o&&o.get(e)&&"variable"===o.get(e).type,l=i("getItems",["products",t]),m=Boolean(c("products",t));return{query:{...r,"is-variable":n},isSingleProductView:a,isRequesting:l,isSingleProductVariable:n,isError:m}}return{query:r,isSingleProductView:a}})))(h)},33863:(e,t,r)=>{r.d(t,{Z:()=>C});var o=r(69307),a=r(65736),s=r(94333),i=r(22629),c=r(9818),n=r(92819),l=r(10431),m=r(86020),u=r(81595),d=r(74617),p=r(67221),_=r(17844),y=r(5029),g=r(46358),b=r(42968),h=r(17062);const w=(0,h.O3)("manageStock","no"),v=(0,h.O3)("stockStatuses",{});class f extends o.Component{constructor(){super(),this.getHeadersContent=this.getHeadersContent.bind(this),this.getRowsContent=this.getRowsContent.bind(this),this.getSummary=this.getSummary.bind(this)}getHeadersContent(){return[{label:(0,a.__)("Product title","woocommerce"),key:"product_name",required:!0,isLeftAligned:!0,isSortable:!0},{label:(0,a.__)("SKU","woocommerce"),key:"sku",hiddenByDefault:!0,isSortable:!0},{label:(0,a.__)("Items sold","woocommerce"),key:"items_sold",required:!0,defaultSort:!0,isSortable:!0,isNumeric:!0},{label:(0,a.__)("Net sales","woocommerce"),screenReaderLabel:(0,a.__)("Net sales","woocommerce"),key:"net_revenue",required:!0,isSortable:!0,isNumeric:!0},{label:(0,a.__)("Orders","woocommerce"),key:"orders_count",isSortable:!0,isNumeric:!0},{label:(0,a.__)("Category","woocommerce"),key:"product_cat"},{label:(0,a.__)("Variations","woocommerce"),key:"variations",isSortable:!0},"yes"===w?{label:(0,a.__)("Status","woocommerce"),key:"stock_status"}:null,"yes"===w?{label:(0,a.__)("Stock","woocommerce"),key:"stock",isNumeric:!0}:null].filter(Boolean)}getRowsContent(e=[]){const{query:t}=this.props,r=(0,l.getPersistedQuery)(t),{render:s,formatDecimal:c,getCurrencyConfig:p}=this.context,_=p();return(0,n.map)(e,(e=>{const{product_id:n,items_sold:p,net_revenue:b,orders_count:h}=e,f=e.extended_info||{},{category_ids:C,low_stock_amount:S,manage_stock:k,sku:E,stock_status:q,stock_quantity:A,variations:P=[]}=f,N=(0,i.decodeEntities)(f.name),R=(0,l.getNewPath)(r,"/analytics/orders",{filter:"advanced",product_includes:n}),x=(0,l.getNewPath)(r,"/analytics/products",{filter:"single_product",products:n}),{categories:F}=this.props,V=C&&F&&C.map((e=>F.get(e))).filter(Boolean)||[],I=(0,g.d)(q,A,S)?(0,o.createElement)(m.Link,{href:(0,d.getAdminLink)("post.php?action=edit&post="+n),type:"wp-admin"},(0,a._x)("Low","Indication of a low quantity","woocommerce")):v[q];return[{display:(0,o.createElement)(m.Link,{href:x,type:"wc-admin"},N),value:N},{display:E,value:E},{display:(0,u.formatValue)(_,"number",p),value:p},{display:s(b),value:c(b)},{display:(0,o.createElement)(m.Link,{href:R,type:"wc-admin"},h),value:h},{display:(0,o.createElement)("div",{className:"woocommerce-table__product-categories"},V[0]&&(0,o.createElement)(y.Z,{category:V[0],categories:F}),V.length>1&&(0,o.createElement)(m.Tag,{label:(0,a.sprintf)((0,a._x)("+%d more","categories","woocommerce"),V.length-1),popoverContents:V.map((e=>(0,o.createElement)(y.Z,{category:e,categories:F,key:e.id,query:t})))})),value:V.map((e=>e.name)).join(", ")},{display:(0,u.formatValue)(_,"number",P.length),value:P.length},"yes"===w?{display:k?I:(0,a.__)("N/A","woocommerce"),value:k?v[q]:null}:null,"yes"===w?{display:k?(0,u.formatValue)(_,"number",A):(0,a.__)("N/A","woocommerce"),value:A}:null].filter(Boolean)}))}getSummary(e){const{products_count:t=0,items_sold:r=0,net_revenue:o=0,orders_count:s=0}=e,{formatAmount:i,getCurrencyConfig:c}=this.context,n=c();return[{label:(0,a._n)("Product","Products",t,"woocommerce"),value:(0,u.formatValue)(n,"number",t)},{label:(0,a._n)("Item sold","Items sold",r,"woocommerce"),value:(0,u.formatValue)(n,"number",r)},{label:(0,a.__)("Net sales","woocommerce"),value:i(o)},{label:(0,a._n)("Order","Orders",s,"woocommerce"),value:(0,u.formatValue)(n,"number",s)}]}render(){const{advancedFilters:e,baseSearchQuery:t,filters:r,hideCompare:s,isRequesting:i,query:c}=this.props,n={helpText:(0,a.__)("Check at least two products below to compare","woocommerce"),placeholder:(0,a.__)("Search by product name or SKU","woocommerce")};return(0,o.createElement)(b.Z,{compareBy:s?void 0:"products",endpoint:"products",getHeadersContent:this.getHeadersContent,getRowsContent:this.getRowsContent,getSummary:this.getSummary,summaryFields:["products_count","items_sold","net_revenue","orders_count"],itemIdField:"product_id",isRequesting:i,labels:n,query:c,searchBy:"products",baseSearchQuery:t,tableQuery:{orderby:c.orderby||"items_sold",order:c.order||"desc",extended_info:!0,segmentby:c.segmentby},title:(0,a.__)("Products","woocommerce"),columnPrefsKey:"products_report_columns",filters:r,advancedFilters:e})}}f.contextType=_.CurrencyContext;const C=(0,s.compose)((0,c.withSelect)(((e,t)=>{const{query:r,isRequesting:o}=t,{getItems:a,getItemsError:s,isResolving:i}=e(p.ITEMS_STORE_NAME);if(o||r.search&&(!r.products||!r.products.length))return{};const c={per_page:-1};return{categories:a("categories",c),isError:Boolean(s("categories",c)),isRequesting:i("getItems",["categories",c])}})))(f)},46358:(e,t,r)=>{function o(e,t,r){return!!t&&e&&t<=r==="instock"}r.d(t,{d:()=>o})},86806:(e,t,r)=>{r.d(t,{I:()=>a});var o=r(65736);function a(e){return[e.country,e.state,e.name||(0,o.__)("TAX","woocommerce"),e.priority].map((e=>e.toString().toUpperCase().trim())).filter(Boolean).join("-")}},5938:(e,t,r)=>{r.d(t,{Z:()=>w});var o=r(69307),a=r(65736),s=r(92694),i=r(92819),c=r(86020),n=r(10431),l=r(81595),m=r(74617),u=r(17844),d=r(42968),p=r(46358),_=r(20513),y=r(17062);const g=(0,y.O3)("manageStock","no"),b=(0,y.O3)("stockStatuses",{});class h extends o.Component{constructor(){super(),this.getHeadersContent=this.getHeadersContent.bind(this),this.getRowsContent=this.getRowsContent.bind(this),this.getSummary=this.getSummary.bind(this)}getHeadersContent(){return[{label:(0,a.__)("Product / Variation title","woocommerce"),key:"name",required:!0,isLeftAligned:!0},{label:(0,a.__)("SKU","woocommerce"),key:"sku",hiddenByDefault:!0,isSortable:!0},{label:(0,a.__)("Items sold","woocommerce"),key:"items_sold",required:!0,defaultSort:!0,isSortable:!0,isNumeric:!0},{label:(0,a.__)("Net sales","woocommerce"),screenReaderLabel:(0,a.__)("Net sales","woocommerce"),key:"net_revenue",required:!0,isSortable:!0,isNumeric:!0},{label:(0,a.__)("Orders","woocommerce"),key:"orders_count",isSortable:!0,isNumeric:!0},"yes"===g?{label:(0,a.__)("Status","woocommerce"),key:"stock_status"}:null,"yes"===g?{label:(0,a.__)("Stock","woocommerce"),key:"stock",isNumeric:!0}:null].filter(Boolean)}getRowsContent(e=[]){const{query:t}=this.props,r=(0,n.getPersistedQuery)(t),{formatAmount:s,formatDecimal:u,getCurrencyConfig:d}=this.context;return(0,i.map)(e,(e=>{const{items_sold:t,net_revenue:i,orders_count:y,product_id:h,variation_id:w}=e,v=e.extended_info||{},{stock_status:f,stock_quantity:C,low_stock_amount:S,deleted:k,sku:E}=v,q=(A=e,(0,_.V1)(A.extended_info||{}));var A;const P=(0,n.getNewPath)(r,"/analytics/orders",{filter:"advanced",variation_includes:w}),N=(0,m.getAdminLink)(`post.php?post=${h}&action=edit`);return[{display:k?q+" "+(0,a.__)("(Deleted)","woocommerce"):(0,o.createElement)(c.Link,{href:N,type:"wp-admin"},q),value:q},{display:E,value:E},{display:(0,l.formatValue)(d(),"number",t),value:t},{display:s(i),value:u(i)},{display:(0,o.createElement)(c.Link,{href:P,type:"wc-admin"},y),value:y},"yes"===g?{display:(0,p.d)(f,C,S)?(0,o.createElement)(c.Link,{href:N,type:"wp-admin"},(0,a._x)("Low","Indication of a low quantity","woocommerce")):b[f],value:b[f]}:null,"yes"===g?{display:C,value:C}:null].filter(Boolean)}))}getSummary(e){const{query:t}=this.props,{variations_count:r=0,items_sold:o=0,net_revenue:i=0,orders_count:c=0}=e,{formatAmount:n,getCurrencyConfig:m}=this.context,u=m();return[{label:(0,s.applyFilters)("experimental_woocommerce_admin_variations_report_table_summary_variations_count_label",(0,a._n)("variation sold","variations sold",r,"woocommerce"),r,t),value:(0,l.formatValue)(u,"number",r)},{label:(0,a._n)("item sold","items sold",o,"woocommerce"),value:(0,l.formatValue)(u,"number",o)},{label:(0,a.__)("net sales","woocommerce"),value:n(i)},{label:(0,a._n)("orders","orders",c,"woocommerce"),value:(0,l.formatValue)(u,"number",c)}]}render(){const{advancedFilters:e,baseSearchQuery:t,filters:r,isRequesting:i,query:c}=this.props,n={helpText:(0,a.__)("Check at least two variations below to compare","woocommerce"),placeholder:(0,a.__)("Search by variation name or SKU","woocommerce")};return(0,o.createElement)(d.Z,{baseSearchQuery:t,compareBy:"variations",compareParam:"filter-variations",endpoint:"variations",getHeadersContent:this.getHeadersContent,getRowsContent:this.getRowsContent,isRequesting:i,itemIdField:"variation_id",labels:n,query:c,getSummary:this.getSummary,summaryFields:["variations_count","items_sold","net_revenue","orders_count"],tableQuery:{orderby:c.orderby||"items_sold",order:c.order||"desc",extended_info:!0,product_includes:c.product_includes,variations:c.variations},title:(0,s.applyFilters)("experimental_woocommerce_admin_variations_report_table_title",(0,a.__)("Variations","woocommerce"),c),columnPrefsKey:"variations_report_columns",filters:r,advancedFilters:e})}}h.contextType=u.CurrencyContext;const w=h},20513:(e,t,r)=>{r.d(t,{FI:()=>b,V1:()=>h,YC:()=>p,hQ:()=>_,jk:()=>y,oC:()=>g,qc:()=>d,uC:()=>w});var o=r(65736),a=r(96483),s=r(86989),i=r.n(s),c=r(92819),n=r(10431),l=r(67221),m=r(86806),u=r(17062);function d(e,t=c.identity){return function(r="",o){const s="function"==typeof e?e(o):e,c=(0,n.getIdsFromQuery)(r);if(c.length<1)return Promise.resolve([]);const l={include:c.join(","),per_page:c.length};return i()({path:(0,a.addQueryArgs)(s,l)}).then((e=>e.map(t)))}}d(l.NAMESPACE+"/products/attributes",(e=>({key:e.id,label:e.name})));const p=d(l.NAMESPACE+"/products/categories",(e=>({key:e.id,label:e.name}))),_=d(l.NAMESPACE+"/coupons",(e=>({key:e.id,label:e.code}))),y=d(l.NAMESPACE+"/customers",(e=>({key:e.id,label:e.name}))),g=d(l.NAMESPACE+"/products",(e=>({key:e.id,label:e.name}))),b=d(l.NAMESPACE+"/taxes",(e=>({key:e.id,label:(0,m.I)(e)})));function h({attributes:e,name:t}){const r=(0,u.O3)("variationTitleAttributesSeparator"," - ");if(t&&t.indexOf(r)>-1)return t;const a=(e||[]).map((({name:e,option:t})=>(t||(e=e.charAt(0).toUpperCase()+e.slice(1),t=(0,o.sprintf)((0,o.__)("Any %s","woocommerce"),e)),t))).join(", ");return a?t+r+a:t}const w=d((({products:e})=>e?l.NAMESPACE+`/products/${e}/variations`:l.NAMESPACE+"/variations"),(e=>({key:e.id,label:h(e)})))}}]);