Prestashop - APIs
Prestashop - APIs
)
http://127.0.0.1/prestashop/api/products/?display=[name]&output_format=JSON&filter[id_category_d
efault]=9
"products": [
},
},
},
},
},
2.) http://127.0.0.1/prestashop/api/products/?output_format=JSON
// 20200414131347
// http://127.0.0.1/prestashop/api/products/?output_format=JSON
"products": [
"id": 1
},
"id": 2
},
"id": 16
},
"id": 17
},
"id": 18
},
"id": 6
},
"id": 7
},
"id": 8
},
{
"id": 9
},
"id": 10
},
"id": 11
},
"id": 15
},
"id": 19
},
"id": 3
},
"id": 4
},
"id": 5
},
"id": 12
},
"id": 13
},
{
"id": 14
3.) http://127.0.0.1/prestashop/api/products/1?output_format=JSON
"product": {
"id": 1,
"id_manufacturer": "1",
"id_supplier": "0",
"id_category_default": "4",
"new": null,
"cache_default_attribute": "1",
"id_default_image": "1",
"id_default_combination": "1",
"id_tax_rules_group": "1",
"position_in_category": "1",
"quantity": "0",
"type": "simple",
"id_shop_default": "1",
"reference": "demo_1",
"supplier_reference": "",
"location": "",
"width": "0.000000",
"height": "0.000000",
"depth": "0.000000",
"weight": "0.000000",
"quantity_discount": "0",
"ean13": "",
"isbn": "",
"upc": "",
"cache_is_pack": "0",
"cache_has_attachments": "0",
"is_virtual": "0",
"state": "1",
"additional_delivery_times": "1",
"delivery_in_stock": "",
"delivery_out_stock": "",
"on_sale": "0",
"online_only": "0",
"ecotax": "0.000000",
"minimal_quantity": "1",
"low_stock_threshold": null,
"low_stock_alert": "0",
"price": "23.900000",
"wholesale_price": "0.000000",
"unity": "",
"unit_price_ratio": "0.000000",
"additional_shipping_cost": "0.00",
"customizable": "0",
"text_fields": "0",
"uploadable_files": "0",
"active": "1",
"redirect_type": "301-category",
"id_type_redirected": "0",
"available_for_order": "1",
"available_date": "0000-00-00",
"show_condition": "0",
"condition": "new",
"show_price": "1",
"indexed": "1",
"visibility": "both",
"advanced_stock_management": "0",
"pack_stock_type": "3",
"meta_description": "",
"meta_keywords": "",
"meta_title": "",
"link_rewrite": "hummingbird-printed-t-shirt",
"available_now": "",
"available_later": "",
"associations": {
"categories": [
"id": "2"
},
"id": "3"
},
"id": "4"
],
"images": [
"id": "1"
},
"id": "2"
],
"combinations": [
"id": "1"
},
"id": "2"
},
"id": "3"
},
"id": "4"
},
{
"id": "5"
},
"id": "6"
},
"id": "7"
},
"id": "8"
],
"product_option_values": [
"id": "1"
},
"id": "11"
},
"id": "2"
},
"id": "8"
},
"id": "3"
},
{
"id": "4"
],
"product_features": [
"id": "1",
"id_feature_value": "4"
},
"id": "2",
"id_feature_value": "8"
],
"stock_availables": [
"id": "1",
"id_product_attribute": "0"
},
"id": "20",
"id_product_attribute": "1"
},
"id": "21",
"id_product_attribute": "2"
},
"id": "22",
"id_product_attribute": "3"
},
"id": "23",
"id_product_attribute": "4"
},
"id": "24",
"id_product_attribute": "5"
},
"id": "25",
"id_product_attribute": "6"
},
"id": "26",
"id_product_attribute": "7"
},
"id": "27",
"id_product_attribute": "8"
}
4.) http://127.0.0.1/prestashop/api/orders/1?output_format=JSON
"order": {
"id": 1,
"id_address_delivery": "5",
"id_address_invoice": "5",
"id_cart": "1",
"id_currency": "1",
"id_lang": "1",
"id_customer": "2",
"id_carrier": "2",
"current_state": "6",
"module": "ps_checkpayment",
"invoice_number": "0",
"delivery_number": "0",
"valid": "0",
"shipping_number": "",
"id_shop_group": "1",
"id_shop": "1",
"secure_key": "b44a6d9efd7a0076a0fbce6b15eaf3b1",
"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": "61.800000",
"total_paid_tax_incl": "61.800000",
"total_paid_tax_excl": "61.800000",
"total_paid_real": "0.000000",
"total_products": "59.800000",
"total_products_wt": "59.800000",
"total_shipping": "2.000000",
"total_shipping_tax_incl": "2.000000",
"total_shipping_tax_excl": "2.000000",
"carrier_tax_rate": "0.000",
"total_wrapping": "0.000000",
"total_wrapping_tax_incl": "0.000000",
"total_wrapping_tax_excl": "0.000000",
"round_mode": "0",
"round_type": "0",
"conversion_rate": "1.000000",
"reference": "XKBKNABJK",
"associations": {
"order_rows": [
"id": "1",
"product_id": "1",
"product_attribute_id": "1",
"product_quantity": "1",
"product_name": "Hummingbird printed t-shirt - Color : White, Size : S",
"product_reference": "demo_2",
"product_ean13": "",
"product_isbn": "",
"product_upc": "",
"product_price": "23.900000",
"id_customization": "0",
"unit_price_tax_incl": "23.900000",
"unit_price_tax_excl": "23.900000"
},
"id": "2",
"product_id": "2",
"product_attribute_id": "9",
"product_quantity": "1",
"product_reference": "demo_3",
"product_ean13": "",
"product_isbn": "",
"product_upc": "",
"product_price": "35.900000",
"id_customization": "0",
"unit_price_tax_incl": "35.900000",
"unit_price_tax_excl": "35.900000"
}
5.) curl --location --request POST
'http://127.0.0.1/prestashop/admin602gqubdt/index.php?controller=AdminOrders&token=4fc250576d
6d6f0ff9ed89abe02a315e' \
--header 'User-Agent: Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko)
Chrome/80.0.3987.149 Safari/537.36' \
--header 'Referer:
http://127.0.0.1/prestashop/admin602gqubdt/index.php?controller=AdminOrders&vieworder=&id_ord
er=5&token=4fc250576d6d6f0ff9ed89abe02a315e' \
--data-raw
'ajax=1&token=4fc250576d6d6f0ff9ed89abe02a315e&action=editProductOnOrder&id_order=5&produc
t_id_order_detail=7&product_price_tax_excl=18.9&product_price_tax_incl=18.9&product_quantity=26'
File - /var/www/html/prestashop/controllers/admin/AdminOrdersController.php
// Return value
$res = true;
if (Tools::isSubmit('product_invoice')) {
$product_quantity = 0;
if (is_array(Tools::getValue('product_quantity'))) {
} else {
$product_quantity = Tools::getValue('product_quantity');
if (isset($order_invoice)) {
// If OrderInvoice to use is different, we update the old invoice and new invoice
if ($order_detail->id_order_invoice != $order_invoice->id) {
$old_order_invoice->total_products -= $order_detail->total_price_tax_excl;
$old_order_invoice->total_products_wt -= $order_detail->total_price_tax_incl;
$old_order_invoice->total_paid_tax_excl -= $order_detail->total_price_tax_excl;
$old_order_invoice->total_paid_tax_incl -= $order_detail->total_price_tax_incl;
$order_invoice->total_products_wt += $order_detail->total_price_tax_incl;
$order_invoice->total_paid_tax_excl += $order_detail->total_price_tax_excl;
$order_invoice->total_paid_tax_incl += $order_detail->total_price_tax_incl;
$order_detail->id_order_invoice = $order_invoice->id;
$order_detail->unit_price_tax_excl = $product_price_tax_excl;
$order_detail->unit_price_tax_incl = $product_price_tax_incl;
$order_detail->total_price_tax_incl += $diff_price_tax_incl;
$order_detail->total_price_tax_excl += $diff_price_tax_excl;
if (isset($order_invoice)) {
$order_invoice->total_products += $diff_price_tax_excl;
$order_invoice->total_products_wt += $diff_price_tax_incl;
$order_invoice->total_paid_tax_excl += $diff_price_tax_excl;
$order_invoice->total_paid_tax_incl += $diff_price_tax_incl;
$order->total_products += $diff_price_tax_excl;
$order->total_products_wt += $diff_price_tax_incl;
$order->total_paid += $diff_price_tax_incl;
$order->total_paid_tax_excl += $diff_price_tax_excl;
$order->total_paid_tax_incl += $diff_price_tax_incl;
$old_quantity = $order_detail->product_quantity;
$order_detail->product_quantity = $product_quantity;
$order_detail->reduction_percent = 0;
// update taxes
if (Validate::isLoadedObject($order_carrier)) {
if ($res) {
}
}
if (isset($order_invoice)) {
StockAvailable::updateQuantity($order_detail->product_id, $order_detail->product_attribute_id,
($old_quantity - $order_detail->product_quantity), $order->id_shop);
$products = $this->getProducts($order);
$product = $products[$order_detail->id];
$resume = OrderSlip::getProductSlipResume($order_detail->id);
$product['amount_refund'] = Tools::displayPrice($resume['amount_tax_incl']);
$product['refund_history'] = OrderSlip::getProductSlipDetail($order_detail->id);
if ($product['id_warehouse'] != 0) {
$product['warehouse_name'] = $warehouse->name;
$warehouse_location = WarehouseProductLocation::getProductLocation($product['product_id'],
$product['product_attribute_id'], $product['id_warehouse']);
if (!empty($warehouse_location)) {
$product['warehouse_location'] = $warehouse_location;
} else {
$product['warehouse_location'] = false;
}
} else {
$product['warehouse_name'] = '--';
$product['warehouse_location'] = false;
$invoice_collection = $order->getInvoicesCollection();
$invoice_array = array();
$invoice->name = $invoice->getInvoiceNumberFormatted(Context::getContext()->language->id,
(int) $order->id_shop);
$invoice_array[] = $invoice;
$order = $order->refreshShippingCost();
$stockLocationIsAvailable = false;
if (!empty($currentProduct['location'])) {
$stockLocationIsAvailable = true;
break;
$this->context->smarty->assign(array(
'product' => $product,
));
if (!$res) {
die(json_encode(array(
'error' => $this->trans('An error occurred while editing the product line.', array(),
'Admin.Orderscustomers.Notification'),
)));
if (is_array(Tools::getValue('product_quantity'))) {
$view = $this->createTemplate('_customized_data.tpl')->fetch();
} else {
$view = $this->createTemplate('_product_line.tpl')->fetch();
$this->sendChangedNotification($order);
die(json_encode(array(
'result' => $res,
)));
6.) http://127.0.0.1/prestashop/api/stock_availables/19?output_format=JSON
7.)http://127.0.0.1/prestashop/api/products/?output_format=JSON&filter[id_category_default]=9
8.) http://127.0.0.1/prestashop/api/products/19?output_format=JSON
9.) http://127.0.0.1/prestashop/api/orders/1?output_format=JSON