Support » Plugin: WooCommerce » How to hange e-mail order details information?

  • Hi guys,

    I tried to change some code in email-order-details.php and I failed. What I wanted to achieve was to replace “Order: #9999” with “Something Else: #9999”, when a certain product is in “Something Else” category, so I changed these lines:

    <?php if ( ! $sent_to_admin ) : ?>
    	<h2><?php printf( __( 'Order #%s', 'woocommerce' ), $order->get_order_number() ); ?></h2>
    <?php else : ?>
    	<h2><a class="link" href="<?php echo esc_url( admin_url( 'post.php?post=' . $order->id . '&action=edit' ) ); ?>"><?php printf( __( 'Order #%s', 'woocommerce'), $order->get_order_number() ); ?></a> (<?php printf( '<time datetime="%s">%s</time>', date_i18n( 'c', strtotime( $order->order_date ) ), date_i18n( wc_date_format(), strtotime( $order->order_date ) ) ); ?>)</h2>
        <?php endif; ?>

    to these:

    <?php if ( ! $sent_to_admin ) { ?>
    	<h2><?php printf( __( 'Order #%s', 'woocommerce' ), $order->get_order_number() ); ?></h2>
    <?php } else if ((!$sent_to_admin) && (is_product_category('something-else'))) { ?>
    	<h2><?php printf( __( 'Something Else #%s', 'woocommerce' ), $order->get_order_number() ); ?></h2>
    <?php } else { ?>
    	<h2><a class="link" href="<?php echo esc_url( admin_url( 'post.php?post=' . $order->id . '&action=edit' ) ); ?>"><?php printf( __( 'Order #%s', 'woocommerce'), $order->get_order_number() ); ?></a> (<?php printf( '<time datetime="%s">%s</time>', date_i18n( 'c', strtotime( $order->order_date ) ), date_i18n( wc_date_format(), strtotime( $order->order_date ) ) ); ?>)</h2>
    <?php } ?>

    But whenever anyone orders the “Something Else” category product the “Order” is still being displayed instead of “Something Else”.

    Could anyone help me on this please?
    Thanksin advance, regards.

    https://wordpress.org/plugins/woocommerce/

Viewing 3 replies - 1 through 3 (of 3 total)
  • Plugin Author Mike Jolley (a11n)

    (@mikejolley)

    is_product_category is not suitable for emails -you’re not showing a product category.

    The correct thing to do would be to loop over the items in an order ($order->get_items()), however, an order can contain multiple items in multiple categories so not certain what you want to do there.

    Thread Starter Daniel

    (@junglized)

    Actually you’re right, I didn’t think of another categories possibly being mixed with products from “Something Else” category.

    So let’s consider two scenarios then:
    1. There are only items (one or more) only from “Something Else” to display “Something Else”.
    2. There are items from any other category (doesn’t matter if any product from “Something Else” is among them or not) to display “Order”.

    Can it be done that way?
    Regards.

    Plugin Author Mike Jolley (a11n)

    (@mikejolley)

    If you loop over the items first, you can set a flag if a category is present and handle it anyway you need 🙂

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘How to hange e-mail order details information?’ is closed to new replies.