admin管理员组文章数量:1290979
i'm familiar with wordpress plugin development and use of hook and filters. By the way i'm encountering a big lack of documentation about what i write on the title. The need is to implement a new "total box" in Woocommerce Revenue Dashboard with a custom indicator that I want to calculate in a custom way.
The problem is that i found the filter "woocommerce_analytics_revenue_select_query" to manipulate the "standard" indicators, i can also add new custom data in the object returned by the ajax stats call, but the problem remain on how to add a Custom Box.
Here what i'm talking about speaking about "BOX WITH CUSTOM FIELD":
Going in the deep of ajax calls i found that those Boxes are defined in a Javascript that is under the /wp-content/plugins/woocommerce/packages/woocomerce-admin/dist/chunks/analytics-report-revenue.js but they are fixed (or maybe the files are auto-generated on plugin's installation/upgrade). So if i un-minify the file i found on line 935:
var a = r(3),
n = r(49),
o = Object(n.applyFilters)("woocommerce_admin_revenue_report_charts", [{
key: "gross_sales",
label: Object(a.__)("Gross Sales", 'woocommerce'),
order: "desc",
orderby: "gross_sales",
type: "currency"
}, {
key: "refunds",
label: Object(a.__)("Returns", 'woocommerce'),
order: "desc",
orderby: "refunds",
type: "currency"
}, {
key: "coupons",
label: Object(a.__)("Coupons", 'woocommerce'),
order: "desc",
orderby: "coupons",
type: "currency"
}, {
key: "net_revenue",
label: Object(a.__)("Net Sales", 'woocommerce'),
orderby: "net_revenue",
type: "currency"
}, {
key: "taxes",
label: Object(a.__)("Taxes", 'woocommerce'),
order: "desc",
orderby: "taxes",
type: "currency"
}, {
key: "shipping",
label: Object(a.__)("Shipping", 'woocommerce'),
orderby: "shipping",
type: "currency"
}, {
key: "total_sales",
label: Object(a.__)("Total Sales", 'woocommerce'),
order: "desc",
orderby: "total_sales",
type: "currency"
} , **{ // added custom object
key: "custom_indicator",
label: Object(a.__)("Custom Computation", 'woocommerce'),
order: "desc",
orderby: "whatever",
type: "currency"
}**
Now, if I add another of these JSON Object i OBTAIN the the new BOX with the custom field on the dashboard, so it WORKS. The problem is that I have to work on a JS file in the STANDARD plugin, so i cannot upgrade it or re-install or i don't know if the file will be re-generated in the future by some feature. I'm looking for a "elegant way" to override/extend that file, maybe acting using some filters that allow to obtain the expected goal.
I already tried to use filters "written" in the js or that i found looking into the woocomerce code, but they are never fired during the upgrade process: woocommerce_admin_revenue_report_charts woocommerce_rest_report_revenue_stats_schema woocommerce_admin_revenue_report_advanced_filters woocommerce_admin_revenue_report_filters
Does anyone have some experience with that? I found nothing about it in the web.
The goal is to handle this custom field on a separate custom plugin that works with woocommerce without touching the standard.
Thank you
本文标签: plugin developmentPHPExtend Wordpress Woocommerce Revenue Analytics with custom field
版权声明:本文标题:plugin development - PHP - Extend Wordpress Woocommerce Revenue Analytics with custom field 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1741522492a2383272.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论