Posting in the Magento forums has been disabled pending the implementation of a new and improved forum solution which should better serve the community.

For new questions please post at magento.stackexchange.com, the community-run support site for the Magento community. We will be providing updates on the new forum solution soon. For questions or concerns please email community@magento.com.

Magento Forum

Web service/API: retrieve orders’ and customers’ details
 
simsab
Jr. Member
 
Total Posts:  5
Joined:  2009-02-18
 

Dear Magento Community,

I hope this forum is the right one to place my questions. If not please tell me and I’ll move the topic to the correct one.

I am working on a web application/gateway that collects information from pending orders and delivers the information to a dispatch company. The application communicates with Magento through the SOAP web service/API and I am having trouble retrieving all needed data. Either the documentation or the API doesn’t seem to be 100% complete or I missed some important parts. I have definitely tried to solve my problems reading the documentation, though.

My questions concerning the API or - alternatively - the database structure are:
1. Where do I find a customer’s date of birth or other fields customising Magento’s customer details such as a person’s title?
2a. Where do I find the selected billing method?
2b. Where do I find the selected payment method?
2c. Where do I find the selected delivery method?
=> Only the shipping method is provided by the API.
3. Where do I find the bank account information (if given)?
4a. Where do I find a product’s tax class?
4b. Where do I find a single product’s price?
5. When unauthenticated users process an order their address is stored in the database but in some cases the API throws an exception telling that the address does not exist any longer. How can I solve this problem?

Any help is greatly appreciated!

Kind regards,
Simon (from Berlin, Germany)

 
Magento Community Magento Community
Magento Community
Magento Community
 
simsab
Jr. Member
 
Total Posts:  5
Joined:  2009-02-18
 

For those who like to read code or need an idea of how I am approaching this task, here is an excerpt of the gateway, written in PHP:

<?php

function retrieveOrders() {
    $orders 
= array();
    
$magento_orders soapCall('sales_order.list', array(array('status' => 'pending')));
    
    foreach (
$magento_orders as $n => $magento_order{
        $orders[] 
Order::convert($magento_order);
    
}
    
    
return $orders;
}

class Order {
    
// left out logic in order to improve the readableness
    
    
public static function convert($magento_order{
        
try {
            
if (!$magento_order['customer_is_guest']$magento_customer soapCall('customer.info'$magento_order['customer_id']);
            else throw new 
Exception('customer_is_guest');
        
catch (Exception $e{
            $magento_customer 
= array(
                
'customer_id' => 0,
                
'created_in' => 'German'
            
);
        
}
        
try {
            
// unauthenticated users' addresses are also stored in the database
            
$magento_billing_address soapCall('customer_address.info'$magento_order['billing_address_id']);
            
$magento_shipping_address soapCall('customer_address.info'$magento_order['shipping_address_id']);
        
catch (Exception $e{
            $address 
= array(
                
'telephone' => '',
                
'fax' => '',
                
'street' => '',
                
'postcode' => '',
                
'country_id' => '',
                
'city' => ''
            
);
            
            
$magento_billing_address $address;
            
$magento_shipping_address $address;
        
}
        
        $order 
= new Order;
        
        
$order->customer->id $magento_customer['customer_id'];
        
$order->customer->telephone $magento_billing_address['telephone'];
        
$order->customer->fax $magento_billing_address['fax'];
        
$order->customer->email $magento_order['customer_email'];
        
$order->customer->language_code self::retrieveLanguageCode($magento_customer['created_in']);
        
$order->customer->date_of_birth '';//TODO
        
$order->customer->bank_account '';//TODO
        
$order->customer->bank_code '';//TODO
        
$order->customer->bank_account_holder '';//TODO
        
$order->customer->currency_code self::retrieveCurrencyCode($magento_order['order_currency_code']);
        
$order->customer->billing_method self::retrieveBillingMethod('');//TODO
        
$order->customer->payment_method self::retrievePaymentMethod('');//TODO
        
$order->customer->shipping_method self::retrieveShippingMethod($magento_order['shipping_method']);
        
$order->customer->delivery_method self::retrieveDeliveryMethod();//TODO
        
        
$order->billing_address->title 1;//TODO
        
$order->billing_address->last_name $magento_order['billing_lastname'];
        
$order->billing_address->first_name $magento_order['billing_firstname'];
        
$order->billing_address->street self::retrieveStreet($magento_billing_address['street']);
        
$order->billing_address->house_number self::retrieveHouseNumber($magento_billing_address['street']);
        
$order->billing_address->post_code $magento_billing_address['postcode'];
        
$order->billing_address->city $magento_billing_address['city'];
        
$order->billing_address->country_code self::retrieveCountryCode($magento_billing_address['country_id']);
        
        
$order->shipping_address->title 1;//TODO
        
$order->shipping_address->last_name $magento_order['shipping_lastname'];
        
$order->shipping_address->first_name $magento_order['shipping_firstname'];
        
$order->shipping_address->street self::retrieveStreet($magento_shipping_address['street']);
        
$order->shipping_address->house_number self::retrieveHouseNumber($magento_shipping_address['street']);
        
$order->shipping_address->post_code $magento_shipping_address['postcode'];
        
$order->shipping_address->city $magento_shipping_address['city'];
        
$order->shipping_address->country_code self::retrieveCountryCode($magento_shipping_address['country_id']);
        
        
$order->order->id $magento_order['increment_id'];
        
$order->order->date self::convertDate($magento_order['updated_at']);
        
$order->order->order_index self::retrieveOrderIndex();
        
$order->order->customer_group self::retrieveCustomerGroup('');//TODO
        
$order->order->billing_method 1;//TODO
        
$order->order->payment_method 1;//TODO
        
$order->order->shipping_method 4;//TODO
        
$order->order->delivery_method 1;//TODO
        
$order->order->debit_bank_account '';//TODO
        
$order->order->debit_bank_code '';//TODO
        
$order->order->debit_bank '';//TODO
        
        
foreach (self::getProducts($magento_order['order_id']) as $n => $product{
            $order
->products[] = new OrderProduct($order$product);
        
}
        
        
foreach ($order->products as $n => $product{
            $product
->position $n 1;
            
$product->sku $product->getSku();
            
$product->quantity self::convertFloat($product->getQuantity());
            
$product->price 0;//TODO
            
$product->after_tax_price 0;//TODO
            
$product->order_index self::retrieveOrderIndex();
            
$product->customer_group self::retrieveCustomerGroup('');//TODO
        
}
        
        
return $order;
    
}
}

?>
 
Magento Community Magento Community
Magento Community
Magento Community
 
simsab
Jr. Member
 
Total Posts:  5
Joined:  2009-02-18
 

Hey folks,

is there really nobody who can help me? The problem here is kind of urgent
and I don’t have a clue how to solve it. I don’t except anyone to write code for
me or take over all the work - just a little hint would really be appreciated!

Thanks a lot,
Simon

Edit: Okay, problems solved. Basically,

$magento_order soapCall('sales_order.info'$magento_order['increment_id']);
did the trick, populating the order array with nearly all needed data.
 
Magento Community Magento Community
Magento Community
Magento Community
Magento Community
Magento Community
Back to top