AbanteCart Community
AbanteCart Development => API Development => Topic started by: Rawinder on October 21, 2020, 01:28:58 AM
-
i'm developing an android app . that interact with API.
all other Post Commands are working in app except one. and i'm not getting the reason behind this
In App i'm Sending Post Command
rt= a/checkout/shipping
token= xxxxxxxxx
mode=Select
shipping_method=default_free_shipping.default_free_shipping
api_key=112233
in android this command return result set of Mode=list command.(means all the data like Shipping Method list)
when i run this Post in Postman .
on first run it Returns Result set Of Mode=List(means all the data like Shipping Method list)
on 2nd run it return its actual out put (status=1, Shipping_method Select)
checking headers and other this but couldn't able to solve this problem
plz help
-
I am trying to clarify the question. Are you expecting to see the same list all the time?
What version of Abantecart do you have?
-
I think this is related to the session used in the API. API and requests should be stateless and you will need to provide a full request every time.
What you experience with Android is correct behavior.
We will disable session in the API for version 1.2.17.
I have create an issue here: https://github.com/abantecart/abantecart-src/issues/1435
Feel free to add to it if you have any other suggestions.
-
I am trying to clarify the question. Are you expecting to see the same list all the time?
What version of Abantecart do you have?
no, from android app , (as i already know the shipping methods) i dont need to access list with mode =List
so i want to use "mode= Select" Command(that selects shipping Method)
but Mode=Select Command returns list of shipping Method options
its actual output must be
{
"status": 1,
"shipping_select": "success"
}
in postman it returns this output on when i Run this command 2nd time .
-
I am trying to clarify the question. Are you expecting to see the same list all the time?
What version of Abantecart do you have?
im using an older version
-
ok admin :-(
-
if (!isset($this->session->data[ 'shipping_methods' ]) || !$this->config->get('config_shipping_session')) {
$quote_data = array();
$results = $this->model_checkout_extension->getExtensions('shipping');
foreach ($results as $result) {
$this->loadModel('extension/' . $result[ 'key' ]);
$quote = $this->{'model_extension_' . $result[ 'key' ]}->getQuote($shipping_address);
if ($quote) {
$quote_data[ $result[ 'key' ] ] = array(
'title' => $quote[ 'title' ],
'quote' => $quote[ 'quote' ],
'sort_order' => $quote[ 'sort_order' ],
'error' => $quote[ 'error' ]
);
}
}
$sort_order = array();
foreach ($quote_data as $key => $value) {
$sort_order[ $key ] = $value[ 'sort_order' ];
}
array_multisort($sort_order, SORT_ASC, $quote_data);
$this->session->data[ 'shipping_methods' ] = $quote_data;
}
this function from API print List of shipping methods when condition is true
can someone plz explain the line below?
!$this->config->get('config_shipping_session'))
-
config_shipping_session is used to be for optimize number of request to shipping providers and minimize re-qoute requests.
This will not be helpful in API case as session can not be used.
-
Thx
-
Rawinder,
Please feel free to provide some feedback and we would be glad to work together and improve Abantecart storefront API.
Version 1.2.17 is active in development now, we can incorporate API updates as well.
-
ok admin , i will
for above problems i drop the idea of executing shipping selection command directly. instead i executed mode =list the select command.
this solved my problem. now im able to select shipping method.