-
-
Save WanChengCheng/137b8382310170624e92fea436b08654 to your computer and use it in GitHub Desktop.
Create Test-Order on Magento 1.9.3.x with SOAP Api V2
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// debug script | |
// apiDoc: https://devdocs.magento.com/guides/m1x/api/soap/checkout/checkout.html | |
$proxy = new SoapClient('http://lts.localhost/api/v2_soap/?wsdl'); | |
$sessionId = $proxy->login('debug', 'debug123'); | |
// create cart | |
$quoteId = $proxy->shoppingCartCreate($sessionId); | |
// set customer to cart | |
$customerData = array( | |
'firstname' => 'John', | |
'lastname' => 'Doe', | |
'email' => '[email protected]', | |
'mode' => 'guest', | |
'website_id' => '1', | |
'store_id' => '1' | |
); | |
$response = $proxy->shoppingCartCustomerSet($sessionId, $quoteId, $customerData); | |
var_dump($response); | |
// set customer addresses | |
$addressData = array( | |
array( | |
'mode' => 'billing', | |
'firstname' => 'John', | |
'lastname' => 'Doe', | |
'street' => 'Homestreet', | |
'city' => 'St.Gallen', | |
'region' => 'SG', | |
'postcode' => '9000', | |
'country_id' => 'CH', | |
'telephone' => '123456789', | |
'is_default_billing' => 0, | |
'is_default_shipping' => 0 | |
) | |
); | |
$addressData[] = $addressData[0]; | |
$addressData[1]['mode'] = 'shipping'; | |
$response = $proxy->shoppingCartCustomerAddresses($sessionId, $quoteId, $addressData); | |
var_dump($response); | |
// add product | |
$productData = array( | |
array( | |
'product_id' => '337', // from magento sample data | |
'sku' => 'simple_product', | |
'qty' => '1', | |
'options' => null, | |
'bundle_option' => null, | |
'bundle_option_qty' => null, | |
'links' => null | |
) | |
); | |
$response = $proxy->shoppingCartProductAdd($sessionId, $quoteId, $productData); | |
var_dump($response); | |
//var_dump( $proxy->shoppingCartShippingList($sessionId, $quoteId) ); | |
//var_dump( $proxy->shoppingCartPaymentList($sessionId, $quoteId) ); | |
//exit; | |
// set payment | |
$paymentData = array( | |
'po_number' => null, | |
'method' => 'banktransfer', | |
'cc_cid' => null, | |
'cc_owner' => null, | |
'cc_number' => null, | |
'cc_type' => null, | |
'cc_exp_year' => null, | |
'cc_exp_month' => null | |
); | |
$response = $proxy->shoppingCartPaymentMethod($sessionId, $quoteId, $paymentData); | |
var_dump($response); | |
// set shipment | |
$response = $proxy->shoppingCartShippingMethod($sessionId, $quoteId, 'flatrate_flatrate'); | |
var_dump($response); | |
// show quote data | |
$response = $proxy->shoppingCartInfo($sessionId, $quoteId); | |
var_dump($response); | |
// place order | |
$response = $proxy->shoppingCartOrder($sessionId, $quoteId, null, null); | |
var_dump($response); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment