wc_gzd_cart_product_delivery_time

Appends delivery time live data (while checkout) or order meta to product name.

Description

(string) wc_gzd_cart_product_delivery_time( (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_delivery_time' ) ) { 
  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_delivery_time($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_delivery_time( $title, $cart_item, $cart_item_key = '' ) { 
  2.  
  3. $delivery_time = ""; 
  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_delivery_time_term() ) 
  10. $delivery_time = wc_gzd_get_gzd_product( $product )->get_delivery_time_html(); 
  11.  
  12. } elseif ( isset( $cart_item[ 'delivery_time' ] ) ) { 
  13.  
  14. $delivery_time = $cart_item[ 'delivery_time' ]; 
  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_delivery_time_term() ) 
  21. $delivery_time = wc_gzd_get_gzd_product( $product )->get_delivery_time_html(); 
  22.  
  23.  
  24. if ( ! empty( $delivery_time ) ) 
  25. $title .= '<p class="delivery-time-info">' . $delivery_time . '</p>'; 
  26.  
  27. return $title;