I'm trying create programmatically a new address to customers that was imported a some time ago for me.
My Code:
//All variables about customer address info are filled
$customerModel = Mage::getModel('customer/customer');
$customer = $customerModel->setWebsiteId(1)->loadByEmail($_email);
if($customer->getId()) {
$addressData = array (
'firstname' => $customer->getFirstname(),
'lastname' => $customer->getLastname(),
'street' => "$_s1
$_s2
$_s3
$_s4",
'city' => $_city,
'country_id' => 'BR',
'region_id' => $_regionid,
'postcode' => $_cep,
'telephone' => $_tel,
'celular' => $_cel,
'is_default_billing' => 1,
'is_default_shipping' => 1
);
$address = Mage::getModel('customer/address');
$address->addData($addressData);
$customer->addAddress($address);
try {
print_r($addressData);
$customer->save();
}
catch (Exception $e) {
}
}
Object loaded '$customer' isnt what I need: a full customer object.
Any Idea?
You have to save customer address in different way, following is address saving code.
$customerAddress = Mage::getModel('customer/address');
$customerAddress->setData($addressData)
->setCustomerId($customer->getId())
->setSaveInAddressBook('1');
$customerAddress->save();
The full code will look like:
$customerModel = Mage::getModel('customer/customer');
$customer = $customerModel->setWebsiteId(1)->loadByEmail($_email);
if($customer->getId()) {
$addressData = array (
'firstname' => $customer->getFirstname(),
'lastname' => $customer->getLastname(),
'street' => "$_s1
$_s2
$_s3
$_s4",
'city' => $_city,
'country_id' => 'BR',
'region_id' => $_regionid,
'postcode' => $_cep,
'telephone' => $_tel,
'celular' => $_cel,
'is_default_billing' => 1,
'is_default_shipping' => 1
);
$customerAddress = Mage::getModel('customer/address');
$customerAddress->setData($addressData)
->setCustomerId($customer->getId())
->setSaveInAddressBook('1');
$customerAddress->save();
//And reload customer object
$customer = Mage::getModel('customer/customer')->load($customer->getId());
//Check customer data
print_r($customer->getData());
//Check addresses
foreach($customer->getAddresses() as $address)
{
print_r($address);
}
}
Related
I am creating an application where I have to insert a user at registration with custom fields. As found online, i customised the create method in the Laravel RegisterController. However, now the application inserts two user records whenever I register a new user. Can someone help me with this please?
Here is the code of my create method in the RegisterController
protected function create(array $data)
{
/********************************************************************************
* CALCULATE ALL THE NEEDED DATA FOR THE USER
********************************************************************************/
// Delete the uncompleted registration
UncompletedRegistration::deleteByEmail($data['email']);
// Set the right values based on the filled values
$compercentagecreative = 0.0;
$compercentagenotcreative = 0.0;
$creativepercent = 0.0;
switch ($data['headjob']) {
case 1:
$compercentagecreative = config('constants.percentageRates.comPercentageCreative.headjob');
$compercentagenotcreative = config('constants.percentageRates.comPercentageNotCreative.headjob');
$creativepercent = config('constants.percentageRates.creativePercent.headjob');
break;
case 2:
$compercentagecreative = config('constants.percentageRates.comPercentageCreative.notheadjob');
$compercentagenotcreative = config('constants.percentageRates.comPercentageNotCreative.notheadjob');
$creativepercent = config('constants.percentageRates.creativePercent.notheadjob');
break;
default:
$compercentagecreative = config('constants.percentageRates.comPercentageCreative.headjob');
$compercentagenotcreative = config('constants.percentageRates.comPercentageNotCreative.headjob');
$creativepercent = config('constants.percentageRates.creativePercent.headjob');
break;
}
// Format the VAT number
$data['vatnumber'] = Helper::formatVatNumber($data['vatnumber']);
$isVatValid = false;
try {
// Check if vat is valid
$response = Helper::checkVat($data['vatnumber']);
$responseArray = json_decode($response);
$isVatValid = $responseArray->valid;
} catch (\Exception $exception) {
$isVatValid = false;
}
// Generate an activation key
$activationKey = md5(uniqid('CS', true));
/********************************************************************************
* CREATE THE USER IN THE DATABASE
********************************************************************************/
// Create the user and insert in the database
return User::create([
'usertype' => config('constants.userTypes.USER'),
'registeredon' => strtotime(date("Y-m-d H:i:s")),
'activationkey' => $activationKey,
'language' => 'nl',
'email' => Helper::truncate($data['email']),
'fullname' => Helper::truncate($data['lastname'] . ' ' . $data['firstname']),
'firstname' => Helper::truncate($data['firstname']),
'lastname' => Helper::truncate($data['lastname']),
'password' => Hash::make($data['password']),
'lastloginon' => strtotime('now'),
'lastloginip' => $_SERVER['REMOTE_ADDR'],
'activatedon' => strtotime(date('Y-m-d H:i:s', strtotime('1970-01-01 00:00:00'))),
'deleted' => false,
'companyname' => Helper::truncate($data['companyname']),
'street' => Helper::truncate($data['street']),
'number' => Helper::truncate($data['number']),
'city' => Helper::truncate($data['city']),
'zipcode' => Helper::truncate($data['zipcode']),
'vatnumber' => Helper::truncate($data['vatnumber']),
'validvat' => $isVatValid,
'website' => Helper::truncate($data['website']),
'phonenumber' => Helper::truncate($data['phonenumber']),
'bankname' => Helper::truncate($data['bank']),
'iban' => Helper::truncate($data['iban']),
'bicswift' => Helper::truncate($data['bicswift']),
'paymentremindermode' => $data['paymentremindermode'],
'invoicecreationremindermode' => 2,
'nettosavedmailmode' => 1,
'zombiemailsent' => 0,
'zombiemail180sent' => 0,
'nettosavedperinvoicmailemode' => 1,
'logo' => NULL,
'emailaccepted' => false,
'contractaccepted' => false,
'compercentagecreative' => $compercentagecreative,
'compercentagenotcreative' => $compercentagenotcreative,
'contractdate' => date("Y-m-d H:i:s"),
'creativepercent' => $creativepercent,
'activity' => $data['activity'],
'headjob' => $data['headjob'],
'template' => config('constants.templates.ORIGINAL'),
'freebtw' => isset($data['freebtw']) ? ($data['freebtw'] == "on" ? true : false) : false,
'refid' => Input::get('invite_id'),
'api_key' => Helper::generateRandomString(40),
'allowed_quotation' => true,
'send_bcc' => false
]);
}
I've created a transaction but I'd like to return all data which has been created in one json. I'd like to do this using Resources in Laravel 5.5.
This is my transaction:
$firstUser = DB::transaction(function () use ($request) {
//Create Group Campany
$groupCompany = \App\GroupCompany::create([
'name' => $request['nameGroupCompany'],
'cod' => $request['codGroupCompany'],
]);
//Create Company
$company = \App\Company::create([
'group_company_id' => $groupCompany->id,
'name' => $request['nameCompany'],
'cod' => $request['codCompany'],
]);
//Create Group User
$groupUser = \App\GroupUser::create([
'name' => 'Admin',
'admin' => 1,
]);
$groupUser->companies()->attach($company->id);
//Create Person
$person = \App\Person::create([
'firstName' => $request['name'],
'middleName' => $request['middleName'],
'lastName' => $request['lastName'],
'dateOfBirth' => $request['dateOfBirth'],
]);
$person->groupUsers()->attach($groupUser->id);
//Create User
$newUser = \App\User::create([
'person_id' => $person->id,
'name' => $request['name'],
'email' => $request['email'],
'password' => bcrypt($request['password']),
]);
return ??????;
});
And finally I call my Resource:
return new FirstUserResource($firstUser);
What should I do?
Thank you very much.
Marcel
Save info in a array before save them like below:
$groupCompanya = array('name' => $request['nameGroupCompany'],
'cod' => $request['codGroupCompany']);
$groupCompany = \App\GroupCompany::create($groupCompanya);
Gather all data into a new array:
$result = array("groupCompany"=> $groupCompanya, "company" => $companya, "groupUser" => $groupUsera, "person"=>$persona, "newUser"=>$newUsera);
after convert it to json and return it:
$json = array("result" => $result);
return json_encode($json,JSON_UNESCAPED_UNICODE);
If you are returning all the data as a single json I think Collections will help you here?
$collection = collect([var1,var2]);
return $collection->toJson();
I currently have EasyPost creating a shipment. When I create the shipment it provides me with all the available services and rates.
I would like to dynamically select service and only return that rate.
I originally would read through the array using the index number (I guess that how to describe it).
The problem with this is every time I create a new shipment the order of the rates array changes so what would have been $shipment->rates[0]['rate'] would be express and then the next time first class.
I want to create a shipment with "Express" and only return that rate.
Any advice would be appreciated.
Here is my code:
$name = $this->thiscustomer->cust_first . ' ' . $this->thiscustomer->cust_first;
$street_1 = $this->thiscustomer->street_1;
$street_2 = $this->thiscustomer->street_2;
$city = $this->thiscustomer->city;
$state = $this->thiscustomer->state;
$zip = $this->thiscustomer->zip;
$weight = $this->weight;
$packaging = $this->packaging;
$service = $this->service;
$caddress = $this->consultant->address;
$cstreet_1 = $this->consultant->street_1;
$cstreet_2 = $this->consultant->street_2;
$ccity = $this->consultant->city;
$cstate = $this->consultant->state;
$czip = $this->consultant->zip;
$cname = $this->consultant->first_name . ' ' . $this->consultant->last_name;
$cuser_id = $this->consultant->user_id;
require_once(dirname(__FILE__) . '/lib/easypost.php');
\EasyPost\EasyPost::setApiKey('KUk4fZUI6YaYc1h0FiIXFw');
$shipment = \EasyPost\Shipment::create(array(
'to_address' => array(
"name" => $name,
"street1" => $street_1,
"street2" => $street_2,
"city" => $city,
"state" => $state,
"zip" => $zip
),
'from_address' => array(
"company" => $cname,
"street1" => $cstreet_1,
"street2" => $cstreet_2,
"city" => $ccity,
"state" => $cstate,
"zip" => $czip
),
'parcel' => array(
'weight' => $weight,
'predefined_package'=> $packaging
),
'rates' => array(
'service' => $service
)
));
echo $shipment->rates[0]['rate']. '<br>';
In EasyPost's Getting Started Guide there is an example of buying a specific carrier+rate:
$shipment->buy($shipment->lowest_rate(array('USPS'), array('Express')));
you can get different rates through below lines of code
if(!empty($shipment->rates))
{
$count = 0;
foreach($shipment->rates as $rate)
{
$serviceRates[$count] = [
'service' => $rate->service,
'carrier' => $rate->carrier,
'rate' => $rate->rate,
'currency' => $rate->currency,
'delivery_days' => $rate->delivery_days
];
$count++;
}
}
else
{
echo 'no result fond for given address';
}
print_r($serviceRates);
#KFunk is correct that EasyPost does not provide a native way to accomplish what you are asking since this use case is unique to you. The EasyPost client libraries provide all the functions needed to interact with the API; however, all of the business logic is left to the user.
If you want to create a shipment but only show a single rate to the user, you will need to filter out the other rates in your own application. To do this, you can follow the simple example here:
<?php
\EasyPost\EasyPost::setApiKey($_ENV['EASYPOST_API_KEY']);
// Create your shipment, the response will contain all rates for all configured carriers
$shipment = \EasyPost\Shipment::create([
'to_address' => [
'name' => 'Dr. Steve Brule',
'street1' => '179 N Harbor Dr',
'city' => 'Redondo Beach',
'state' => 'CA',
'zip' => '90277',
'country' => 'US',
'phone' => '3331114444',
'email' => 'dr_steve_brule#gmail.com'
],
'from_address' => [
'name' => 'EasyPost',
'street1' => '417 Montgomery Street',
'street2' => '5th Floor',
'city' => 'San Francisco',
'state' => 'CA',
'zip' => '94104',
'country' => 'US',
'phone' => '3331114444',
'email' => 'support#easypost.com'
],
'parcel' => [
'length' => 20.2,
'width' => 10.9,
'height' => 5,
'weight' => 65.9
]
]);
$rates = $shipments->rates;
// Filter out all the rates that aren't the desired one, in this case - `Express`
$expressRate = null;
foreach ($rates as $rate) {
if ($rate->service == "Express") {
$expressRate = $rate;
break;
}
}
// Return $expressRate to your UI or do with it what you need
echo $expressRate;
Relying on array ordering is an antipattern that should be avoided. Array indices are never guaranteed to remain in the same order and do not have a strong bond to the data in question.
For further help with the EasyPost API specifically, you can reach out to our support team via support#easypost.com. Best of luck!
THE SOAP REQUEST AS SENT
<?xml version="1.0" encoding="UTF-8"?>
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ns1="http://fedex.com/ws/ship/v12">
<SOAP-ENV:Body>
<ns1:ProcessShipmentRequest>
<ns1:WebAuthenticationDetail>
<ns1:UserCredential>
<ns1:Key>kQyj3MtQGLJ3ZYWG</ns1:Key>
<ns1:Password>66ywMwyasljK5uRkaNENRZCZW</ns1:Password>
</ns1:UserCredential>
</ns1:WebAuthenticationDetail>
<ns1:ClientDetail>
<ns1:AccountNumber>510087682</ns1:AccountNumber>
<ns1:MeterNumber>100154483</ns1:MeterNumber>
</ns1:ClientDetail>
<ns1:TransactionDetail>
<ns1:CustomerTransactionId>*** Express Domestic Shipping Request v12 using PHP ***</ns1:CustomerTransactionId>
</ns1:TransactionDetail>
<ns1:Version>
<ns1:ServiceId>ship</ns1:ServiceId>
<ns1:Major>12</ns1:Major>
<ns1:Intermediate>1</ns1:Intermediate>
<ns1:Minor>0</ns1:Minor>
</ns1:Version>
<ns1:RequestedShipment>
<ns1:ShipTimestamp>2013-03-25T14:33:08+00:00</ns1:ShipTimestamp>
<ns1:DropoffType>REGULAR_PICKUP</ns1:DropoffType>
<ns1:ServiceType>FEDEX_GROUND</ns1:ServiceType>
<ns1:PackagingType>YOUR_PACKAGING</ns1:PackagingType>
<ns1:TotalWeight>
<ns1:Units>LB</ns1:Units>
<ns1:Value>17.22</ns1:Value>
</ns1:TotalWeight>
<ns1:Shipper>
<ns1:Contact>
<ns1:PersonName>Shipping Department</ns1:PersonName>
<ns1:CompanyName>Big Dog Treestands</ns1:CompanyName>
<ns1:PhoneNumber>3092636800</ns1:PhoneNumber>
</ns1:Contact>
<ns1:Address>
<ns1:StreetLines>120 E. Detroit Parkway</ns1:StreetLines>
<ns1:City>Morton</ns1:City>
<ns1:StateOrProvinceCode>IL</ns1:StateOrProvinceCode>
<ns1:PostalCode>61550</ns1:PostalCode>
<ns1:CountryCode>US</ns1:CountryCode>
</ns1:Address>
</ns1:Shipper>
<ns1:Recipient>
<ns1:Contact>
<ns1:PersonName>David Sinc</ns1:PersonName>
<ns1:CompanyName>TEST COMPANY</ns1:CompanyName>
<ns1:PhoneNumber>3093701229</ns1:PhoneNumber>
</ns1:Contact>
<ns1:Address>
<ns1:StreetLines>1202 Chalet Ln</ns1:StreetLines>
<ns1:StreetLines>HIDDLY- Test Account</ns1:StreetLines>
<ns1:City>PEORIA</ns1:City>
<ns1:StateOrProvinceCode>IL</ns1:StateOrProvinceCode>
<ns1:PostalCode>61614</ns1:PostalCode>
<ns1:CountryCode>US</ns1:CountryCode>
<ns1:Residential>false</ns1:Residential>
</ns1:Address>
</ns1:Recipient>
<ns1:ShippingChargesPayment>
<ns1:PaymentType>SENDER</ns1:PaymentType>
<ns1:Payor>
<ns1:ResponsibleParty>
<ns1:AccountNumber>510087682</ns1:AccountNumber>
<ns1:Contact/>
<ns1:Address>
<ns1:CountryCode>US</ns1:CountryCode>
</ns1:Address>
</ns1:ResponsibleParty>
</ns1:Payor>
</ns1:ShippingChargesPayment>
<ns1:LabelSpecification>
<ns1:LabelFormatType>COMMON2D</ns1:LabelFormatType>
<ns1:ImageType>PDF</ns1:ImageType>
<ns1:LabelStockType>PAPER_8.5X11_TOP_HALF_LABEL</ns1:LabelStockType>
</ns1:LabelSpecification>
<ns1:RateRequestTypes>ACCOUNT</ns1:RateRequestTypes>
<ns1:PackageCount>1</ns1:PackageCount>
<ns1:RequestedPackageLineItems>
<ns1:SequenceNumber>1</ns1:SequenceNumber>
<ns1:GroupPackageCount>1</ns1:GroupPackageCount>
<ns1:Weight>
<ns1:Units>LB</ns1:Units>
<ns1:Value>17.22</ns1:Value>
</ns1:Weight>
</ns1:RequestedPackageLineItems>
</ns1:RequestedShipment>
</ns1:ProcessShipmentRequest>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>
Fedex APpplication Code
<?php
// Copyright 2009, FedEx Corporation. All rights reserved.
// Version 12.0.0
require_once('library/fedex-common.php5');
//The WSDL is not included with the sample code.
//Please include and reference in $path_to_wsdl variable.
$path_to_wsdl = "http://bigdog.webdesign309.com/wp-content/themes/bigdogtreestands-new/woocommerce/emails/ShipWebServiceClient/wsdl/ShipService_v12.wsdl";
$uploads = wp_upload_dir();
define('SHIP_LABEL', $uploads['basedir'].'/shippinglabels/shipexpresslabel'.str_replace('#','',$order->get_order_number()).'.pdf'); // PNG label file. Change to file-extension .pdf for creating a PDF label (e.g. shiplabel.pdf)
ini_set("soap.wsdl_cache_enabled", "0");
$client = new SoapClient($path_to_wsdl, array('trace' => 1)); // Refer to http://us3.php.net/manual/en/ref.soap.php for more information
$request['WebAuthenticationDetail'] = array(
'UserCredential' => array(
'Key' => getProperty('key'),
'Password' => getProperty('password')
)
);
$request['ClientDetail'] = array(
'AccountNumber' => getProperty('shipaccount'),
'MeterNumber' => getProperty('meter')
);
$request['TransactionDetail'] = array('CustomerTransactionId' => '*** Express Domestic Shipping Request v12 using PHP ***');
$request['Version'] = array(
'ServiceId' => 'ship',
'Major' => '12',
'Intermediate' => '1',
'Minor' => '0'
);
$ships = $order->get_shipping_method();
$shippingType = "FEDEX_GROUND";
if($ships == "Fedex Ground"){
$shippingType = "FEDEX_GROUND";
}
else if( $ships == "Fedex 2 Day"){
$shippingType = "FEDEX_2_DAY";
}
else if($ships == "Fedex Standard Overnight"){
$shippingType = "STANDARD_OVERNIGHT";
}
else if($ships == "Fedex Home Delivery"){
$shippingType = "GROUND_HOME_DELIVERY";
}
function totalOrderWeight($orders) {
$totalWeight = 0;
$items = $orders->get_items();
foreach($items as $item) {
$product = get_product( $item['product_id'] );
$quantity = intval( $item['qty'] );
$totalWeight += $product->get_weight() * $quantity;
}
return $totalWeight;
}
$request['RequestedShipment'] = array(
'ShipTimestamp' => date('c'),
'DropoffType' => 'REGULAR_PICKUP', // valid values REGULAR_PICKUP, REQUEST_COURIER, DROP_BOX, BUSINESS_SERVICE_CENTER and STATION
'ServiceType' => $shippingType, // valid values STANDARD_OVERNIGHT, PRIORITY_OVERNIGHT, FEDEX_GROUND, ...
'PackagingType' => 'YOUR_PACKAGING', // valid values FEDEX_BOX, FEDEX_PAK, FEDEX_TUBE, YOUR_PACKAGING, ...
'TotalWeight' => array('Value' => totalOrderWeight($order), 'Units' => 'LB'), // valid values LB and KG
'Shipper' => addShipper(),
'Recipient' => addRecipient($order),
'ShippingChargesPayment' => addShippingChargesPayment(),
'LabelSpecification' => addLabelSpecification(),
'RateRequestTypes' => array('ACCOUNT'), // valid values ACCOUNT and LIST
'PackageCount' => 1,
'RequestedPackageLineItems' => array(
'0' => addPackageLineItem1(totalOrderWeight($order))
)
);
try
{
if(setEndpoint('changeEndpoint'))
{
$newLocation = $client->__setLocation(setEndpoint('endpoint'));
}
$response = $client->processShipment($request); // FedEx web service invocation
if ($response->HighestSeverity != 'FAILURE' && $response->HighestSeverity != 'ERROR')
{
printSuccess($client, $response);
$label =
// Create PNG or PDF label
// Set LabelSpecification.ImageType to 'PDF' or 'PNG for generating a PDF or a PNG label
$fp = fopen(SHIP_LABEL, 'wb');
fwrite($fp, $response->CompletedShipmentDetail->CompletedPackageDetails->Label->Parts->Image); //Create PNG or PDF file
fclose($fp);
// echo 'Click Here to Download Shipping Label was generated.';
}
else
{
printError($client, $response);
}
writeToLog($client); // Write to log file
} catch (SoapFault $exception) {
printFault($exception, $client);
}
function addShipper(){
$shipper = array(
'Contact' => array(
'PersonName' => 'Shipping Department',
'CompanyName' => 'Big Dog Treestands',
'PhoneNumber' => '3092636800'),
'Address' => array(
'StreetLines' => array('120 E. Detroit Parkway'),
'City' => 'Morton',
'StateOrProvinceCode' => 'IL',
'PostalCode' => '61550',
'CountryCode' => 'US')
);
return $shipper;
}
function addRecipient($orders){
$residential = get_post_meta($orders->get_order_number(), '_residential-indicator');
/* echo 'Shipping Address 2:'.$orders->shipping_address_2;
echo 'Shipping Address 1:'.$orders->shipping_address_1; */
if($orders->shipping_address_2){
$addressArray = array($orders->shipping_address_1, $orders->shipping_address_2);
/* echo 'Shipping Address 2'; */
/* $addressArray =array('StreetLines' => array('Address Line 1' => $orders->shipping_address_1, 'Address Line 2' => $orders->shipping_address_2)); */
}
else{
$addressArray = array($orders->shipping_address_1);
/* echo 'Shipping Address 1'; */
}
$joy = false;
if($residential == 1){
$joy = true;
}
else{
$joy = false;
}
$recipient = array(
'Contact' => array(
'PersonName' => $orders->billing_first_name . ' ' . $orders->billing_last_name,
'CompanyName' => $orders->shipping_company,
'PhoneNumber' => $orders->billing_phone),
/* 'Address' => array(
'StreetLines' => array($orders->shipping_address_1, $orders->shipping_address_2),
'City' => $orders->shipping_city,
'StateOrProvinceCode' => $orders->shipping_state,
'PostalCode' => $orders->shipping_postcode,
'CountryCode' => 'US',
'Residential' => $joy) */
'Address' => array(
'StreetLines'=>array($orders->shipping_address_1, $orders->shipping_address_2),
//array(utf8_encode($orders->shipping_address_1), utf8_encode($orders->shipping_address_2)),
'City' => $orders->shipping_city,
'StateOrProvinceCode' => $orders->shipping_state,
'PostalCode' => $orders->shipping_postcode,
'CountryCode' => 'US',
'Residential' => $joy)
);
return $recipient;
}
function addShippingChargesPayment(){
$shippingChargesPayment = array('PaymentType' => 'SENDER',
'Payor' => array(
'ResponsibleParty' => array(
'AccountNumber' => getProperty('billaccount'),
'Contact' => null,
'Address' => array('CountryCode' => 'US'))));
return $shippingChargesPayment;
}
function addLabelSpecification(){
$labelSpecification = array(
'LabelFormatType' => 'COMMON2D', // valid values COMMON2D, LABEL_DATA_ONLY
'ImageType' => 'PDF', // valid values DPL, EPL2, PDF, ZPLII and PNG
'LabelStockType' => 'PAPER_8.5X11_TOP_HALF_LABEL');
return $labelSpecification;
}
function addPackageLineItem1($weight){
$packageLineItem = array(
'SequenceNumber'=>1,
'GroupPackageCount'=>1,
'Weight' => array(
'Value' => $weight,
'Units' => 'LB')
);
return $packageLineItem;
}
?>
It returns this http://bigdog.webdesign309.com/assets/shippinglabels/shipexpresslabel1303.pdf
I have tried everything even calling fedex and they say that they provide no support for this issue as the code is a convenience rather than a service. If anyone can shed some light on this most puzzling issue as to why the second address field never shows up that would be great.
Any thoughts on this one?
In case anyone else comes across this problem, note that FedEx's test labels from their staging environment do not appear to ever include the second address line.
All of my test labels did NOT have a second address line, but as soon as I switched to the production server, the labels had the second line.
It should have multiple address lines as your XML looks valid. FedEx support should be able to provide assistance based on the SOAP request/response, but will not provide assistance with your PHP coding.
according to the Ship Service Docs, you only have two address lines, I solved like this:
'Address' => array(
'StreetLines' => array($array_recipient["address_1"],$array_recipient["address_2"]),
'City' => $array_recipient["City"],
'StateOrProvinceCode' => $array_recipient["StateOrProvinceCode"],
'PostalCode' => $array_recipient["PostalCode"],
'CountryCode' => 'MX',
'Residential' => true
)
in case you need more "space" you can use CUSTOMER_REFERENCE (rigth after dimensions):
$packageLineItem = array(
'SequenceNumber'=>1,
'GroupPackageCount'=>1,
'Weight' => array(
'Value' => $dimension_array["weight"],
'Units' => 'KG'
),
'Dimensions' => array(
'Length' => $dimension_array["length"],
'Width' => $dimension_array["width"],
'Height' => $dimension_array["height"],
'Units' => 'CM'
),
'CustomerReferences' => array(
'CustomerReferenceType' => 'CUSTOMER_REFERENCE',
'Value' => $dimension_array["more_references"]
),
If you make the request in Test Enviroment, the second address will not show, but after to production, the second address will shown.
Hope this help you.
I am trying to import the customers into my new magento installation from an old site and want to set customer address as magento customer default billing address i hvae tried
$customer = $this->getCustomerModel();
$address = Mage::getModel('customer/address');
$customer->addAddress($results[0]['address']); //this says trying to save invalide object
$address ->addAddress($results[0]['address']); //this says undefined method
$results[0]['address'] this field contains the street address i have also the city,state, zip,postcode
Any idea about how can i set my customer address as its default billing or shipping address..
Well I have found it with help of Anoop sir.
$_custom_address = array (
'firstname' => 'Branko',
'lastname' => 'Ajzele',
'street' => array (
'0' => 'Sample address part1',
'1' => 'Sample address part2',
),
'city' => 'Osijek',
'region_id' => '',
'region' => '',
'postcode' => '31000',
'country_id' => 'HR', /* Croatia */
'telephone' => '0038531555444',
);
$customAddress = Mage::getModel('customer/address');
//$customAddress = new Mage_Customer_Model_Address();
$customAddress->setData($_custom_address)
->setCustomerId($customer->getId())
->setIsDefaultBilling('1')
->setIsDefaultShipping('1')
->setSaveInAddressBook('1');
try {
$customAddress->save();
}
catch (Exception $ex) {
//Zend_Debug::dump($ex->getMessage());
}