• Resolved gina.f

    (@ginaf)


    I have been advertising my lead times in Woocommerce by adding them in the description of each product variation. This works fine but I would like them to also be included in the order confirmation sent to the customer. Is there any way to do this based on how I have it set up?

    I’m also open to other ways of displaying lead times that would integrate into the order email easier. The only problem is that it needs to be a per variation lead time not a per product.

Viewing 2 replies - 1 through 2 (of 2 total)
  • Ahir Hemant

    (@hemant-ahir)

    The filter woocommerce_get_item_data can be used for that.

    Like so:

    add_filter( 'woocommerce_cart_item_name', 'ahir_wc_cart_item_data', 10, 3);
    function ahir_wc_cart_item_data( $item_name, $cart_item, $cart_item_key ) {
        // The label
        $label = __( 'Description', 'woocommerce' );
    
        // Get the product description
        $description = $cart_item['data']->get_description();
    
        // For product variations when description is empty
        if( $cart_item['data']->is_type('variation') && empty( $description ) ){
            // Get the parent variable product object
            $product = wc_get_product( $cart_item['data']->get_parent_id() );
            // Get the variable product description
            $description = $product->get_description();
        }
    
        if( ! empty( $description ) ){
            $item_name .= '<p class="item-description" style="margin:12px 0 0;">
                <strong>'.$label.'</strong>: <br>'.$description.'
            </p>';
        }
        return $item_name;
    }

    This way you can show description in cart, so similar way you can check for filters/actions to show in checkout and Order emails. For that you need to little bit customize.

    Thanks
    Ahir

    Hi @ginaf,

    It’s been a while since we’ve heard from you. Hopefully, the helpful snippet provided by @hemant-ahir worked for you. I’m going to mark this thread resolved. If you do have any questions, please open up a new thread.

    Thanks!

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Woocommerce Lead Times in Confirmation Emails’ is closed to new replies.