Wordpress 在woocommerce中创建筛选器

Wordpress 在woocommerce中创建筛选器,wordpress,woocommerce,Wordpress,Woocommerce,这是我的问题,我正在wordpress上工作,使用datafeedr woocommerce importer将我的产品从datafeedr导入woocommerce。当我添加新产品集时,我会获得有关品牌的信息,但在woocommerce产品中,品牌不会显示出来。我有没有办法导入品牌并按品牌为我的产品创建过滤器?此外,我还想按商家创建一个过滤器。您需要为产品添加一个品牌属性,然后将该品牌拉入该属性,例如 <?php /* Add Brand attribute to the product

这是我的问题,我正在wordpress上工作,使用datafeedr woocommerce importer将我的产品从datafeedr导入woocommerce。当我添加新产品集时,我会获得有关品牌的信息,但在woocommerce产品中,品牌不会显示出来。我有没有办法导入品牌并按品牌为我的产品创建过滤器?此外,我还想按商家创建一个过滤器。

您需要为产品添加一个品牌属性,然后将该品牌拉入该属性,例如

<?php
/* Add Brand attribute to the product */
add_filter( 'dfrpswc_product_attributes', 'mycode_add_brand_attribute', 20, 5 );
function mycode_add_brand_attribute( $attributes, $post, $product, $set, $action ) {
    if ( isset( $product['brand'] ) ) {
        $attr = 'Brand';
        if ( !isset( $attributes[sanitize_title( $attr )] ) ) {
            $attributes[$attr]['name'] = $attr;
        }
    }
    return $attributes;
}

/**
 * Set value for "Brand" attribute.
 */
add_filter( 'dfrpswc_filter_attribute_value', 'mycode_set_brand_attribute_value', 30, 6 );
function mycode_set_brand_attribute_value( $value, $attribute, $post, $product, $set, $action ) {
    if ( isset( $product['brand'] ) ) {
        $attr = 'Brand';
        if ( $attribute == $attr ) {
            $value = $product['brand'];
        }
    }
    return $value;
}

我会尝试联系插件的创建者。谢谢Raphael,我只是想让你知道我是新来美国的,我几个月前搬家了,我正在学习英语,实际上我说法语,这样我会犯错误,我真的很感谢你的帮助。