2

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.

1 Answer 1

4

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.

1
  • I was only using that way because using the backend way it was setting my Free shipping but was still keeping my Flat rate there but we wanted it to disappear, so i set up a shopping cart rule instead, which worked but it still had the same name (standard shipping) however thank you for your help :)
    – Adam Allen
    Commented Dec 15, 2014 at 12:04

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.