0 ) { $dfLanguage = wpml_get_default_language(); foreach( $values as $key => $val ) { $values[ $key ] = icl_object_id( $val, 'product_cat', true, $dfLanguage ); } } return $values; } /** * Convert Product ID to Default language ID * @param $value = array */ public function wpml_comparison_tertiary_product_filter($value = array()){ if( function_exists( 'icl_object_id' ) && function_exists( 'wpml_get_default_language' ) && is_array( $value ) && count($value) > 0 ) { $default_lg = wpml_get_default_language(); foreach( $value as $key => $val ) { $value[ $key ] = icl_object_id( $val, 'product', true, $default_lg ); } } return $value; } /** * Acotrs Shipping class compatibility * @param $values array */ public function wpml_settings_shipping_class_filter($value ){ if( function_exists( 'icl_object_id' ) && function_exists( 'wpml_get_default_language' ) && $value ) { $default_language = wpml_get_default_language(); if( is_array( $value ) && count($value) > 0 ) { foreach( $value as $key => $val ) { $value[ $key ] = icl_object_id( $val, 'product_shipping_class', true, $default_language ); } } else { return icl_object_id( $value, 'product_shipping_class', true, $default_language ); } } return $value; } /** * Calculate shipping funciton * @param string */ public function wpml_price_currency_conversation($value){ return apply_filters( 'wcml_raw_price_amount', $value ); } function wpml_get_translated_shipping_label( $available_methods ) { // check for WPML translation function if( ! function_exists( 'icl_t' ) ) return $available_methods; // cycle through methods foreach( $available_methods as $key => $method ) { // only follow through for this method if( $method->method_id !== 'acotrs_shipping' ) continue; // sanitize vars $sanitized_label = sanitize_title( $method->label ); $instance_id = intval( $method->instance_id ); list( $method_id, $option_id ) = explode( '-', sanitize_text_field( $method->id ) ); // determine which translation to use $trans_label = icl_t( 'acotrs_labels', 'option_title-' . $sanitized_label, $method->label ); $trans_instance = icl_t( 'acotrs_labels', 'instance_' . $instance_id . '-option_' . $option_id, $method->label ); if( $trans_label != $method->label && $trans_instance == $method->label ) { $available_methods[ $key ]->label = $trans_label; } else { $available_methods[ $key ]->label = $trans_instance; } } return $available_methods; } } new ACOTRCOMPATIBILITY_Wpml(); } }