Skip to content
Advertisement

WooCommerce product attribute ‘Custom Product Attribute’ change text via functions.php? [closed]

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?

P.S.

See the answer below for the solution.

Advertisement

Answer

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

User contributions licensed under: CC BY-SA
4 People found this is helpful
Advertisement