Created
February 3, 2020 02:34
-
-
Save phuclh/125721c2b7094e81e2facadee06ee7c6 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| $order = Order::find(62); | |
| $products = []; | |
| foreach ($order->orderItems as $orderItem) | |
| { | |
| $products[] = (object) [ | |
| 'sku' => $orderItem->sku, | |
| 'name' => $orderItem->name, | |
| 'price' => $orderItem->price, | |
| 'weight' => $orderItem->weight, | |
| 'quantity' => $orderItem->qty_ordered | |
| ]; | |
| } | |
| $data = [ | |
| 'pickup_code' => 'WCOCS34744', | |
| 'pickup_address' => 'Số 32 thân nhân trung, Phường 13', | |
| 'pickup_province' => 'Hồ Chí Minh', | |
| 'pickup_district' => 'Tân Bình', | |
| 'name' => $order->shippedTo(), | |
| 'phone' => $order->shippedTo('phone'), | |
| 'email' => $order->shippedTo('email'), | |
| 'address' => $order->shippedTo('address'), | |
| 'province' => $order->shippedTo('state'), | |
| 'district' => $order->shippedTo('city'), | |
| 'amount' => 0, // Số tiền thu hộ. Ví dụ: 200000. | |
| 'value' => null, // Giá trị của đơn hàng. Ví dụ: 4200000. | |
| 'weight' => $order->weight, | |
| 'soc' => $order->id, // Mã Đơn Hàng riêng của Người Gửi. Ví dụ: KR-180703-034, | |
| 'note' => $order->note, // Ghi chú thêm về Đơn Hàng của Người Gửi. Ví dụ: Hàng dễ vỡ, lưu ý dùm shop. | |
| 'service' => 1, // Mã Gói Dịch Vụ. Ví dụ: 1. - Gói Tốc Hành: 1. - Gói Tiết Kiệm: 2. | |
| 'config' => 1, // Người Nhận có được quyền xem/thử sản phẩm. - Cho Xem Hàng Nhưng Không Cho Thử Hàng: 1 - Cho Thử Hàng: 2. - Không Cho Xem Hàng: 3, | |
| 'payer' => 1, // Người Trả Phí. Ví dụ: 1. - Người Gửi: 1. | |
| 'product_type' => 2, // Cách truyển sản phẩm. Ví dụ: 1. - Dạng Chuỗi: 1. - Dạng Mảng: 2. | |
| 'products' => $products, // sku, name, price, weight, quantity | |
| //'barter' // Tùy chọn Đổi/Lấy hàng về. Nếu có yêu cầu này, đơn hàng sẽ được hỗ trợ đổi hàng và trả hàng về. Ví dụ: 1. | |
| ]; | |
| $client = new Client(); | |
| $res = $client->post('https://api.mysupership.xyz/v1/partner/orders/add', [ | |
| 'query' => $data, | |
| 'header' => [ | |
| 'Accept' => 'application/json', | |
| 'Authorization' => 'Bearer ' . env('SHIPPING_METHOD_SUPERSHIP') | |
| ] | |
| ]); | |
| $supership = json_decode($res->getBody()->getContents()); | |
| dd($supership); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment