Solution for : How do you add a short description for each product to the checkout page in Woocommerce?
The filter woocommerce_get_item_data
can be used for that.
Like so:
1 2 3 4 5 6 7 8 | 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 ; } |
Note that maybe some kind of checking will be needed, e.g., make sure this filter is only called when actually viewing the Checkout page, as I don't know if it'll be called in other instances.
No comments:
Post a Comment