Jump to content

How to get shipping price for order (webservice)


Recommended Posts

Hello,

I am fulfilling an order using Webservice API. The steps are: creating customer, creating address for the customer,  creating cart with address and customer, and the last step - creating order using customer, address and cart i created prior. 

How do I get shipping calculation for the said cart / order? I know the carrier id. 

Share this post


Link to post
Share on other sites
  • 2 weeks later...

 If you have the cart object itself available, you can use its getPackageShippingCost() method. You can try multiple carrier ids if needed

Share this post


Link to post
Share on other sites

I am utilizing PS API from a remote server, can't edit PrestaShop files or use any of php methods in PrestaShop. I am basically stuck with this god awful medieval times API with no docs and basically no support 😕

Share this post


Link to post
Share on other sites

Up, still looking.

What's the thought process behind PrestaShop WebService? It's basically useless if you need to interact with it from outside

Share this post


Link to post
Share on other sites
  • 8 months later...
  • 1 month later...

Hi, i don't know if you still have a problem with that but i will post it here anyway.

I'm using Prestashop 1.7

when you call endpoint: [GET] /api/orders?output_format=JSON&display=full

you will get list of your orders with all informations like that:

{
            "id": 6,
            "id_address_delivery": "7",
            "id_address_invoice": "7",
            "id_cart": "7",
            "id_currency": "1",
            "id_lang": "1",
            "id_customer": "3",
            "id_carrier": "2",
            "current_state": "2",
            "module": "ps_checkpayment",
            "invoice_number": "1",
            "invoice_date": "2020-04-17 12:23:24",
            "delivery_number": "0",
            "delivery_date": "0000-00-00 00:00:00",
            "valid": "1",
            "date_add": "2020-04-17 12:23:24",
            "date_upd": "2020-04-17 12:23:24",
            "shipping_number": "",
            "id_shop_group": "1",
            "id_shop": "1",
            "secure_key": "9dfbd1c971286da8c10955126a3ef1d6",
            "payment": "Czek",
            "recyclable": "0",
            "gift": "0",
            "gift_message": "",
            "mobile_theme": "0",
            "total_discounts": "0.000000",
            "total_discounts_tax_incl": "0.000000",
            "total_discounts_tax_excl": "0.000000",
            "total_paid": "1410.320000",
            "total_paid_tax_incl": "1410.320000",
            "total_paid_tax_excl": "1146.600000",
            "total_paid_real": "1410.320000",
            "total_products": "1139.600000",
            "total_products_wt": "1401.710000",
            "total_shipping": "8.610000",
            "total_shipping_tax_incl": "8.610000",
            "total_shipping_tax_excl": "7.000000",
            "carrier_tax_rate": "23.000",
            "total_wrapping": "0.000000",
            "total_wrapping_tax_incl": "0.000000",
            "total_wrapping_tax_excl": "0.000000",
            "round_mode": "2",
            "round_type": "2",
            "conversion_rate": "1.000000",
            "reference": "VPUOCMPMG",
            "associations": {
                "order_rows": [
                    {
                        "id": "8",
                        "product_id": "19",
                        "product_attribute_id": "0",
                        "product_quantity": "20",
                        "product_name": "Customizable mug",
                        "product_reference": "demo_14",
                        "product_ean13": "",
                        "product_isbn": "",
                        "product_upc": "",
                        "product_price": "13.900000",
                        "id_customization": "0",
                        "unit_price_tax_incl": "17.097000",
                        "unit_price_tax_excl": "13.900000"
                    },
                    {
                        "id": "9",
                        "product_id": "2",
                        "product_attribute_id": "9",
                        "product_quantity": "30",
                        "product_name": "Hummingbird printed sweater - Rozmiar : S",
                        "product_reference": "demo_3",
                        "product_ean13": "",
                        "product_isbn": "",
                        "product_upc": "",
                        "product_price": "35.900000",
                        "id_customization": "0",
                        "unit_price_tax_incl": "35.325600",
                        "unit_price_tax_excl": "28.720000"
                    }
                ]
            }
        }

Check "total_shipping" for shipping cost
"total_products_wt" for sum of your cart/order products cost

and if you wonder how to get customer address for shipping and invoice you can get it by calling /api/adresses/{id}
so in that example you have:
"id_address_delivery": "7",
"id_address_invoice": "7",

so for delivery adderss call /api/adresses/7, same for invoice address (it's possible for them to be different)

Share this post


Link to post
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...

Important Information

Cookies ensure the smooth running of our services. Using these, you accept the use of cookies. Learn More