wc_gzd_cart_product_item_desc

Appends product item desc live data (while checkout) or order meta to product name.

Description

(string) wc_gzd_cart_product_item_desc( (string) $title, (array) $cart_item, (string) $cart_item_key = '' ); 

Returns (string)

Parameters (3)

0. $title (string)
The title.
1. $cart_item (array)
The cart item.
2. $cart_item_key — Optional. (string) => ''
The cart item key.

Usage

  1. if ( !function_exists( 'wc_gzd_cart_product_item_desc' ) ) { 
  2. require_once ABSPATH . PLUGINDIR . 'woocommerce-germanized/includes/wc-gzd-cart-functions.php'; 
  3.  
  4. // The title. 
  5. $title = ''; 
  6.  
  7. // The cart item. 
  8. $cart_item = array(); 
  9.  
  10. // The cart item key. 
  11. $cart_item_key = ''; 
  12.  
  13. // NOTICE! Understand what this does before running. 
  14. $result = wc_gzd_cart_product_item_desc($title, $cart_item, $cart_item_key); 
  15.  

Defined (1)

The function is defined in the following location(s).

/includes/wc-gzd-cart-functions.php  
  1. function wc_gzd_cart_product_item_desc( $title, $cart_item, $cart_item_key = '' ) { 
  2.  
  3. $product_desc = ""; 
  4.  
  5. if ( isset( $cart_item[ 'data' ] ) ) { 
  6.  
  7. $product = apply_filters( 'woocommerce_cart_item_product', $cart_item[ 'data' ], $cart_item, $cart_item_key ); 
  8.  
  9. if ( wc_gzd_get_gzd_product( $product )->get_mini_desc() ) 
  10. $product_desc = wc_gzd_get_gzd_product( $product )->get_mini_desc(); 
  11.  
  12. } elseif ( isset( $cart_item[ 'item_desc' ] ) ) { 
  13.  
  14. $product_desc = $cart_item[ 'item_desc' ]; 
  15.  
  16. } elseif ( isset( $cart_item[ 'product_id' ] ) ) { 
  17.  
  18. $product = wc_get_product( ! empty( $cart_item[ 'variation_id' ] ) ? $cart_item[ 'variation_id' ] : $cart_item[ 'product_id' ] ); 
  19.  
  20. if ( $product && wc_gzd_get_gzd_product( $product )->get_mini_desc() ) 
  21. $product_desc = wc_gzd_get_gzd_product( $product )->get_mini_desc(); 
  22.  
  23.  
  24. if ( ! empty( $product_desc ) ) 
  25. $title .= '<div class="wc-gzd-item-desc item-desc">' . do_shortcode( $product_desc ) . '</div>'; 
  26.  
  27. return $title;