PrestaApi Posted January 5, 2023 Share Posted January 5, 2023 I'm interested in the ability to get information through the endpoints, is it possible to get information, for example, about the product in more detail, characteristics, reviews, options with prices, why the official api look, not full? or do you have to submit your own endpoint for each page?api look, not full? or do you have to submit your own endpoint for each page? Link to comment Share on other sites More sharing options...
LaurentA83 Posted November 13, 2023 Share Posted November 13, 2023 Hello, Have you succeeded and did you manage to ultimately send JSON POST requests ? Link to comment Share on other sites More sharing options...
ventura Posted November 14, 2023 Share Posted November 14, 2023 I think it would be a better option to use ajax with Axios or Fetch Link to comment Share on other sites More sharing options...
LaurentA83 Posted November 14, 2023 Share Posted November 14, 2023 Hello Ventura, Thanks for your answer I am using axios here is my code below. i have a CORS issue that I am trying to figure out (i'm working on my localhost right now) but is my logic here correct ? const handleSubmit = async () => { const xmlData = `<prestashop xmlns:xlink="http://www.w3.org/1999/xlink"> <order> <id_address_delivery><${customerAddress.id}></id_address_delivery> <id_address_invoice><${customerAddress.id}></id_address_invoice> <id_currency><${cartSummary.id_currency}></id_currency> <id_lang><${cartSummary.id_lang}></id_lang> <id_customer><${selectedCustomer.id}></id_customer> <id_carrier><${cartSummary.id_carrier}></id_carrier> <current_state><${cartSummary.current_state}></current_state> <id_shop_group><${cartSummary.id_group_shop}></id_shop_group> <id_shop><${cartSummary.id_shop}></id_shop> <total_discounts><${totalSavings}></total_discounts> <total_paid><${grandTotal}></total_paid> <total_paid_tax_incl><${grandTotal}></total_paid_tax_incl> <total_products><${totalQuantity}></total_products> <associations> <order_rows> ${cart.map((item, index) => { return `<order_row> <id><${index +1 }></id> <product_id><${item.productId}></product_id> <product_quantity><${item.quantity}></product_quantity> <product_name><${item.productName}></product_name> <product_price><${item.total_paid}></product_price> <unit_price_tax_incl><${item.discountedTotal}></unit_price_tax_incl> </order_row>`; }).join('')} </order_rows> </associations> </order> </prestashop>`; console.log(xmlData); try { const config = { headers: { 'Content-Type': 'text/xml', } }; const response = await axios.post('https://dev.mydomainname.com/api/orders?ws_key=${mykey}', xmlData, config); console.log('Réponse de l\'API:', response.data); } catch (error) { console.error('Erreur:', error); } }; Link to comment Share on other sites More sharing options...
ventura Posted November 14, 2023 Share Posted November 14, 2023 for security reasons I do not recommend that you use the prestashop api to get the information. https://devdocs.prestashop-project.org/8/modules/concepts/controllers/front-controllers/#ajax-request You can use a front-controller with an ajax function from which you can send all the business logic that is necessary to access from the js. 1 Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now