IeM Posted September 28, 2012 Share Posted September 28, 2012 How to create orders from external web sites using the latest Prestashop API? I have seen questions like this on Google but have not seen a workable answer. Scenario: Prestashop members currently in another site that is not a shopping cart as such, but allows the members of both sites to order and/or purchase products that have been extracted from the Prestashop using web services. These extracted products are displayed in the other site with a quantity selector and an add to cart button followed by a submit button. For some people the second site may be a cut down mobile site or a membership site. SSL would naturally be used to link the sites for some security. Can/How do we create a Prestashop shopping cart and possibly process it from the second site using web services. If it can't be all done yet, apart from listing the products via the web services, what can be done towards this scenario? Thanks 2 Link to comment Share on other sites More sharing options...
pspahn Posted January 30, 2013 Share Posted January 30, 2013 I too am looking for a solution to this. The documentation does not provide any examples of this process or what is necessary to successfully submit a new order. Are auto-incremented values automatically set? Should a new cart object be built and then submitted with a new order object? Which fields are required? Is there a sample script similar to the one that describes creating a new customer? Link to comment Share on other sites More sharing options...
NemoPS Posted January 30, 2013 Share Posted January 30, 2013 Hi, First of all, I strongly advice you know A LOT of Prestashop's architecture before trying something like this. I never tried such a thing, but I know the software architecture, and i can say that you would need *at least* one "bridge" file between your app and Prestashop. Due to its nature, Prestashop will deny this kind of process, since it requires the basic cofiguration files to be embedded in the code before doing anything (you can try it yourself, anything without the proper configuration will be killed if called within a module/page, like an ajax request. Therefore, I suggest. 1- Study the order controller 2- Study the cart controller 3- Study the authentication controller After this, you should know how to create a new cart with the proper cookie setting. BUT of course it's not over. You'll need all the data prestashop creates and assigns to a cart cookie. This to create the cart. As for processing the cart itself... well. Basically, in 1.5, you only need 1 function call to create an order, this: $this->module->validateOrder($cart->id, Configuration::get('PS_OS_GOLDENPAY'), $total, $this->module->displayName, NULL, $extraVars, (int)$currency->id, false, $customer->secure_key); But as you can see, it's created for every payment module.An you also want the customer to put in its data, and add it to the database (that's why i told you about the authentication controller), and select shipping. Of course, you also have to deal with currencies....geez, I'm getting lost. I suggest you give up ;D Prestashop has too tight security measures to allow this. Of course, it's just my opinion, and someone who knows the software better than me may have a different idea. Cheers! Link to comment Share on other sites More sharing options...
pspahn Posted January 30, 2013 Share Posted January 30, 2013 Thanks for the response. I have managed to build a new cart via the API, submit it, and it adds to my sandbox store just fine. My problem is that I'm getting the error: HTTP XML response is not parsable : array ( 0 => LibXMLError::__set_state(array( 'level' => 3, 'code' => 4, 'column' => 1, 'message' => 'Start tag expected, \'<\' not found ', 'file' => '', 'line' => 1, )), ) I've seen some other users having this same issue, but I have not found a resolution to this. Link to comment Share on other sites More sharing options...
NemoPS Posted January 30, 2013 Share Posted January 30, 2013 Congrats! It means you're not as lazy as i am then! Link to comment Share on other sites More sharing options...
pspahn Posted January 31, 2013 Share Posted January 31, 2013 Still not sure, but this looks like it's working now. I used `cheque` for the required module node (not sure what this node is supposed to be for), and the orders are being submitted now (despite receiving an HTTP500 error after running the script). Link to comment Share on other sites More sharing options...
amelie13 Posted January 31, 2013 Share Posted January 31, 2013 (edited) I have the same problem. I think it's beacause of the accent "é" ... Edited January 31, 2013 by amelie13 (see edit history) Link to comment Share on other sites More sharing options...
NemoPS Posted February 2, 2013 Share Posted February 2, 2013 Uh...I'm so Dumb. Actually, I've never dived into the RESTful API actually, since I don't like the fact that it outputs XML. But thinking about it, yes, you can definitely create new carts. Actually, I'm looking into it right now, I'll update you as soon as i manage to do it corerctly (so that a full cart can be created, and also assigned to the correct customer if needed) Link to comment Share on other sites More sharing options...
EnergieZ Posted February 4, 2013 Share Posted February 4, 2013 (edited) Hi pspahn, I'm triing to do quiet the same thing as you : add some product to the cart from an other website, using the api. When the product is add to the cart, it will go back to the prestashop website, and follow the normal processus. I can't found any documentation about this. Did you found some documentation about this, or can you help me ? Thank's for your help, and sorry for my por english... Edited February 4, 2013 by EnergieZ (see edit history) Link to comment Share on other sites More sharing options...
pspahn Posted February 4, 2013 Share Posted February 4, 2013 I'm pretty busy this morning with launching a new site, once I have a little extra time I will post a solution here. Link to comment Share on other sites More sharing options...
EnergieZ Posted February 4, 2013 Share Posted February 4, 2013 Thanks so much ! Will wait Link to comment Share on other sites More sharing options...
EnergieZ Posted February 6, 2013 Share Posted February 6, 2013 Hi, I'm still looking for a solution. Can you just give me a guidline ? (I don't know how to get the ID of current cart...). In advance, thank you. Link to comment Share on other sites More sharing options...
EnergieZ Posted February 15, 2013 Share Posted February 15, 2013 Hello, have you some time to help me ? In advance, thank you. Link to comment Share on other sites More sharing options...
carlose Posted February 26, 2013 Share Posted February 26, 2013 Hi, how could you identify the customer that create the cart/order from the other website? Could you help with that? Thanks in advance Link to comment Share on other sites More sharing options...
Jose Miguel Valencia Posted May 4, 2013 Share Posted May 4, 2013 Hello, Iam trying to add some product to the cart from an other website, using the api. Does any one know how? Thank you. Link to comment Share on other sites More sharing options...
An'im Fahmy Posted September 7, 2015 Share Posted September 7, 2015 Still nothing solution? This is my xml, but return bad parameter given. <?xml version="1.0" encoding="UTF-8"?> <prestashop xmlns:xlink="http://www.w3.org/1999/xlink"> <order> <id></id> <id_address_delivery>5047</id_address_delivery> <id_address_invoice>5047</id_address_invoice> <id_cart>35</id_cart> <id_currency>1</id_currency> <id_lang>1</id_lang> <id_customer>34</id_customer> <id_carrier>60</id_carrier> <current_state>59</current_state> <module>bca</module> <invoice_number>5296</invoice_number> <invoice_date>2015-09-01 10:24:07</invoice_date> <delivery_number>4441</delivery_number> <delivery_date>2015-09-01 10:25:10</delivery_date> <valid>1</valid> <date_add>2015-09-01 10:24:05</date_add> <date_upd>2015-09-01 10:25:12</date_upd> <shipping_number></shipping_number> <id_shop_group>1</id_shop_group> <id_shop>1</id_shop> <secure_key>e4c36136722e79f90b80ae87492dad91</secure_key> <payment>BCA</payment> <recyclable>0</recyclable> <gift>0</gift> <gift_message>0</gift_message> <mobile_theme>0</mobile_theme> <total_discounts>0</total_discounts> <total_discounts_tax_incl>0</total_discounts_tax_incl> <total_discounts_tax_excl>0</total_discounts_tax_excl> <total_paid>196000</total_paid> <total_paid_tax_incl>196000</total_paid_tax_incl> <total_paid_tax_excl>196000</total_paid_tax_excl> <total_paid_real>196000</total_paid_real> <total_products>196000</total_products> <total_products_wt>196000</total_products_wt> <total_shipping>0</total_shipping> <total_shipping_tax_incl>0</total_shipping_tax_incl> <total_shipping_tax_excl>0</total_shipping_tax_excl> <carrier_tax_rate>0</carrier_tax_rate> <total_wrapping>0</total_wrapping> <total_wrapping_tax_incl>0</total_wrapping_tax_incl> <total_wrapping_tax_excl>0</total_wrapping_tax_excl> <round_mode>2</round_mode> <round_type>2</round_type> <conversion_rate>1</conversion_rate> <reference>JCOMFUHYZ</reference> <associations> <order_rows> <order_row> <product_id>3</product_id> <product_attribute_id>0</product_attribute_id> <product_quantity>4</product_quantity> </order_row> <order_row> <product_id>6</product_id> <product_attribute_id>0</product_attribute_id> <product_quantity>4</product_quantity> </order_row> </order_rows> </associations> </order> </prestashop> {"status":"Other error <br \/>Bad parameters given"} Anyone help? Thank you 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