Feature request from RUjmiak, posted on GitHub Oct 19, 2016
- Magento 2.1.2
Steps to reproduce
- Customer login
- Create cart (carts/mine)
- Add product to cart
- Create address (via put customers/me)
- Now I have address ID 109115
- I checked available shipping for my address (V1/carts/mine/estimate-shipping-methods-by-address-id) and in response I get that flatrate is available.
Expected result
- One simple call with which I can add shipping address ID to cart.
Actual result
- You need to use POST V1/carts/mine/shipping-information where you cant use just ID
{
"addressInformation": {
"shippingAddress": {
"id": 109115,
"customerAddressId": 109115
},
"shippingMethodCode": "flatrate",
"shippingCarrierCode": "flatrate"
}
}
result: Error 400 Shipping address is not set
or when
{
"addressInformation": {
"shippingAddress": {
"customerAddressId": 109115
},
"shippingMethodCode": "flatrate",
"shippingCarrierCode": "flatrate"
}
}
result: Error 400 Shipping address is not set
or when
{
"addressInformation": {
"shippingAddress": {
"id": 109115
},
"shippingMethodCode": "flatrate",
"shippingCarrierCode": "flatrate"
}
}
result: Error 400 Shipping address is not set
OK lets to add address. Here is another funny part. You cant use address ID because it is not working (and we are just starting)
{
"addressInformation": {
"shippingAddress": {
"id": 109115,
"region": "",
"regionId": 0,
"regionCode": "",
"countryId": "SK",
"street": [
"string"
],
"telephone": "0902222",
"postcode": "82100",
"city": "Bratislava",
"firstname": "My name",
"lastname": "My last name",
"customerAddressId": 109115,
"customerId": 124252
},
"shippingMethodCode": "flatrate",
"shippingCarrierCode": "flatrate"
}
}
response
Error 400: Unable to save shipping information. Please check input data.
Here we can look on another weird thing - why right now we are using another address attribute name asi it is on customers/me calls? For example on customers/me call
region is array, customer_id vs customerId, region_id vs regionId, country_id vs countryId... The right hand does not know what makes left...
So how we can set saved address to cart? We cant... What we need to do is to get address from customers/me, then rewrite it to different structure in shipping-information call AND delete address ID. So call should look like
{
"addressInformation": {
"shippingAddress": {
"region": "",
"regionId": 0,
"regionCode": "",
"countryId": "SK",
"street": [
"string"
],
"telephone": "0902222",
"postcode": "82100",
"city": "Bratislava",
"firstname": "My name",
"lastname": "My last name"
},
"shippingMethodCode": "flatrate",
"shippingCarrierCode": "flatrate"
}
}
Vuala - this is working - but is this good? I think that this is bug and it should be done more simple.
Thanks guys