This is the technical support forum for WPML - the multilingual WordPress plugin.

Everyone can read, but only WPML clients can post here. WPML team is replying on the forum 6 days per week, 22 hours per day.

This topic contains 10 replies, has 3 voices.

Last updated by Itamar 1 year ago.

Assigned support staff: Itamar.

Author Posts
October 7, 2018 at 6:25 pm #2794118

Jacek

Tell us what you are trying to do?
Im trying to use shortcode of Contact Form 7 in string translation field, but on the website I don't see the contact form, but shortcode. Is any way to execute it?

Is there any documentation that you are following?
no

Is there a similar example that we can see?
no

What is the link to your site?

October 8, 2018 at 5:40 am #2794785

Riffaz
Supporter

Languages: English (English )

Timezone: Asia/Colombo (GMT+05:30)

Hi,

Thank you for contacting WPML support.

You do not have to use string translation to translate your CF7 forms.

1. To translate the form, duplicate it and translate the textual contents in the duplicated form. You can translate every element of the form, including the title, mail, and other settings.

2. Navigate to Contact -> Contact Forms page to see a list of all the created forms.
Hover over English (if your primary language is English) Contact Form—the one you created in your primary language—and click on the Duplicate link and start to translate the form fields.

Please refer this for the details steps: https://wpml.org/documentation/plugins-compatibility/using-contact-form-7-with-wpml/

Let me know if you have any other questions regarding this.

Regards,
Riffaz.

October 8, 2018 at 6:16 am #2794806

Jacek

It's not resolve my trouble.
I need to execute shortcode in string translation.

Look on this product page

login: webadmin1
hasło: Webadmin1

hidden link

Red text: [contact-form-7 id="319" title="askaboutproduktde"]

was added to String-translation, but it will not to show contact form, only shortcode

How to show contact form?

October 8, 2018 at 7:08 am #2794873

Riffaz
Supporter

Languages: English (English )

Timezone: Asia/Colombo (GMT+05:30)

Hi,

I could not replicate this issue in my local installation.

Important:
When you duplicate the form to your second language you will get another form with a different form ID.
You have to use that shortcode in your secondary languages.
This will have it's own ID and title.
Like this: hidden link

I am not sure why you are having this in "string translation"

How did you add this shortcode to your secondary language product?
using any page builder element? via custom PHP code? or copied the shortcode and pasted in the product editor?

I would eventually also need to request temporary access (WP-Admin) to your site
– preferably to a test site/temporary user where the problem has been replicated if possible –
in order to be of better help and check if some configurations might need to be changed

Your next answer will be private which means only you and I have access to it.

Regards,

October 8, 2018 at 7:53 am #2794967

Jacek

Thanks for quick answer!

I don't ask about how to translate the contact form.

My question is: why shortcode don't works in string translation field?
In my firs post I was added a image, where I show where is added cf7 shortcode.

I use this shortcode for custom message, if product is out of stock, user can ask about product via cf7form

Access to the website:

login: Riffaz
password: rcqGdGsttjnbL3nDquds9B1z

btw. I dont use at this momen cf7 in second language

October 8, 2018 at 8:24 am #2795093

Riffaz
Supporter

Languages: English (English )

Timezone: Asia/Colombo (GMT+05:30)

Hi,

I am not sure where did you add that shortcode / I could not find the custom message you've added.

I understand now you have to show this form when a product is out of stock, right?
The proper ways is to do this is create a WooCommerce custom function and use a WooCommerce hook to show it in the proper place based on your page language.

I've added the correct PHP code to display this form when a product is out of stock in your German site/page.
Code has been added to Appearance > Editor > Functions.php

add_action('woocommerce_single_product_summary', 'add_contact_form', 20);

function add_contact_form() {
	if(ICL_LANGUAGE_CODE == 'de'){/* select the language of the page */
		global $product;
		if(!$product->is_in_stock( )) { /*if the product is out of stock */
		   echo do_shortcode('[contact-form-7 id="319" title="askaboutproduktde"]'); /* show this form */
		}
	}
}

change or edit the code you want. (selective language and the cf7 shortcode )
Remove the shortcode/message you are showing now from somewhere.

As you see the form is displayed correctly here hidden link that comes from the above code.

Let me know if this helps you or not, please.

Regards,

October 8, 2018 at 8:37 am #2795124

Jacek

Riffaz, You Are AMAZING!
Thanks a lot!

If I change ICL_LANGUAGE_CODE == 'de' to 'en' i can add new shortcode for English version?

October 8, 2018 at 10:22 am #2795511

Riffaz
Supporter

Languages: English (English )

Timezone: Asia/Colombo (GMT+05:30)

Hi,

Yes, you are correct.

Anyhow, you have only two languages.
In that case, the optimized code is :

add_action('woocommerce_single_product_summary', 'add_contact_form', 20);
 
function add_contact_form() {
    if(ICL_LANGUAGE_CODE == 'de'){/* select the language of the page */
        global $product;
        if(!$product->is_in_stock( )) { /*if the product is out of stock */
           echo do_shortcode('[contact-form-7 id="319" title="askaboutproduktde"]'); /* show this form */
        }
    }else{
		global $product;
        if(!$product->is_in_stock( )) { /*if the product is out of stock */
           echo do_shortcode('[other form shortcode]'); /* show this form */
        }
	}
}

this will show

[contact-form-7 id="319" title="askaboutproduktde"]

in German and the other form in other language automatically.

Please note always take a full backup of your site and database before you proceeding with code and this kind of works are beyond our support policy. Anyhow, I hope, this will help you.

Regards,

October 12, 2018 at 6:02 pm #2812875

Jacek

Hello Riffaz,

its not working for atributties

Please take a look on grobe 36/s

login: webadmin1
hasło: Webadmin1

hidden link

is possible to fix it?
Thank you

October 15, 2018 at 6:24 am #2816329

Jacek

I found a solution and i don't need help anymore.
Thanks for help!

October 15, 2018 at 7:56 pm #2818654

Itamar
Supporter

Languages: English (English ) Hebrew (עברית )

Timezone: Asia/Jerusalem (GMT+03:00)

Hi.

Riffaz is not available today so I'll continue to handle this ticket. But I see that you have found the solution so I'm glad about it.

I mark this ticket as resolved now.

Please contact us again with any WPML issue.

Regards,
Itamar.