• Resolved toddpinil

    (@toddpinil)


    I’d like for individual item prices to be shown in my confirmation e-mails.
    The cart shows product, price, quantity and total, but then the order itself only shows quantity and (total) price. I don’t need anything fancy like a new table column.

    [Item name] . ” (” . $item_price . ” each)” would suffice.

    I’m guessing there is some simple PHP code (similar to above) that I could apply, but my PHP expertice went the way of the dodo two decades ago before everything went all OOP and hooks and stuff that I only vaguely understand.

    Thanks!

    The page I need help with: [log in to see the link]

Viewing 3 replies - 1 through 3 (of 3 total)
  • Hello,

    My PHP skills pretty much non-existent so bear with me on this if it doesn’t apply. ?? You might find what you are looking for in our documentation.

    https://docs.woocommerce.com/wc-apidocs/class-WC_Product.html

    The link above shows information the get_price(), get_regular_price(), and get_sale_price() methods. I hope that helps.

    Thanks!

    Thread Starter toddpinil

    (@toddpinil)

    Thanks. That page is really helpful. I used to code PHP, but I’m having to re-learn on the fly. I already found and modified some code for my purposes. As you mentioned, I used get_price(). I always hate it when people say “I figured it out” but don’t post an explination or code, so here’s what I’m using:

    add_filter( ‘woocommerce_order_item_name’, ‘display_variation_price_in_order’, 10, 2 );
    function display_ variation_price_in_order ( $item_name, $item ) {

    $_product = get_product( $item[‘variation_id’] ? $item[‘variation_id’] : $item[‘product_id’] );

    $_var_description =”;

    if ( $item[‘variation_id’] ) {
    $_var_description = $_product->get_price();
    }
    if($_var_description){
    return ”. $item_name .’ ($’. $_var_description.’ each)’ ;
    }else{
    return ”.$item_name;
    }
    }

    Hi,

    Thanks for replying with how you did this. Other users will likely find this very useful.

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Show individual item price in confirmations’ is closed to new replies.