Question

I am trying to call all the customer info after placing an order and insert all these info into a database. All the parameters are passing ok beside getStreet() which ends up as array into database, Just the word array is inserted into database.

Here is my code:

$client = new SoapClient('http://xxxxxxxxxx', array("connection_timeout"=>120));


$aWebOrder->CustomerAddress = new CustomerAddress;
$aWebOrder->CustomerAddress->Email              = $order->getCustomerEmail(); 
$aWebOrder->CustomerAddress->Address1           = $order->getBillingAddress()->getStreet();
$aWebOrder->CustomerAddress->City               = $order->getBillingAddress()->getCity();
$aWebOrder->CustomerAddress->State              = $order->getBillingAddress()->getRegion();
$aWebOrder->CustomerAddress->PostalCode         = $order->getBillingAddress()->getPostcode();
$aWebOrder->CustomerAddress->CountryID          = $order->getBillingAddress()->getCountry();

    $params = array(
    'OrderWebAPILogin' => array("login" => 'xxx', "password"=> 'xxx'),
    'DbVersion' => 16,
    'Order' => $aWebOrder,
    'RequestOptions' => NULL
    );

  $result = $client->addOrder($params);

The error i get into the log file is :

Array to string conversion in C:\xampp\htdocs\xxx\app\code\local\InsertOrder\OrderExport\Model\Export.php on line 215

The line 215 is this line:

 $result = $client->addOrder($params);
Was it helpful?

Solution

Use $order->getBillingAddress()->getData('street') and it returns string format data. If you use $order->getBillingAddress()->getStreet() it returns array which is contains street1 and street2 data. See Mage_Customer_Model_Address_Abstract class for further information.

Licensed under: CC-BY-SA with attribution
Not affiliated with magento.stackexchange
scroll top