hellykun Posted October 4, 2013 Share Posted October 4, 2013 Hello everyone I would like to call a function to get the customers postal code from his selected address into the get carrier function in the Carrier Class.php. Is it possible? Can somebody help a little? Thanks a lot. Link to comment Share on other sites More sharing options...
gonebdg - webindoshop.com Posted October 4, 2013 Share Posted October 4, 2013 (edited) You can get it from object address with object cart parameters (taken from global $cart or from $params)If customer already set their delivery address, then we can catch it.You can do something like this, depend on where you will use this function : /* get postal code for the existing cart address delivery * @param $params An array of the existing objects * @param $obcart An existing object cart * If global cart object is exist, @param $params and $cart are not necessary * return postal code if delivery address already set in the cart, else return boolean false */ public function getPostCode($obcart = false, $params = false) { global $cart; /* Make sure the existences of object cart */ if(!$obcart OR !Validate::isLoadedObject($obcart)) $mycart = !$params ? $cart : $params; if(!$params AND !Validate::isLoadedObject($mycart)) return false; /* Get an existing id_address_delivery from object cart */ $id_address_delivery = $mycart->id_address_delivery; /* Load object address according to existing id_address_delivery */ $address = new Address($id_address_delivery); /* If object address passed validation, define postal code variable */ if(Validate::isLoadedObject($address)) $postcode = $address->postcode; return $postcode; } Edited October 4, 2013 by gonebdg - webindoshop.com (see edit history) Link to comment Share on other sites More sharing options...
hellykun Posted October 7, 2013 Author Share Posted October 7, 2013 Thanks a lot! Is it also possible to extract the product categories or the product IDs from inside this $cart global variable? Your help is great! Link to comment Share on other sites More sharing options...
gonebdg - webindoshop.com Posted October 7, 2013 Share Posted October 7, 2013 Yes it possible.To get to know all parameters inside the cart object you can use p($cart); an alias of print_r() function OR you can use d($cart); an alias of print_r() function ended with die() function. Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now