• Resolved 2TheMoon

    (@ruskiller777)


    Please help i cant change admin-new-order.php file to show in email header “Product $PRODUCTSOLDLIST was sold”

Viewing 12 replies - 1 through 12 (of 12 total)
  • Thread Starter 2TheMoon

    (@ruskiller777)

    sorry i meaning email Subject

    Hey,
    You can control the subject for the emails in your woocommerce > settings > emails.

    Subjects are not set in the template files so you can’t set them in the PHP templates.

    BEn

    Thread Starter 2TheMoon

    (@ruskiller777)

    add_filter(‘woocommerce_email_subject_new_order’, ‘change_admin_email_subject’, 10, 2);
    function change_admin_email_subject( $subject, $order ) {
    $products_names = $products_tags = [];

    foreach ( $order->get_items() as $item ) {
    // Get the product tags term names in an array
    $term_names = wp_get_post_terms($item->get_product_id(), ‘product_tag’, [‘fields’ => ‘names’]);

    $products_tags = array_merge($products_tags, $term_names);
    $products_names[] = $item->get_name();
    }

    return sprintf( ‘[%s] New Order (#%s): Season: %s, Item: %s from %s %s’,
    wp_specialchars_decode(get_option(‘blogname’), ENT_QUOTES),
    $order->get_order_number(),
    implode(‘, ‘, array_unique($products_tags)),
    implode(‘, ‘, array_unique($products_names)),
    $order->get_billing_first_name(),
    $order->get_billing_last_name()
    );
    }

    Thread Starter 2TheMoon

    (@ruskiller777)

    but its still working bad(

    hannah

    (@hannahritner)

    Hi @ruskiller777
    This was marked as resolved. Were you able to get it working as you’re wanting?

    Hannah

    Thread Starter 2TheMoon

    (@ruskiller777)

    no i still need help)
    want to show product name in email subject , for example “$PRODUCTNAMES” Was Sold..

    hannah

    (@hannahritner)

    Hey,
    Have you tried settings this from woocommerce > settings > emails as Ben suggested above?

    Hannah

    Thread Starter 2TheMoon

    (@ruskiller777)

    so, its no option to place product name in subject? (

    hannah

    (@hannahritner)

    Hey @ruskiller777,
    From my understanding, you would need to add in a custom function. Are you using a child theme?

    Hannah

    Thread Starter 2TheMoon

    (@ruskiller777)

    yes storefront…how to place in email subject product name?

    hannah

    (@hannahritner)

    I’ll check with the developer if there’s a simple function for this.

    Hannah

    Hey,
    Writing a custom function for this is beyond the plugin support I can offer. It’s not a feature this plugin adds or edits. However, you seem to be on the right track: https://docs.woocommerce.com/document/change-email-subject-lines/

    Perhaps you can hire a developer to code it for you if you are stuck: https://codeable.io/

    Ben

Viewing 12 replies - 1 through 12 (of 12 total)
  • The topic ‘items name in email header’ is closed to new replies.