WCML_Fix_Copied_Custom_Fields_WPML353

The WooCommerce Multilingual WCML Fix Copied Custom Fields WPML353 class.

Defined (1)

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

/inc/class-wcml-fix-copied-custom-fields-wpml353.php  
  1. class WCML_Fix_Copied_Custom_Fields_WPML353{ 
  2.  
  3. public function __construct() { 
  4. //@TODO review after WPML 3.6 
  5. if ( is_admin() && version_compare( ICL_SITEPRESS_VERSION, '3.5.3', '>=' ) && version_compare( ICL_SITEPRESS_VERSION, '3.6', '<' ) ) { 
  6. add_action( 'added_post_meta', array( 
  7. $this,  
  8. 'fix_copied_custom_fields' 
  9. ), 10, 4 ); 
  10.  
  11.  
  12. public function fix_copied_custom_fields( $mid, $object_id, $meta_key, $_meta_value ) { 
  13. global $wpdb; 
  14.  
  15. if ( in_array( get_post_type( $object_id ), array( 'product', 'product_variation' ) ) ) { 
  16.  
  17. $meta_keys_to_fix = array( 
  18. '_price',  
  19. '_regular_price',  
  20. '_sale_price',  
  21. '_sku' 
  22. ); 
  23.  
  24. if ( in_array( $meta_key, $meta_keys_to_fix ) ) { 
  25.  
  26. if ( is_null( $_meta_value ) ) { 
  27. $wpdb->update( $wpdb->postmeta, array( 'meta_value' => '' ), array( 'meta_id' => $mid ) ); 
  28.  
  29.  
  30.  
  31.