• Resolved Armsportstore.com

    (@armbreakersweden)


    Hi.

    I run a WPML based store, which has Klarna Checkout for Swedish language on Armsportbutiken.se and English language on Armsportstore.com which uses PayPal-checkout. It is the same store even though it is two different URL:s.

    On the Swedish store, your plugin adds the shipping phone & email field above the Klarna Checkout iframe. I need a way to disable the added fields for that payment gateway, as it should only be used on the default checkout i.e. English site. Any ideas of how to do this?
    I use Code Snippets, so I can add custom php code to the site.

    And another question, or more of a feature request. Can you please add a possibility to rename the label of the fields (and placeholder)?
    Or is this already possible somehow?

    Thanks for a really simple and nice plugin.

    The page I need help with: [log in to see the link]

Viewing 8 replies - 1 through 8 (of 8 total)
  • I just translated those 17 strings for Swedish. A Swedish language pack should be generated within an hour and become available via the “Updates” page. Let’s see if that helps you. If you from the context realize that some strings should be different, please feel free to suggest a new translation. https://translate.www.ads-software.com/projects/wp-plugins/f4-woocommerce-shipping-phone-and-e-mail
    Best regards from the Swedish WordPress translation team.

    Thread Starter Armsportstore.com

    (@armbreakersweden)

    Thanks @tobifjellner
    Appreciate the translations Tor-Bjorn, even though I need to configure the Phone labels for both English and Swedish. But it is good to have the translations done anyway ??

    Yeah. I hope you’ll find a way to get your conditional inclusion working, too ??

    Plugin Author FAKTOR VIER

    (@faktorvier)

    @tobifjellner thank you very much for the translations, we really appreciate it!

    @armbreakersweden we’ll have to take a closer look, maybe we can find a quick solution for you, so you can hide the fields for this special case. We will get back to you as fast as possible.

    Thread Starter Armsportstore.com

    (@armbreakersweden)

    I may have found a way myself. I have a Code Snippet that disables PayPal when Klarna Checkout is active, this is due to Klarna demands to be the only checkout option when in use…

    So I added this function:

    // Conditionally remove checkout fields based on active payment gateways
    function wc_remove_checkout_fields ( $fields ) {
    	unset( $fields['shipping']['shipping_phone'] );
    	unset( $fields['shipping']['shipping_email'] );
    
    	return $fields;
    }

    And added this inside the code for disabling payment gateways (have removed a lot of code as this part is much longer):

    add_filter( 'woocommerce_available_payment_gateways', 'custom_disable_payment_gateways_for_specific_countries', 20, 1  );
    function custom_disable_payment_gateways_for_specific_countries ( $available_gateways ) {
    
    // DISABLE PAYPAL EXPRESS FOR ALL COUNTRIES WHERE KLARNA IS ENABLED
    		if ( isset( $available_gateways['eh_paypal_express'] ) && isset( $available_gateways['kco'] ) ) {
    			unset( $available_gateways['eh_paypal_express'] );
    			add_filter( 'woocommerce_checkout_fields' , 'wc_remove_checkout_fields' ); // Remove the additional Shipping Phone & Email fields when using Klarna Checkout!
    		}
    }

    Don’t know if this is the right way to do it, as my php coding is at amateur level at best. So please give me input if this can be optimized somehow.
    It seem to work for now. Can’t see the email and phone fields when using Klarna, but they are visible when using PayPal if checking the box “Ship to a different address”.

    Plugin Author FAKTOR VIER

    (@faktorvier)

    Hi @armbreakersweden

    Maybe there are more elegant and more solid solutions, but this should work pretty well. Let us know if you run into problems, so we can help you find a better way to do this!

    Thread Starter Armsportstore.com

    (@armbreakersweden)

    Hi.
    Thanks for the feedback.

    Forgot about this:

    And another question, or more of a feature request. Can you please add a possibility to rename the label of the fields (and placeholder)?
    Or is this already possible somehow?

    Would that be possible to add in your plugin? Or would that be to advanced or break something in the simplicity of the plugin?

    Plugin Author FAKTOR VIER

    (@faktorvier)

    Hi @armbreakersweden

    Sorry, we forgot to answer this request. It already is (partially) possible. With this two hooks you can rename labels and placeholders in the front. We skipped all backend hooks because they’re not completed and we don’t know if you want to rename the labels in the backend (orders etc.) too.

    This hook changes the labels/placeholders in the checkout form:

    add_filter('woocommerce_checkout_fields', function($fields) {
    	$fields['shipping']['shipping_email']['label'] = 'Your own e-mail label';
    	$fields['shipping']['shipping_email']['placeholder'] = 'Your own e-mail placeholder';
    
    	$fields['shipping']['shipping_phone']['label'] = 'Your own phone label';
    	$fields['shipping']['shipping_phone']['placeholder'] = 'Your own phone placeholder';

    return $fields;
    }, 50);

    and this hook in the my account address form:

    add_filter('woocommerce_shipping_fields', function($address_fields, $country) {
    	$address_fields['shipping_email']['label'] = 'Your own email label';
    	$address_fields['shipping_email']['placeholder'] = 'Your own email placeholder';
    
    	$address_fields['shipping_phone']['label'] = 'Your own phone label';
    	$address_fields['shipping_phone']['placeholder'] = 'Your own phone placeholder';
    
    	return $address_fields;
    }, 50, 2);

    Hope this answers your question. If you need more infos, we’re happy to help you!

    • This reply was modified 4 years, 10 months ago by FAKTOR VIER.
Viewing 8 replies - 1 through 8 (of 8 total)
  • The topic ‘Doesn’t work with Klarna Checkout Payment gateway + more’ is closed to new replies.