Woocommerce产品属性与类别等层次结构

时间:2017-05-30 20:34:43

标签: php wordpress woocommerce

面对根据产品属性制作过滤器的任务。 我需要制作产品类别等属性的层次结构。 这可以实现吗?也许有人做过或知道现成的解决方案,插件等? 请告诉我......

2 个答案:

答案 0 :(得分:1)

您可以使用过滤器更改

app.get('/all', function (req, res) {
    db.query(...) LIMIT 20000;")
    .then(function (data) {
        let result = []
        data.forEach(element => {
            result.push(element)
        })

        /* make the worksheet */
        var ws = XLSX.utils.json_to_sheet(data);

        /* add to workbook */
        var wb = XLSX.utils.book_new();
        XLSX.utils.book_append_sheet(wb, ws, "All");

        XLSX.writeFile(wb, 'alltest1.xlsx'); //This saves the file in my server but I don't know how to send it as a response.

        console.log('Ready');

        res.send(result);
    })
    .catch(function (error) {
        console.log("ERROR:", error)
    })
})

其中“ pa_color”是您的属性分类名称。

答案 1 :(得分:0)

这是一个老问题,但是我碰到了这个问题,因为我不再能够在属性中添加层次结构。 似乎在较新版本的Woocommerce中,属性的层次结构已被删除。 您可以手动将它们重新添加到代码中(经过测试并在Woocommerce v3.8.1上运行)

编辑/wp-content/plugins/woocommerce/includes/class-wc-post-types.php第214行

更改:

'hierarchical'=>否,

至:

'hierarchical'=>是,

现在将启用层次结构。 显然,每当Woocommerce升级时,它将恢复为不再具有层次结构。我确定有一个可以编写的函数,但这对我来说是目前使其最快的方法。

相关问题