WordPress.org

Ready to get started?Download WordPress

Forums

WooCommerce - excelling eCommerce
[resolved] Outputting custom attributes (4 posts)

  1. latro666
    Member
    Posted 1 year ago #

    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.

    http://wordpress.org/extend/plugins/woocommerce/

  2. royho
    Member
    Posted 1 year ago #

    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.

  3. latro666
    Member
    Posted 1 year ago #

    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.

  4. 123brh
    Member
    Posted 1 year ago #

    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

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic

Tags

No tags yet.