Getting Country Code After International Shipping is Selected in Magento 1.9

magento-1.9shipping

Im trying to write an IF statement which takes into consideration the Country Code from the shipping address Selected. For example i have an If statement which checks if a user sub total is over 75 and in a certain customer group, if so then it displays a message telling them they get free delivery this works perfectly well

<?php
if ($sub > 75 && Mage::getSingleton('customer/session')->getCustomerGroupId() == 5 )
{
   echo "Free Shipping";
}

However this only applies to Customer is the UK, So when a customer ask for an estimated delivery cost for a country (using the table Method) it displays the correct price but it is still showing the "Free Shipping" because "If statement" is still showing True.

Is there a way i can add another IF statement to say if the country code select != UK dont echo the string.

What i need to be able to do.

Take in the country code from the basket after international shipping has been selected and check if it UK.

If you need me to clear up what i mean or need screen shots please just let me know.

If it is possible thank you for your help.

Best Answer

Adam, am not sure why you are trying this method to show "Free shipping" availability were by default you can enable the table rate shipping method to show free shipping based on user address(country code or region code) which will be straight forward and right way to do this.

If you still looking for to add if statement based on customer's selected country code then you can get country code by using

  $checkout = Mage::getSingleton('checkout/session')->getQuote();
  $getShippingAddress = $checkout->getShippingAddress();

This $getShippingAddress will have all data including country code so you can check from this object.