Can I split a gravity forms postcode field by the space so just the first half of the postcode is entered automatically into a text field

reaching out on this one. I’m using gravityforms address field and need a simple text field to display just the first half of the postcode.

Example

Postcode Field: E14 4RD Text Field: E14

No idea where to start I’ve Googled and asked on gravityforms forum but no luck.

Any pointers would be great

Show/Hide specific shipping methods based on postcode and cart subtotal

I would like to show or hide specific shipping options based on postcode and cart subtotal amount. Here is my code:

add_filter( 'woocommerce_package_rates', 'unset_shipping_when_free_is_available', 10, 2 );     function unset_shipping_when_free_is_available( $  rates, $  package ) {      $  excluded_postcode = array( 1000,1030,1040,1050,1060,1070,1080,1081,1082,1083,1090,1140,1150,1160,1170,1180,1190,1200,1210 );     if(WC()->cart->get_cart_subtotal() >= '50' && !in_array(WC()->customer->get_shipping_postcode(), $  excluded_postcode )){         if ( isset( $  rates['free_shipping:4'] ) ) {             unset( $  rates['flat_rate:2'] );             unset( $  rates['flat_rate:26'] );             unset( $  rates['flat_rate:27'] );         }     }elseif(WC()->cart->get_cart_subtotal() >= '50' && in_array(WC()->customer->get_shipping_postcode(), $  excluded_postcode )){         if ( isset( $  rates['free_shipping:16'] ) ) {             unset( $  rates['flat_rate:13'] );             unset( $  rates['flat_rate:28'] );             unset( $  rates['flat_rate:29'] );         }     }     return $  rates; } 

What I want to do is when the customer’s postcode meets one of the list: array $ excluded_postcode(Brussels’s postcode), there will be 2 options: free collective shipping(free_shipping:16) (the customer need to choose a date) or flat rate based on weight, but if the cart subtotal is >=50€, then the shipping fee will be free, there will be also 2 options (both free), one is free collective shipping (need to choose a date) and the other is free shipping when the minimum amount is 50€(free_shipping:4); if the customer’s postcode is different from the array (not from Brussels), the shipping rate is based on weight, but if the subtotal amount is >=50€, then it will be free shipping. So if subtotal greater or equals 50€, only free options will be shown (if postcode=Brussels, 2 free shipping options: free_shipping:4 and free_shipping:16, if not Brussels: only free_shipping:4), if subtotal less than 50€, 2 options if Brussels: free_shipping:16 and flat rate based on weight, if not Brussels: only flat rate based on weight. (Brussels flat rates: flat_rate:2=0-2kg, flat_rate:26=2-5kg, flat_rate:27=5-10kg, No Brussels flat rates: flat_rate:13=0-2kg, flat_rate:28=2-5kg, flat_rate:29=5-10kg)

It works fine except when the subtotal is less than 50€ and from Brussels, only one free shipping option is showing: free_shipping:16, I would like to have both free options to be displayed.

This is the checkout page: https://www.labeerepoque.be/en/checkout/

I would be greatful if you could help me with this, thank you!

Magento 2 how to get Postcode from billing address in observer?

I cannot get the postcode from Users’s billing Address,this is my code, everything works fine except for the postcode, which i’m not able to pull.

$  objectManager = \Magento\Framework\App\ObjectManager::getInstance();          $  customer = $  observer->getEvent()->getCustomer();         $  customer_email=$  customer->getEmail();         $  first_name= $  customer->getFirstname();         $  last_name= $  customer->getLastname();         $  taxVat = $  customer->getTaxvat();           //Billing Address variables          $  billingID = $  customer->getDefaultBilling();         $  billingAddress = $  objectManager->create('Magento\Customer\Model\Address')->load($  billingID);         $  billingCompany = $  billingAddress->getCompany();         $  billingZipcode = $  billingAddress->getPostCode();         $  billingCity = $  billingAddress->getCity();         $  billingState = $  billingAddress->getRegion();         $  billingStreet = $  billingAddress->getStreet();         $  billingStreet1 = $  billingStreet[0];         $  billingStreet2 = $  billingStreet[1];         $  billingTelephone = $  billingAddress->getTelephone(); 

Greetings!

Shipping is calculated in checkout no postcode. I think I’ve figured out why

My shipping module is getting a postcode even though postcode is not set in the cart.

  • This is for a new cart created from an guest customer.
  • Magento 2.3/Ubuntu Server
  • All Magento Default Shipping Modules Disabled, Running Custom Module.

In my shipping module, using xdebug, I saw that:

$ request->getDestPostcode(); // Defaults to value from Tax Calculation in admin backend.

I’ve isolated this value to be from:

http://Base_url/admin/admin/system_config/edit/section/tax/ postcode set here

Can someone confirm/reproduce this? Github Issue #18630