• Hey
    Thanks for creating an awesome plugin it integrates super well!
    One suggestion/question I have is the way that you have integrated translation. I don’t think it’s as smooth as it could be. Mainly, when I checkoff that i want WPML integration it disabled all the custom fields… why?

    We already discussed this here https://ww.wp.xz.cn/support/topic/wpml-integration-14/, but for some reason you closed the issue. Each time I update I have to manually modify the code to make this function properly. I see you are still updating the plugin so do you think that you could just modify teh code. It works great on a French => English and other language interface with WPML.

    Please please please integrate this feature. It’s not going to cause any harm and works really well!

    forms-buttons.php

               <?php if ( $show_login_step ) : ?>
                    <button id="wpmc-next" class="button button-active alt" type="button"><?php echo __($t_next, 'wp-multi-step-checkout'); ?></button>

    and the same for the second button

    form-tabs.php

    $steps = apply_filters( 'wp-multi-step-checkout-timeline', array(
      'login' => array(
        'order' => 0,
        'label' => __($t_login, 'wp-multi-step-checkout'),
      ),
      'billing' => array(
        'order' => 1,
        'label' => __($t_billing, 'wp-multi-step-checkout'),
      ),
      'shipping' => array(
        'order' => 2,
        'label' => __($t_shipping, 'wp-multi-step-checkout'),
      ),
      'order' => array(
        'order' => 3,
        'label' => __($t_order, 'wp-multi-step-checkout'),
      ),
      'payment' => array(
        'order' => 4,
        'label' => __($t_payment, 'wp-multi-step-checkout'),
      ),
    ));
    
    if ( !$show_shipping_step) unset($steps['shipping']);
    if ( !$show_login_step) unset($steps['login']);
    
    if ( $unite_billing_shipping ) {
        $steps['billing']['label'] = __($t_billing . ' & ' . $t_shipping, 'wp-multi-step-checkout');
        unset($steps['shipping']);
    }
    if ( $unite_order_payment) {
        $steps['order']['label'] = __($t_order . ' & ' . $t_payment, 'wp-multi-step-checkout');
        unset($steps['payment']);
    }
    
    ?>

    I also commented out the section you created with regards to the translation retrieval in form-checkout.php. Using it this way means that whatever the user provides is then properly translated through the system AND furthermore is done properly based on your code to combine the sections together.

Viewing 10 replies - 1 through 10 (of 10 total)
  • Plugin Author SilkyPress

    (@diana_burduja)

    Since the plugin’s 2.0 version the code you’re referring is not present in the codebase anymore.

    The custom fields get disabled when enabling the WPML option in order to solve the following scenario: you translate the “Login” custom field to “Login 2”. With a multilingual website the WPML will try to retrieve the translation for each language for the “Login 2” string instead of “Login”. Of course the .po translations don’t have the “Login 2” string, so on all the languages the step title will be “Login 2”.

    Your code modifications doesn’t seem to address this issue. It seems only that the __() function is moved from being applied in the /includes/form-checkout.php file to the /includes/form-tabs.php file (I’m talking about the codebase for the versions older than 2.0).

    Thread Starter shaneonabike

    (@shaneonabike)

    Sorry about that Diana. Actually, what I am suggesting is that you remove the WPML integration checkbox all together. The reason being is that with the WPML checkbox I cannot change the wording on any of these fields. It defaults itself to the PO files you have, and therefore are not changeable (unless I am missing something). What I want to suggest is that we remove that option, and then simply run the settings through the _() function to let WPML do it’s thang. It’s less maintenance for you and it also guarantees full integration. The user can modify as they wish AND it also allows for the support of the combined tabs.

    Here is the latest code that I am using:

    form-buttons.php

    <!-- The steps buttons -->
    <div class="wpmc-nav-wrapper">
        <div class="wpmc-footer-left">
            <?php if( $options['show_back_to_cart_button'] ) : ?>
            <button data-href="<?php echo wc_get_cart_url(); ?>" id="wpmc-back-to-cart" class="button alt" type="button"><?php echo 
    __($options['t_back_to_cart']); ?></button>
            <?php endif; ?>
        </div>
        <div class="wpmc-footer-right wpmc-nav-buttons">
            <button id="wpmc-prev" class="button button-inactive alt" type="button"><?php echo __($options['t_previous']); ?></butto
    n>
            <?php if ( $show_login_step ) : ?>
                <button id="wpmc-next" class="button button-active alt" type="button"><?php echo __($options['t_next']); ?></button>
                <button id="wpmc-skip-login" class="button button-active current alt" type="button"><?php echo __($options['t_skip_l
    ogin']); ?></button>
            <?php else : ?>
                <button id="wpmc-next" class="button button-active current alt" type="button"><?php echo __($options['t_next']); ?><
    /button>
            <?php endif; ?>
        </div>
    </div>
    

    form-checkout.php

    // Get the steps
    $steps = get_wmsc_steps('wp-multi-step-checkout');
    
    // Set the step titles
    $steps['billing']['title']  = __($options['t_billing']);
    $steps['shipping']['title'] = __($options['t_shipping']);
    $steps['review']['title']   = __($options['t_order']);
    $steps['payment']['title']  = __($options['t_payment']);
    

    and

    // Enabled "Show the Order and the Payment steps together" option on Multi-Step Checkout -> General Settings page 
    if ( $options['unite_order_payment']) {
        $steps['review']['title'] = __($options['t_order']) . ' '.esc_html($options['c_sign']).' ' . __($options['t_payment']); 
        $steps['review']['class'] = $steps['review']['class'] . ' ' . $steps['payment']['class'];
        $steps['review']['sections'] = array('review', 'payment');
        if ( $swap_payment_review ) {
            $steps['review']['sections'] = array('payment', 'review');
        }
        unset($steps['payment']);
    }
    

    and finallly form-tabs.php

    <!-- The steps tabs -->
    <div class="wpmc-tabs-wrapper">
        <ul class="wpmc-tabs-list wpmc-<?php echo $number_of_steps; ?>-tabs">
        <?php if ( $show_login_step ) : ?>
            <li class="wpmc-tab-item current wpmc-login">
                <div class="wpmc-tab-number"><?php echo $i = $i + 1; ?></div>
                <div class="wpmc-tab-text"><?php echo __($options['t_login']); ?></div>
            </li>
        <?php endif; ?>
        <?php
        foreach( $steps as $_id => $_step ) :
          $class = ( ! $show_login_step && $i == 0) ? ' current' : '';
          ?>
            <li class="wpmc-tab-item<?php echo $class; ?> wpmc-<?php echo $_id; ?>">
                <div class="wpmc-tab-number"><?php echo $i = $i + 1; ?></div>
                <div class="wpmc-tab-text"><?php echo __($_step['title']); ?></div>
            </li>
        <?php endforeach; ?>
    	</ul>
    </div>
    
    Thread Starter shaneonabike

    (@shaneonabike)

    The main reason that I was forced to implement this is because with your existing WPML implementation the labels are fixed. So by modifying this to just throw your code through the __() it will allow us to modify it as we wish. If you already have hte PO translation available then naturally WPML would just use that cause that’s how it works, but if we change the wording then we have to do that ourselves.

    Is my workflow / needs a bit clearer?

    • This reply was modified 6 years, 11 months ago by shaneonabike.
    Plugin Author SilkyPress

    (@diana_burduja)

    I just tried your code and doesn’t seem to solve the issue I explained this morning.

    Maybe I didn’t explain the case clear enough. Here are my settings for the button titles: WPML unchecked, “Next” and “Previous” remain the same, the “Back to cart” button is changed to something custom like “Back to cart 2”.

    With the code changes you propose here are the buttons for English (the default language for the test website) and here are the buttons for German (the second language for the website changed with WPML).

    WPML won’t find any string to translate in the plugin for the new button title and it will show the same new button title for all the languages. Also the WPML String Translation plugin will not find the string for the new button title, so it will not be translatable.

    Therefore the options for changing the text on steps and buttons need to be disabled when enabling the WPML option. Otherwise any change to the steps and button titles will be shown on all the languages and the changed text will not be translatable with WPML String Translation.

    Thread Starter shaneonabike

    (@shaneonabike)

    Did you refresh your strings using the WPML system. In my situation on a live site this works like magic. The original are written in English and then translated to French.

    Could you just double check with the changes that perhaps I didn’t miss one of the button translations when I did the copy of the code. Also, just to be certain when you looked at the translation in German did you then go back and check if the strings were available? I could be stating the obvious but that’s the only way that I find WPML picks up the need to translate strings. I then searched for the start of the strings that needed translated and viola they were there!

    https://beesonabike.com/wp-content/uploads/2019/06/Selection_002.jpg
    https://beesonabike.com/wp-content/uploads/2019/06/Selection_001.jpg

    Thread Starter shaneonabike

    (@shaneonabike)

    I also forget this code bit as well I realized afterwards. Sorry about that.

    // Enabled "Show the Order and the Payment steps together" option on Multi-Step Checkout -> General Settings page 
    if ( $options['unite_billing_shipping'] && $options['show_shipping_step'] ) {
        $steps['billing']['title'] = __($options['t_billing']) . ' '.esc_html($options['c_sign']).' ' . __($options['t_shipping']);
        $steps['billing']['class'] = $steps['billing']['class'] . ' ' . $steps['shipping']['class'];
        $steps['billing']['sections'] = array('billing', 'shipping');
        unset($steps['shipping']);
    }
    
    Thread Starter shaneonabike

    (@shaneonabike)

    There’s some instructions here related to scanning the plugin after you have modified strings https://wpml.org/documentation/getting-started-guide/theme-localization/. You also have to verify your WPML settings as you could have selected to only use the MO files and thus if there is no match it won’t attempt to add it into your string translation.

    Is this an existing install or a refresh one?

    Plugin Author SilkyPress

    (@diana_burduja)

    Ok, so according to this screenshot you’ve changed the “Shipping” string to “Camp Details”. How is the “Camp Details” translated to French? How does the WPML String Translate plugin pick up the “Camp Details” string to translate it to French?

    In this screenshot you show me that the “Back to cart” and “Skip login” buttons are correctly translated to French. But these exact strings were not modified on the multi-step checkout plugin settings page.

    Thread Starter shaneonabike

    (@shaneonabike)

    Yep!

    It picks up all the strings to translate in fact. Here’s the output so you can that it is properly picking up stuff.

    Plugin Author SilkyPress

    (@diana_burduja)

    You can use your solution, but unfortunately i cannot accept your changes as they will create a lot of confusion for other users.

    The plugin can be successfully used also without your solution by translating the original strings with the WPML String Translate instead of the modified strings. For example, by enabling the “WPML” option in the multi-step checkout settings and translating the “Billing” string to “Billing and information” in English and then to “Facturation et information” in French.

    My solution still looks to me more clear cut: you can translate/modify the strings from the plugin’s settings page OR you can switch all the translations and modifications to the WPML and you manage it from there. These are two independent and exclusive options. But combining these two options, as you want to do, will lead to confusions as to why the translation isn’t picked up in some cases.

    Besides, this is an open-source plugin. You are free to use it and to modify it as you want. If your changes fit your needs, then feel free to use them.

    • This reply was modified 6 years, 11 months ago by SilkyPress.
Viewing 10 replies - 1 through 10 (of 10 total)

The topic ‘WPML Integration’ is closed to new replies.