在woocommerce中查看自定义属性

在woocommerce中查看自定义属性

问题描述:

this is my code and I have added custom attributes in the product edit page. an attribute for example, the name : id value : 3421

This is my code :

<?php
    $size = sizeof( get_the_terms( $post->ID, 'product_tag' ) );
    echo $product->get_tags( ', ', '<span class="tagged_as">' . _n( 'Tag:', 'Tags:', $size, 'woocommerce' ) . ' ', '.</span>' );
    global $product;
    $attributes = $product->get_attributes();
    echo 'Enter Id Here';
?>

and where I echo enter id here I want the id to shown. I tired to reach for the id from the attributes variable I created and it didn't work. any suggestions?

try this:

$result = array_shift(woocommerce_get_product_terms($product->id, 'pa_koostis', 'names'));