cancel
Showing results for 
Search instead for 
Did you mean: 

API Coupons

SOLVED

API Coupons

We have built an API integration for our fulfilment house but need to access whether a specific coupon code has been used in the order.

Our call to the shopping cart is GetOrders that meet a criteria but cannot see where we can find a coupon code in the API return.

Our customer is using this to indicate whether the item is a 'customer collect' from the warehouse. 

If this is not possible can someone suggest an alternative to this

Thanks

Bryn Hackland

1 ACCEPTED SOLUTION

Accepted Solutions

Re: API Coupons

Hello @bryn_hackland,

 

Here is an example of get coupon data of order info, You can find coupon_code in response

Request Example SOAP V1

 

$client = new SoapClient('http://magentohost/api/soap/?wsdl');

// If somestuff requires api authentication,
// then get a session token
$session = $client->login('apiUser', 'apiKey');

$result = $client->call($session, 'sales_order.info', 'orderIncrementId');
var_dump($result);

// If you don't need the session anymore
//$client->endSession($session);

Request Example SOAP V2

 

 

$proxy = new SoapClient('http://magentohost/api/v2_soap/?wsdl'); // TODO : change url
$sessionId = $proxy->login('apiUser', 'apiKey'); // TODO : change login and pwd if necessary

$result = $proxy->salesOrderInfo($sessionId, '200000006');
var_dump($result);

Request Example SOAP V2 (WS-I Compliance Mode)

 

$proxy = new SoapClient('http://magentohost/api/v2_soap/?wsdl'); 

$sessionId = $proxy->login((object)array('username' => 'apiUser', 'apiKey' => 'apiKey')); 
 
$result = $proxy->salesOrderInfo((object)array('sessionId' => $sessionId->result, 'orderIncrementId' => '200000006'));   
var_dump($result->result);

Response Example SOAP V1

 

 

array
  'state' => string 'new' (length=3)
  'status' => string 'pending' (length=7)
  'coupon_code' => null
  'protect_code' => string 'defe18' (length=6)
  'shipping_description' => string 'Flat Rate - Fixed' (length=17)
  'is_virtual' => string '0' (length=1)
  'store_id' => string '2' (length=1)
  'customer_id' => string '2' (length=1)
  'base_discount_amount' => string '0.0000' (length=6)
  'base_discount_canceled' => null
  'base_discount_invoiced' => null
  'base_discount_refunded' => null
  'base_grand_total' => string '619.9700' (length=8)
  'base_shipping_amount' => string '10.0000' (length=7)
  'base_shipping_canceled' => null
  'base_shipping_invoiced' => null
  'base_shipping_refunded' => null
  'base_shipping_tax_amount' => string '0.0000' (length=6)
  'base_shipping_tax_refunded' => null
  'base_subtotal' => string '609.9700' (length=8)
  'base_subtotal_canceled' => null
  'base_subtotal_invoiced' => null
  'base_subtotal_refunded' => null
  'base_tax_amount' => string '0.0000' (length=6)
  'base_tax_canceled' => null
  'base_tax_invoiced' => null
  'base_tax_refunded' => null
  'base_to_global_rate' => string '1.0000' (length=6)
  'base_to_order_rate' => string '1.0000' (length=6)
  'base_total_canceled' => null
  'base_total_invoiced' => null
  'base_total_invoiced_cost' => null
  'base_total_offline_refunded' => null
  'base_total_online_refunded' => null
  'base_total_paid' => null
  'base_total_qty_ordered' => null
  'base_total_refunded' => null
  'discount_amount' => string '0.0000' (length=6)
  'discount_canceled' => null
  'discount_invoiced' => null
  'discount_refunded' => null
  'grand_total' => string '619.9700' (length=8)
  'shipping_amount' => string '10.0000' (length=7)
  'shipping_canceled' => null
  'shipping_invoiced' => null
  'shipping_refunded' => null
  'shipping_tax_amount' => string '0.0000' (length=6)
  'shipping_tax_refunded' => null
  'store_to_base_rate' => string '1.0000' (length=6)
  'store_to_order_rate' => string '1.0000' (length=6)
  'subtotal' => string '609.9700' (length=8)
  'subtotal_canceled' => null
  'subtotal_invoiced' => null
  'subtotal_refunded' => null
  'tax_amount' => string '0.0000' (length=6)
  'tax_canceled' => null
  'tax_invoiced' => null
  'tax_refunded' => null
  'total_canceled' => null
  'total_invoiced' => null
  'total_offline_refunded' => null
  'total_online_refunded' => null
  'total_paid' => null
  'total_qty_ordered' => string '2.0000' (length=6)
  'total_refunded' => null
  'can_ship_partially' => null
  'can_ship_partially_item' => null
  'customer_is_guest' => string '0' (length=1)
  'customer_note_notify' => string '1' (length=1)
  'billing_address_id' => string '1' (length=1)
  'customer_group_id' => string '1' (length=1)
  'edit_increment' => null
  'email_sent' => string '1' (length=1)
  'forced_shipment_with_invoice' => null
  'payment_auth_expiration' => null
  'quote_address_id' => null
  'quote_id' => string '1' (length=1)
  'shipping_address_id' => string '2' (length=1)
  'adjustment_negative' => null
  'adjustment_positive' => null
  'base_adjustment_negative' => null
  'base_adjustment_positive' => null
  'base_shipping_discount_amount' => string '0.0000' (length=6)
  'base_subtotal_incl_tax' => string '609.9700' (length=8)
  'base_total_due' => null
  'payment_authorization_amount' => null
  'shipping_discount_amount' => string '0.0000' (length=6)
  'subtotal_incl_tax' => string '609.9700' (length=8)
  'total_due' => null
  'weight' => string '1.2000' (length=6)
  'customer_dob' => null
  'increment_id' => string '200000001' (length=9)
  'applied_rule_ids' => null
  'base_currency_code' => string 'USD' (length=3)
  'customer_email' => string 'john@example.com' (length=16)
  'customer_firstname' => string 'johny' (length=5)
  'customer_lastname' => string 'doe' (length=3)
  'customer_middlename' => null
  'customer_prefix' => null
  'customer_suffix' => null
  'customer_taxvat' => null
  'discount_description' => null
  'ext_customer_id' => null
  'ext_order_id' => null
  'global_currency_code' => string 'USD' (length=3)
  'hold_before_state' => null
  'hold_before_status' => null
  'order_currency_code' => string 'USD' (length=3)
  'original_increment_id' => null
  'relation_child_id' => null
  'relation_child_real_id' => null
  'relation_parent_id' => null
  'relation_parent_real_id' => null
  'remote_ip' => string '127.0.0.1' (length=9)
  'shipping_method' => string 'flatrate_flatrate' (length=17)
  'store_currency_code' => string 'USD' (length=3)
  'store_name' => string 'website
English store
English' (length=29)
  'x_forwarded_for' => null
  'customer_note' => null
  'created_at' => string '2012-03-30 11:40:30' (length=19)
  'updated_at' => string '2012-03-30 11:40:32' (length=19)
  'total_item_count' => string '2' (length=1)
  'customer_gender' => null
  'hidden_tax_amount' => string '0.0000' (length=6)
  'base_hidden_tax_amount' => string '0.0000' (length=6)
  'shipping_hidden_tax_amount' => string '0.0000' (length=6)
  'base_shipping_hidden_tax_amnt' => string '0.0000' (length=6)
  'hidden_tax_invoiced' => null
  more elements...

 

 

--
If my answer is useful, please Accept as Solution & give Kudos

 

View solution in original post

2 REPLIES 2

Re: API Coupons

Hello @bryn_hackland,

 

Here is an example of get coupon data of order info, You can find coupon_code in response

Request Example SOAP V1

 

$client = new SoapClient('http://magentohost/api/soap/?wsdl');

// If somestuff requires api authentication,
// then get a session token
$session = $client->login('apiUser', 'apiKey');

$result = $client->call($session, 'sales_order.info', 'orderIncrementId');
var_dump($result);

// If you don't need the session anymore
//$client->endSession($session);

Request Example SOAP V2

 

 

$proxy = new SoapClient('http://magentohost/api/v2_soap/?wsdl'); // TODO : change url
$sessionId = $proxy->login('apiUser', 'apiKey'); // TODO : change login and pwd if necessary

$result = $proxy->salesOrderInfo($sessionId, '200000006');
var_dump($result);

Request Example SOAP V2 (WS-I Compliance Mode)

 

$proxy = new SoapClient('http://magentohost/api/v2_soap/?wsdl'); 

$sessionId = $proxy->login((object)array('username' => 'apiUser', 'apiKey' => 'apiKey')); 
 
$result = $proxy->salesOrderInfo((object)array('sessionId' => $sessionId->result, 'orderIncrementId' => '200000006'));   
var_dump($result->result);

Response Example SOAP V1

 

 

array
  'state' => string 'new' (length=3)
  'status' => string 'pending' (length=7)
  'coupon_code' => null
  'protect_code' => string 'defe18' (length=6)
  'shipping_description' => string 'Flat Rate - Fixed' (length=17)
  'is_virtual' => string '0' (length=1)
  'store_id' => string '2' (length=1)
  'customer_id' => string '2' (length=1)
  'base_discount_amount' => string '0.0000' (length=6)
  'base_discount_canceled' => null
  'base_discount_invoiced' => null
  'base_discount_refunded' => null
  'base_grand_total' => string '619.9700' (length=8)
  'base_shipping_amount' => string '10.0000' (length=7)
  'base_shipping_canceled' => null
  'base_shipping_invoiced' => null
  'base_shipping_refunded' => null
  'base_shipping_tax_amount' => string '0.0000' (length=6)
  'base_shipping_tax_refunded' => null
  'base_subtotal' => string '609.9700' (length=8)
  'base_subtotal_canceled' => null
  'base_subtotal_invoiced' => null
  'base_subtotal_refunded' => null
  'base_tax_amount' => string '0.0000' (length=6)
  'base_tax_canceled' => null
  'base_tax_invoiced' => null
  'base_tax_refunded' => null
  'base_to_global_rate' => string '1.0000' (length=6)
  'base_to_order_rate' => string '1.0000' (length=6)
  'base_total_canceled' => null
  'base_total_invoiced' => null
  'base_total_invoiced_cost' => null
  'base_total_offline_refunded' => null
  'base_total_online_refunded' => null
  'base_total_paid' => null
  'base_total_qty_ordered' => null
  'base_total_refunded' => null
  'discount_amount' => string '0.0000' (length=6)
  'discount_canceled' => null
  'discount_invoiced' => null
  'discount_refunded' => null
  'grand_total' => string '619.9700' (length=8)
  'shipping_amount' => string '10.0000' (length=7)
  'shipping_canceled' => null
  'shipping_invoiced' => null
  'shipping_refunded' => null
  'shipping_tax_amount' => string '0.0000' (length=6)
  'shipping_tax_refunded' => null
  'store_to_base_rate' => string '1.0000' (length=6)
  'store_to_order_rate' => string '1.0000' (length=6)
  'subtotal' => string '609.9700' (length=8)
  'subtotal_canceled' => null
  'subtotal_invoiced' => null
  'subtotal_refunded' => null
  'tax_amount' => string '0.0000' (length=6)
  'tax_canceled' => null
  'tax_invoiced' => null
  'tax_refunded' => null
  'total_canceled' => null
  'total_invoiced' => null
  'total_offline_refunded' => null
  'total_online_refunded' => null
  'total_paid' => null
  'total_qty_ordered' => string '2.0000' (length=6)
  'total_refunded' => null
  'can_ship_partially' => null
  'can_ship_partially_item' => null
  'customer_is_guest' => string '0' (length=1)
  'customer_note_notify' => string '1' (length=1)
  'billing_address_id' => string '1' (length=1)
  'customer_group_id' => string '1' (length=1)
  'edit_increment' => null
  'email_sent' => string '1' (length=1)
  'forced_shipment_with_invoice' => null
  'payment_auth_expiration' => null
  'quote_address_id' => null
  'quote_id' => string '1' (length=1)
  'shipping_address_id' => string '2' (length=1)
  'adjustment_negative' => null
  'adjustment_positive' => null
  'base_adjustment_negative' => null
  'base_adjustment_positive' => null
  'base_shipping_discount_amount' => string '0.0000' (length=6)
  'base_subtotal_incl_tax' => string '609.9700' (length=8)
  'base_total_due' => null
  'payment_authorization_amount' => null
  'shipping_discount_amount' => string '0.0000' (length=6)
  'subtotal_incl_tax' => string '609.9700' (length=8)
  'total_due' => null
  'weight' => string '1.2000' (length=6)
  'customer_dob' => null
  'increment_id' => string '200000001' (length=9)
  'applied_rule_ids' => null
  'base_currency_code' => string 'USD' (length=3)
  'customer_email' => string 'john@example.com' (length=16)
  'customer_firstname' => string 'johny' (length=5)
  'customer_lastname' => string 'doe' (length=3)
  'customer_middlename' => null
  'customer_prefix' => null
  'customer_suffix' => null
  'customer_taxvat' => null
  'discount_description' => null
  'ext_customer_id' => null
  'ext_order_id' => null
  'global_currency_code' => string 'USD' (length=3)
  'hold_before_state' => null
  'hold_before_status' => null
  'order_currency_code' => string 'USD' (length=3)
  'original_increment_id' => null
  'relation_child_id' => null
  'relation_child_real_id' => null
  'relation_parent_id' => null
  'relation_parent_real_id' => null
  'remote_ip' => string '127.0.0.1' (length=9)
  'shipping_method' => string 'flatrate_flatrate' (length=17)
  'store_currency_code' => string 'USD' (length=3)
  'store_name' => string 'website
English store
English' (length=29)
  'x_forwarded_for' => null
  'customer_note' => null
  'created_at' => string '2012-03-30 11:40:30' (length=19)
  'updated_at' => string '2012-03-30 11:40:32' (length=19)
  'total_item_count' => string '2' (length=1)
  'customer_gender' => null
  'hidden_tax_amount' => string '0.0000' (length=6)
  'base_hidden_tax_amount' => string '0.0000' (length=6)
  'shipping_hidden_tax_amount' => string '0.0000' (length=6)
  'base_shipping_hidden_tax_amnt' => string '0.0000' (length=6)
  'hidden_tax_invoiced' => null
  more elements...

 

 

--
If my answer is useful, please Accept as Solution & give Kudos

 

Re: API Coupons

Thanks for this.

 

This has helped me a lot.

I'm using a Nuget .net plugin for  a MagentoAPI wrapper and it is this that is not picking up the coupon code.

Thanks for pointing me in the right direction

 

Bryn