تخطي إلى المحتوى تخطي إلى الشريط الجانبي

Waiting for author

Topic Tags: Compatibility

Overview of the issue

When using Kadence WC Email Designer with WPML, you might experience an issue where placeholders such as {site_title}, {site_address}, and {site_url} are not replaced in translated emails when they are inserted inside the email body text. These placeholders continue to work correctly in the default WooCommerce header or additional notes fields.

Workaround

Please, make sure of having a full site backup of your site before proceeding.

  • Open the …/wp-content/plugins/kadence-woocommerce-email-designer/kadence-woocommerce-email-designer.php file.
  • Look for line 375.
  • Replace:
    $body_text = str_replace( '{site_title}', get_bloginfo( 'name', 'display' ), $body_text );
    $body_text = str_replace( '{site_address}', wp_parse_url( home_url(), PHP_URL_HOST ), $body_text );
    $body_text = str_replace( '{site_url}', wp_parse_url( home_url(), PHP_URL_HOST ), $body_text );
    
    if ( $order ) {
    	if ( 0 === ( $user_id = (int) $order->get_customer_id() ) ) {
    		$user_id = 'guest';
    	}
    	if ( class_exists( 'WCML_Orders' ) ) {
    		$order_language = WCML_Orders::getLanguage( $order->get_id() );
    		if ( $order_language ) {
    			$language_code = $order_language;
    			$name   = '[kt_woomail]' . $setting_key;
    			$body_text = apply_filters( 'wpml_translate_single_string', $body_text, 'admin_texts_kt_woomail', $name, $order_language );
    		}
    	}
    	// Check for placeholders.
    	$body_text = str_replace( '{order_date}', wc_format_datetime( $order->get_date_created() ), $body_text );
    	$body_text = str_replace( '{order_number}', $order->get_order_number(), $body_text );
    	$body_text = str_replace( '{customer_first_name}', $order->get_billing_first_name(), $body_text );
    	$body_text = str_replace( '{customer_last_name}', $order->get_billing_last_name(), $body_text );
    	$body_text = str_replace( '{customer_full_name}', $order->get_formatted_billing_full_name(), $body_text );
    	$body_text = str_replace( '{customer_company}', $order->get_billing_company(), $body_text );
    	$body_text = str_replace( '{customer_email}', $order->get_billing_email(), $body_text );
    	$body_text = str_replace( '{customer_username}', self::get_username_from_id( $user_id ), $body_text );
    }
    
    $body_text = apply_filters( 'kadence_woomail_order_body_text', $body_text, $order, $sent_to_admin, $plain_text, $email );
            
  • With:
    // Moved from here
    
    if ( $order ) {
    	if ( 0 === ( $user_id = (int) $order->get_customer_id() ) ) {
    		$user_id = 'guest';
    	}
    	if ( class_exists( 'WCML_Orders' ) ) {
    		$order_language = WCML_Orders::getLanguage( $order->get_id() );
    		if ( $order_language ) {
    			$language_code = $order_language;
    			$name   = '[kt_woomail]' . $setting_key;
    			$body_text = apply_filters( 'wpml_translate_single_string', $body_text, 'admin_texts_kt_woomail', $name, $order_language );
    		}
    	}
    	// Check for placeholders.
    	$body_text = str_replace( '{order_date}', wc_format_datetime( $order->get_date_created() ), $body_text );
    	$body_text = str_replace( '{order_number}', $order->get_order_number(), $body_text );
    	$body_text = str_replace( '{customer_first_name}', $order->get_billing_first_name(), $body_text );
    	$body_text = str_replace( '{customer_last_name}', $order->get_billing_last_name(), $body_text );
    	$body_text = str_replace( '{customer_full_name}', $order->get_formatted_billing_full_name(), $body_text );
    	$body_text = str_replace( '{customer_company}', $order->get_billing_company(), $body_text );
    	$body_text = str_replace( '{customer_email}', $order->get_billing_email(), $body_text );
    	$body_text = str_replace( '{customer_username}', self::get_username_from_id( $user_id ), $body_text );
    }
    
    // To here
    $body_text = str_replace( '{site_title}', get_bloginfo( 'name', 'display' ), $body_text );
    $body_text = str_replace( '{site_address}', wp_parse_url( home_url(), PHP_URL_HOST ), $body_text );
    $body_text = str_replace( '{site_url}', wp_parse_url( home_url(), PHP_URL_HOST ), $body_text );
    
    $body_text = apply_filters( 'kadence_woomail_order_body_text', $body_text, $order, $sent_to_admin, $plain_text, $email );
            

اترك ردًا

الرجاء البقاء في الموضوع واحترام الآخرين. إذا كنت بحاجة إلى مساعدة في مشكلات غير متعلقة بهذا المنشور، استخدم منتدى الدعم الخاص بنا لبدء محادثة أو تقديم تذكرة.

يمكنك استخدام هذه الوسوم:
<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>