Snippets with the tag: address

Check if shipping methods are available

Description

function to know that there is any shipping method available

Code

public function haveShippingMethods()
{
	if (count(Mage::getSingleton('checkout/session')->getQuote()->getShippingAddress()->getShippingRatesCollection())) {
		return true;
	}
	return false;
}

Array of billing and shipping addresses

Description

use this code to get an array of billing address and shipping address

Code

$all_data = array();
$customer = Mage::getModel(‘customer/session’)->getCustomer();
foreach($customer->getAddressesCollection() as $customer_address)
{
$all_data[] = $customer_address;
}
var_dump($all_data);

Create a customer

Description

code to create a customer account

Code

$customer = Mage::getModel('customer/customer');
$password = 'test1234';
$email = 'dtest@gmail.com';
$customer->setWebsiteId(Mage::app()->getWebsite()->getId());
$customer->loadByEmail($email);
if(!$customer->getId()) {
    $groups = Mage::getResourceModel('customer/group_collection')->getData();
    $groupID = '3';

    $customer->setData( 'group_id', $groupID );
    $customer->setEmail($email);
    $customer->setFirstname('test');
    $customer->setLastname('testing');
    $customer->setPassword($password);

    $customer->setConfirmation(null);
    $customer->save();

    echo $customer->getId();
}