• Resolved latro666

    (@latro666)


    Hi there

    I’m trying to output a product’s custom attributes in the description area e.g. just after the excerpt. I worked out how to do it with:

    $attributes = $product->get_attributes();
    $schart = $attributes['kpfitting']['value'];

    in single-product.php
    But it errors if put in short-description.php, think its because the product object isn’t set at that point or something. I started to try and figure out the template system etc but got very confused very quickly as its pretty complex.

    any help appreciated.

    https://www.ads-software.com/extend/plugins/woocommerce/

Viewing 3 replies - 1 through 3 (of 3 total)
  • Plugin Contributor royho

    (@royho)

    To use $product, you need to add it as a global. So on the top of that file you will see global $post; change it to global $post, $product;

    Now you’re able to access the $product object.

    Thread Starter latro666

    (@latro666)

    woo hoo, cheers man perfect. Always the little things.

    If your are ever in the bedfordshire area of the uk a beer rests on a pub bar for you.

    Hey guys, I can see I have come along quite late to the conversation.

    I am trying to print product attributes in the admin-new-order email.

    For example I have an attribute “Colour” with each product having a single value for this attribute, e.g. “Blue”. I want this to be printed in the admin-new-order email.

    So far I have tried adding this code to email-order-items.php:

    echo "\n" . "Test: " . get_post_meta($_product->id,'attribute_pa_colour',true);

    and have also tried your code above, but with no success so far.

    Please can you help me?

    Many thanks
    Ben

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘[Plugin: WooCommerce – excelling eCommerce] Outputting custom attributes’ is closed to new replies.