This topic has 4 replies, 2 voices, and was last updated 1 years, 8 months ago ago by Rose Tyler
Hi there is there any code to display in the archive loop item? My attribute is delivery and I want to display the term of each product. Thank you
Hello, Mike Papadakis,
Thank you for getting in touch with us.
We kindly request that you provide more details regarding your request so that we can better understand your needs.
Thank you for your cooperation.
Kind Regards,
8theme team
So for explanation I have an attribute called delivery and has 2 terms inside, Greece and Only Kalamata, every product has 1 terms of these 2, so I want to display the attribute value on the products archive (shop, category etc) before the title. I have used this code but it doesn’t work
add_action( ‘woocommerce_shop_loop_item_title’, ‘ecommercehints_show_product_attributes_on_arhive_loop_item’, 1, 0 );
function ecommercehints_show_product_attributes_on_arhive_loop_item() {
global $product;
$product = wc_get_product( get_the_id() );
$product_attributes = $product->get_attributes();
$color_id = $product_attributes[‘pa_delivery’][‘options’][‘0’]; // returns the ID of the term. You will need to change ‘pa_color’ to your taxonomy attribute ID.
$color_name = get_term( $color_id )->name;
$class= $color_id == 228 ? “greekcolor” : “deliverypa”;
echo ‘‘ . $color_name . ‘‘;
};
Hello, Mike Papadakis,
We need to inform you that additional customization of code is outside the scope of our basic support.
Please provide the URL of your site, temporary wp-admin and FTP access via the Private Content area, so that we can assess what can be done to help you.
To provide wp-admin access, you can create a new user account with administrator role via the Dashboard, and provide us with the username and password via the Private Content area.
To create FTP access, please contact your hosting provider for assistance.
Kind Regards,
8theme team
You must be logged in to reply to this topic.Log in/Sign up