Store have configurable product, which costs 750 ("base version"), via API I want to buy configured product, which costs 1500. When I just try to get shoppingCartTotals()
, I get right prices (with right tax), but when I try to get shipping and payment methods - prices changing.
Here is code:
<?php
$proxy = new SoapClient('http://example.com/index.php/api/v2_soap/?wsdl');
$sessionId = $proxy->login('ApiUser', 'ApiKey');
$quoteId = $proxy->shoppingCartCreate( $sessionId, 3 );
/*$customerData = array(
"firstname" => "-",
"lastname" => "-",
"email" => "[email protected]",
"mode" => "guest",
"website_id" => "0"
);*/
//$proxy->shoppingCartCustomerSet($sessionId, $quoteId, $customerData);
$proxy->shoppingCartCustomerAddresses($sessionId, $quoteId, array(array(
'mode' => 'billing',
'firstname' => '-',
'lastname' => '-',
'street' => '-',
'city' => '-',
'region' => '-',
'postcode' => '-',
'country_id' => 'UK',
'telephone' => '-',
'is_default_billing' => 1
)));
$proxy->shoppingCartProductAdd(
$sessionId,
$quoteId,
array(
array(
'sku' => '111111',
'qty' => '1',
'options' => array(
array(
"key" => 111,
"value" => 1212,
)
),
)
),
3 //storeId
);
//Uncomment following lines for price changing
//$result_payment = $proxy->shoppingCartPaymentMethod($sessionId, $quoteId, array('method' => 'checkmo'), 3);
//$result_shipping = $proxy->shoppingCartShippingMethod($sessionId, $quoteId, 'freeshipping_freeshipping', 3);
//echo var_dump(array('shoppingCartPaymentMethod' => $result_payment,'shoppingCartShippingMethod' => $result_shipping));
//$result = $proxy->shoppingCartInfo($sessionId, $quoteId, 3);
//var_dump($result);
$result = $proxy->shoppingCartTotals($sessionId, $quoteId, 3);
var_dump($result);
And here is results:
Without shipping and payment methods:
array(3) { [0]=> object(stdClass)#2 (2) { ["title"]=> string(8) "Subtotal" ["amount"]=> float(1500) } [1]=> object(stdClass)#3 (2) { ["title"]=> string(3) "Tax" ["amount"]=> float(300) } [2]=> object(stdClass)#4 (2) { ["title"]=> string(11) "Grand Total" ["amount"]=> float(1500) } }
With shipping and payment methods:
array(2) { ["shoppingCartPaymentMethod"]=> bool(true) ["shoppingCartShippingMethod"]=> bool(true) } array(4) { [0]=> object(stdClass)#2 (2) { ["title"]=> string(8) "Subtotal" ["amount"]=> float(780) } [1]=> object(stdClass)#3 (2) { ["title"]=> string(3) "Tax" ["amount"]=> float(156) } [2]=> object(stdClass)#4 (2) { ["title"]=> string(40) "Shipping & Handling (Fri frakt - Gratis)" ["amount"]=> float(0) } [3]=> object(stdClass)#5 (2) { ["title"]=> string(11) "Grand Total" ["amount"]=> float(780) } }
What am I doing wrong?