Jonathan btq Posted April 12, 2023 Share Posted April 12, 2023 I am developing a tool that communicates with API (Prestashop API) using Python. When I try to create an order with a product, everything seems to work fine, but the I want to put a personnal reference and I dont find any empty parameters. I have try to change id and reference but it dont want to change. Details: Order creation successful with the specified product Stock but need an empty parameters to put my reference I have try to change id and reference but it dont want to change. When I save the order, prestashop put their reference. # This is the order parameters: orderJ = { 'reference': 'test', 'id_currency': 1, 'id_carrier': 1, 'id_lang': 1, 'current_state': 'PS_OS_PAYMENT_ACCEPTED', 'module': 'ps_checkpayment', 'payment': 'ps_checkpayment', 'total_paid': order["base_subtotal"], 'total_paid_real': order["base_shipping_amount"], 'total_products': order["base_shipping_incl_tax"], 'total_products_wt': '13.120000', 'conversion_rate': order["total_incl_tax"], } response = ord.createOrder(userJ, addressJ, billadressJ, cartJ, itemJ, orderJ) I have try this too: # Mise a jour de la reference # ord = prestashop.get('orders', response['prestashop']['order']['id']) # ordid = ord['order']['id'] # ord['order']['reference'] = 'test' # edit = prestashop.edit('orders', ordid, ord) # print(edit) How can I put paramaters to find my reference in order? Thanks for your help Link to comment Share on other sites More sharing options...
Eutanasio Posted April 22, 2023 Share Posted April 22, 2023 Based on the code snippet you've provided, it seems you're trying to set the reference directly while creating the order. However, the Prestashop API might not allow you to set the reference directly upon order creation. Instead, you can try updating the order reference after creating the order. You have tried updating the order reference in your code, but there are some issues with it. Here's the corrected version of your code to update the order reference: # Create the order response = ord.createOrder(userJ, addressJ, billadressJ, cartJ, itemJ, orderJ) # Get the order ID order_id = response['prestashop']['order']['id'] # Retrieve the order details order_details = prestashop.get('orders', order_id) # Update the reference order_details['order']['reference'] = 'test' # Save the updated order prestashop.edit('orders', order_id, order_details) This code will create the order, retrieve the order details using the returned order ID, update the reference, and then save the updated order back to Prestashop. Make sure to replace prestashop with the correct variable name representing your Prestashop API instance. 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