PHPFixing
  • Privacy Policy
  • TOS
  • Ask Question
  • Contact Us
  • Home
  • PHP
  • Programming
  • SQL Injection
  • Web3.0

Saturday, February 5, 2022

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

 February 05, 2022     hook-woocommerce, php, woocommerce, wordpress     No comments   

Issue

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.


Solution

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



Answered By - Barton
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg
Newer Post Older Post Home

0 Comments:

Post a Comment

Note: Only a member of this blog may post a comment.

Total Pageviews

Featured Post

Why Learn PHP Programming

Why Learn PHP Programming A widely-used open source scripting language PHP is one of the most popular programming languages in the world. It...

Subscribe To

Posts
Atom
Posts
Comments
Atom
Comments

Copyright © PHPFixing