简体   繁体   中英

WooCommerce product attribute 'Custom Product Attribute' change text via functions.php?

I've added a handful of Custom Product Attribute's (CPA) to a product, and all displays as expected. The main issue is that I want to add a link to the Contact page ("COUNTRIES WE SHIP TO" attribute), which I cant do via the page builder.

In other places, I've used the add_filter facility to change the text on checkout pages etc, but can't find much on hooks for product attributes and specifically CPA's. Can anybody help with an example?

Thanks.

Easy once you have a little help from your friends...

add_filter( 'woocommerce_display_product_attributes', custom_product_additional_information', 10, 2 );
function custom_product_additional_information( $product_attributes, $product ) {
    $product_attributes[ 'attribute_' . 'custom-one' ] = array(
        'label' => __('Quantity per Package'),
        'value' => __('Value 1'),
    );
    return $product_attributes;
}

Ciao

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM