yit_set_prop

The YITH WooCommerce Wishlist yit set prop function.

Description

yit_set_prop( $object, $arg1, (bool) $arg2 = false ); 

Parameters (3)

0. $object
The object.
1. $arg1
The arg1.
2. $arg2 — Optional. (bool) => false
The arg2.

Usage

  1. if ( !function_exists( 'yit_set_prop' ) ) { 
  2. require_once ABSPATH . PLUGINDIR . 'yith-woocommerce-wishlist/plugin-fw/yit-woocommerce-compatibility.php'; 
  3.  
  4. // The object. 
  5. $object = null; 
  6.  
  7. // The arg1. 
  8. $arg1 = null; 
  9.  
  10. // The arg2. 
  11. $arg2 = false; 
  12.  
  13. // NOTICE! Understand what this does before running. 
  14. $result = yit_set_prop($object, $arg1, $arg2); 
  15.  

Defined (1)

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

/plugin-fw/yit-woocommerce-compatibility.php  
  1. function yit_set_prop( $object, $arg1, $arg2 = false ) { 
  2.  
  3. if ( !is_array( $arg1 ) ) { 
  4. $arg1 = array( 
  5. $arg1 => $arg2 
  6. ); 
  7.  
  8. $is_wc_data = $object instanceof WC_Data; 
  9.  
  10. foreach ( $arg1 as $key => $value ) { 
  11. if ( $is_wc_data ) { 
  12. $key = ( array_key_exists( $key, $prop_map ) ) ? $prop_map[ $key ] : $key; 
  13.  
  14. if ( ( $setter = "set{$key}" ) && method_exists( $object, $setter ) ) { 
  15. $object->$setter( $value ); 
  16. } elseif ( ( $setter = "set_{$key}" ) && method_exists( $object, $setter ) ) { 
  17. $object->$setter( $value ); 
  18. } else { 
  19. $object->update_meta_data( $key, $value ); 
  20. } else { 
  21. $key = ( in_array( $key, $prop_map ) ) ? array_search( $key, $prop_map ) : $key; 
  22. ( strpos( $key, '_' ) === 0 ) && $key = substr( $key, 1 ); 
  23.  
  24. if ( yit_wc_check_post_columns( $key ) ) { 
  25. $object->post->$key = $value; 
  26. } else { 
  27. $object->$key = $value;