MCPcopy Create free account
hub / github.com/Useful-Scripts-Extension/useful-script / getOrderDetail

Function getOrderDetail

scripts/shopee_totalSpendMoney.js:116–152  ·  view source on GitHub ↗
(orderId)

Source from the content-addressed store, hash-verified

114 }
115
116 async function getOrderDetail(orderId) {
117 let res = await fetch(
118 "https://shopee.vn/api/v4/order/get_order_detail?order_id=" + orderId
119 );
120 let json = await res.json();
121
122 let shippingSpent = 0;
123 let shipping_discount = 0;
124 let shopee_voucher = 0;
125 let shop_voucher = 0;
126 json.data.info_card.parcel_cards.forEach((_) => {
127 _.payment_info.info_rows.forEach((row) => {
128 if (row.info_label.text === "label_odp_shipping") {
129 shippingSpent += Number(row.info_value.value);
130 }
131 if (
132 row.info_label.text === "label_odp_shipping_discount_subtotal"
133 ) {
134 shippingSpent += Number(row.info_value.value);
135 shipping_discount += Number(row.info_value.value);
136 }
137 if (row.info_label.text === "label_odp_shopee_voucher_applied") {
138 shopee_voucher += Number(row.info_value.value);
139 }
140 if (row.info_label.text === "label_odp_shop_voucher_applied") {
141 shop_voucher += Number(row.info_value.value);
142 }
143 });
144 });
145 return {
146 shippingSpent,
147 shipping_discount,
148 shopee_voucher,
149 shop_voucher,
150 json,
151 };
152 }
153
154 let { closeLoading, setLoadingText } = showLoading("Đang chuẩn bị...");
155 try {

Callers 1

getStatisticsFunction · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected