• Resolved perli123

    (@perli123)


    Hi there,

    My problem is that when the customer updates his/her address inside the iframe this does not cause the new address to match against the shipping zone that it should. It never updates at all.

    This in turn causes the Klarna Shipping Assistant to not be shown, even though it should.

    My default shipping zone does not use Klarnas Shipping Assistant since we don’t want to ship anything except to certain areas. Only after the customer enters a “correct” address we want to present the shipping options.

    Why does updating the shipping/billing in the iframe not update the woocommerce shipping zone?

    And what can I do to fix this?

    The second goal is that we want to be able to use coupons that are restricted to certain shipping zones. And of course since the shipping zone does not update we can’t do this.

    Greateful for any help!

Viewing 7 replies - 1 through 7 (of 7 total)
  • Plugin Author Michael Bengtsson

    (@michaelbengtsson)

    Hi @perli123 ! I just tested this in my environment and from what i can see my shipping zone do get updated properly when i change my adress in the iframe.

    How do you know that the shipping zone is not updated? When are you checking for this?

    Thread Starter perli123

    (@perli123)

    Hi Michael,

    Thanks for your response.

    So there are three things that I can’t see

    1. The debug banner from Woocommerce don’t show any update in shipping zone matching
    2. The snippet don’t show the Klarna Shipping Asisstant fields
    3. Trying to enter a coupon with zone restriction don’t work (Advanced Coupons Plugin) since the zone is not correct.

    However I tried to read out the shipping zone from my themes functions.php when I changed the address in the iframe between one inside the zone and one outside the zone. This works and prints the zone id and name as expected!

    function update_order_review($posted_data)
    {
    	$klarna_order = kco_create_or_update_order();
    	$billing = $klarna_order['billing_address'];
    	$shipping = $klarna_order['shipping_address'];
    
    	WC()->customer->set_shipping_address_1($shipping["street_address"]);
    	WC()->customer->set_shipping_city($shipping["city"]);
    	WC()->customer->set_shipping_postcode($shipping["postal_code"]);
    	WC()->customer->set_shipping_country($billing["country"]);
    
    	WC()->customer->set_billing_address_1($billing["street_address"]);
    	WC()->customer->set_billing_city($billing["city"]);
    	WC()->customer->set_billing_postcode($billing["postal_code"]);
    	WC()->customer->set_billing_country($billing["country"]);
    
    	// // Get cart shipping packages
    	$shipping_packages =  WC()->cart->get_shipping_packages();
    
    	// Get the WC_Shipping_Zones instance object for the first package
    	 $shipping_zone = wc_get_shipping_zone( reset( $shipping_packages ) );
    
    	 $zone_id   = $shipping_zone->get_id(); // Get the zone ID
    	 $zone_name = $shipping_zone->get_zone_name(); // Get the zone name
    	 write_log($zone_name);
    	 write_log($zone_id );
    }
    
    add_action('woocommerce_checkout_update_order_review', 'update_order_review');

    Does that make things clearer?

    Can you switch from a shipping zone without Klarnas Shipping Assistant to one with Shipping Assistant and get the iframe to properly show this?

    Plugin Author Michael Bengtsson

    (@michaelbengtsson)

    @perli123

    1. That will only be printed on page loads. Which is kinda strange i agree. If you check on a normal checkout page with bank transfer for example this is the same.
    2. Are you talking about inside the iframe?
    3. This i am not sure about, since i have not tested it myself. I can test it possibly, if you can link me the coupon plugin that you had.

    Regarding the last question you had:

    Can you switch from a shipping zone without Klarnas Shipping Assistant to one with Shipping Assistant and get the iframe to properly show this?

    We have seen this error before, and we have talked about it with Klarna (Klarna internal ticket number SHAS-204). So my recommendation for this would be to contact the Klarna merchant support.

    Thread Starter perli123

    (@perli123)

    @michaelbengtsson

    Hi,

    Thanks for your answer. It looks like I might have interpreted three different things happening being due one root cause but judging from your response it might actually be three different things happening…

    Regarding number 2 yes I mean inside the iframe. But in that case you have already answered the question why we don’t see the Shipping Assistant with this

    We have seen this error before, and we have talked about it with Klarna (Klarna internal ticket number SHAS-204). So my recommendation for this would be to contact the Klarna merchant support.

    3. The plugin is called Advanced Coupons, they have a free and premium version. Unfortunately the premium version is needed for restricting coupons to shipping zones.

    Link here

    If you have any idea what is going on there I would be helpful, otherwise I will try to contact them directly.

    It might be an alternative for us to add the Shipping Assistant to the default shipping zone so that it is always visible and then deny orders that only matches with the default shipping zone (somehow).

    Thread Starter perli123

    (@perli123)

    @michaelbengtsson

    I tried to use the default WooCommerce checkout and there the coupons / switching between freight alternatives works as expected.

    I.e by only changing the postal code field inside WooCommerce checkout it is possible to “switch” shipping zone and get the coupons to apply correctly.

    Changing postal code in Klarna Checkout iframe does not give the same behaviour.

    So I guess the question is: What event / trigger is fired when changing address in WC checkout that is not fired when switching address in Klarna Checkout?

    Any ideas or suggestions what to do?

    Plugin Author Michael Bengtsson

    (@michaelbengtsson)

    @perli123 Depending on how much experience you have with coding you can try to add missing standard WooCommerce actions from the checkout page and see what might be missing. You can edit our template file under /templates/klarna-checkout.php

    You can also compare this to the WooCommerce templates for the checkout to make sure you get the normal once.

    For your information, we are planing on going over these actions to see which we might be able to include in our template as well. We where a bit hesitant at first to do this since we did not support extra checkout fields fully out of the gate with our plugin, but have later improved on this quite a bit to be able to more comfortably be able to support these things. The problem is just what else might be added that stores might not expect to see after a simple update. But we will be looking into this quite a bit more in the near future.

    Thread Starter perli123

    (@perli123)

    Hi Michael,

    Thanks for your answer a while back. Sorry for not replying.

    I’ve been working on higher priority tasks but will continue with this task again soon.

    Is there any update on your side regarding this topic? If your going to make a new release with this feature this week there is no need for me to start looking at this ??

    Regards
    Per

Viewing 7 replies - 1 through 7 (of 7 total)
  • The topic ‘Updates to Billing address in iframe does not update shipping zone’ is closed to new replies.