Support » Plugin: WooCommerce » Remove Variation from Product Name in Emails

  • Resolved pinballw

    (@pinballw)


    I am trying to resolve how I can remove Product Variations (Attributes/Meta) from the Product/Item title specifically when sending automated emails through WooCommerce.

    I have successfully accomplished removing these attributes from titles and listing them below in the Cart, Checkout, My Account Order History, Creating Invoices & Packing Slips (WooCommerce PDF Invoices & Packing Slips). However, when I send emails they remain (they also remain in the title on the Admin Order Details page which is annoying but not the end of the world).

    Disclaimer, I am new to WooCommerce and learning how to properly apply filters.

    From my research I feel confident that I need to adjust the woocommerce_order_item_name filter but I’m not exactly sure what I need to adjust specifically.

    I found a similar article, but it was referring to a very specific set of conditions: https://stackoverflow.com/questions/52556402/woocommerce-remove-variation-from-product-title-in-order-details-and-email

    Current Code:

    /* Woocommerce: Item Descriptions: Cart/Order - Removing attribute values from Product variation title */ 
    add_filter( 'woocommerce_product_variation_title_include_attributes', 'variation_title_not_include_attributes' ); 
    function variation_title_not_include_attributes( $boolean ){ 
    if ( ! is_cart() ) 
    $boolean = false; 
    return $boolean; 
    }
    
    /* Woocommerce: Item Descriptions: Cart/Order - Display Product variation attributes label and values in separate rows */ 
    add_filter( 'woocommerce_is_attribute_in_product_name', 'remove_attribute_in_product_name' ); 
    function remove_attribute_in_product_name( $boolean){ 
    if ( ! is_cart() ) 
    $boolean = false; 
    return $boolean; 
    }
    
    /* Woocommerce: Item Descriptions: Checkout page - Remove the quantity from the product title */ 
    add_filter( 'woocommerce_checkout_cart_item_quantity', 'remove_product_variation_qty_from_title', 10, 3 ); 
    function remove_product_variation_qty_from_title( $quantity_html, $cart_item, $cart_item_key ){ 
    if ( $cart_item['data']->is_type('variation') && is_checkout() ) 
    $quantity_html = '';
    
    return $quantity_html; 
    }
    
    /* Woocommerce: Item Descriptions: Checkout page - Add back the cart item quantity in a separate row */ 
    add_filter( 'woocommerce_get_item_data', 'filter_get_item_data', 10, 2 ); 
    function filter_get_item_data( $item_data, $cart_item ) {
    
    if ( $cart_item['data']->is_type('variation') && is_checkout() ) 
    $item_data[] = array( 
    'key' => __('QTY'), 
    'display' => $cart_item['quantity'] 
    );
    
    return $item_data; 
    }
    
    /* Woocommerce: Item Descriptions: Remove Attributes in Packing Slip & Invoice */ 
    add_filter( 'wpo_wcpdf_order_item_data', 'wpo_wcpdf_remove_variation_from_product_title', 10, 3 ); 
    function wpo_wcpdf_remove_variation_from_product_title( $item_data, $order, $template_type ) { 
    if ( !empty($item_data['product']) && $item_data['product']->is_type( 'variation' ) ) { 
    $item_data['name'] = $item_data['product']->get_title(); 
    }
    
    return $item_data; 
    }
Viewing 4 replies - 1 through 4 (of 4 total)
  • Plugin Support Jesse Pearson (a11n)

    (@jessepearson)

    Automattic Happiness Engineer

    @pinballw Were you able to find a resolution to this?

    Not all staff are developers, so we are limited in the coding help we can provide. There are developers that frequent this forum, however, I do not see that any have been able to supply a solution yet.

    Thread Starter pinballw

    (@pinballw)

    Hi Jesse

    No I was not. I have been directed to use shortcode but unfortunately I’m new to WooCommerce and the shortcode reads like a riddle to me. Any insight you have would be greatly appreciated.

    Tommy

    Plugin Support Jesse Pearson (a11n)

    (@jessepearson)

    Automattic Happiness Engineer

    @pinballw What shortcode were you directed to use? I am not aware of one to use for this purpose.

    Plugin Support Mike a11n

    (@nixiack8)

    Hi @pinballw,

    We have not heard back from you in a while, so I am going to go ahead and close this thread. If you are still experiencing issues please open a new thread and let us know.

    Cheers!

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Remove Variation from Product Name in Emails’ is closed to new replies.