WooCommerce: Echo product title in checkout

Hope you guys can help.

I’m working on a WooCommerce shop that sells software-plans for 1 product. Therefor I’ve deactivated the cart-page and made it possible only to have 1 item in the checkout (old items are automaticly removed).

Read More

What I need, is too echo out the product name in the "cart" before the checkout fields.
E.g. “Yaaay, you selected the XXXX-plan!”.

I tried to use below code from the review-order.php, but no luck.

<?php echo apply_filters( 'woocommerce_cart_item_name', $_product->get_title(), $cart_item, $cart_item_key ) . '&nbsp;'; ?>

Any ideas? Thank you in advance.

Related posts

1 comment

  1. You can use ‘woocommerce_before_checkout_billing_form’ hook or ‘woocommerce_checkout_before_order_review’ hook to add your Title for product purchased in cart.

    Basically

    add_action('woocommerce_before_checkout_billing_form','wdm_my_custom_title',10,1);
    
    function wdm_my_custom_title($checkout){
     // code to retrieve item title in cart . And echoing it with the custom title which we need.
    }
    

    Or

    add_action('woocommerce_checkout_before_order_review','wdm_my_custom_title',10);
    
    function wdm_my_custom_title(){
     // code to retrieve item title in cart . And echoing it with the custom title which we need.
    }
    

    Use one of the codes as per your requirement of location where the Title needs to be displayed.

Comments are closed.