• Hi,

    I would like to display the product attribute instead of the name if variation exist in cart, checkout and emails sent,

    So, in cart.php I identify :
    if ( ! $product_permalink ) {
    echo apply_filters( ‘woocommerce_cart_item_name’, $_product->get_title(), $cart_item, $cart_item_key ) . ‘ ‘;
    } else {
    echo apply_filters( ‘woocommerce_cart_item_name’, sprintf( ‘%s‘, esc_url( $product_permalink ), $_product->get_title() ), $cart_item, $cart_item_key );
    }

    And I print the attributes :

    $attributes = $_product->get_attributes();
    print_r($attributes);

    but it gives me the array with [pa_couleurs], but I can’t find how to print the attribute name,

    Can anyone help me please ?

    Thanks in advance,

Viewing 1 replies (of 1 total)
  • Thread Starter alguna

    (@alguna)

    Finally found the solution, if it can help anyone :

    $colo = array_shift( wc_get_product_terms( $_product->id, ‘pa_couleurs’, array( ‘fields’ => ‘names’ ) ) );
    echo $colo;

Viewing 1 replies (of 1 total)
  • The topic ‘display attribute name’ is closed to new replies.