• Resolved jokubas2000k

    (@jokubas2000k)


    Hi,

    I need some help with a code snippet.

    I’m using WooCommerce. I want to display the product’s short description below the product’s name at checkout.

    I found a code snippet that helps me achieve that. It allows me to display the Product short description below the product’s name at checkout.

    add_filter( 'woocommerce_get_item_data', 'wc_checkout_description_so_15127954', 10, 2 );
    function wc_checkout_description_so_15127954( $other_data, $cart_item )
    {
        $post_data = get_post( $cart_item['product_id'] );
        $other_data[] = array( 'name' =>  $post_data->post_excerpt );
        return $other_data;
    }

    However, there’s a few issues. It adds a colon (:) at the end of the description, makes the text bold and capitalizes each word.

    My product’s short description: https://ibb.co/NjD92Fv
    Result: https://ibb.co/xJFTHxh

    Could someone please help me remove the colon (:), bold style and capitalization of each word?

    Thanks in advance!

Viewing 1 replies (of 1 total)
  • I think the : is coming from wc-template-functions.php line 3648. There’s no filter on that which I can see, and any edits to core files would be overwritten by updates.

    Consider working with the : instead of trying to delete it, so

    $other_data[] = array(
      'key' => 'Description', 
      'display' =>  $post_data->post_excerpt );

    should result in:
    Description: Test Short Description

    The bold and the capitalization will be coming from styles. Look for font-weight which is used for bold, and text-transform: capitalize which is used for capitalizing each word.

    Every theme is different so for further advice on custom css to change your default styles, please post the link to your site so the styles and markup can be examined with browser tools.

Viewing 1 replies (of 1 total)
  • The topic ‘Product description at checkout’ is closed to new replies.