| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556 |
- import type { AddressListInOrderDetails,OrderAddressType,ProductItemAdditional } from "@/types/customer/type";
- import type { CartAddress } from "@/types/cart/type";
- export function getAddressFromOrderDetailAddressList(addressList: AddressListInOrderDetails, addressType: OrderAddressType) {
- const address = addressList.edges.find((x) => x.node.addressType === addressType);
- if (!address) {
- throw new Error(
- "Order shipping address missing"
- );
- }
- const res: CartAddress = {
- id: String(address.node._id),
- firstName: address.node.firstName,
- lastName: address.node.lastName,
- email: address.node.email,
- address: address.node.address,
- city: address.node.city,
- state: address.node.state,
- country: address.node.country,
- postcode: address.node.postcode,
- phone: address.node.phone,
- }
- return res;
- }
- export function getProductAdditionalInfo(productItem: ProductItemAdditional) {
- const attributeKeys = Object.keys(productItem.attributes);
- let res = '';
- attributeKeys.forEach(key => {
- const attribute = productItem.attributes[key];
- if (attribute) {
- // option_label value_label
- if(res) {
- res = res + ', ' + attribute.option_label + ': ' + attribute.value_label;
- } else {
- res = attribute.option_label + ': ' + attribute.value_label;
- }
- }
- });
- return res;
- }
- export function getProductFinalPriceInOrder() {}
- // export function getProductAdditinalInOrder(itemAdditional: string) {
- // const additinal = JSON.parse(itemAdditional);
- // let optionsTxt = '';
- // Object.keys(additinal.attributes).forEach((key) => {
- // const att = additinal.attributes[key];
- // optionsTxt = optionsTxt
- // });
- // return {}
- // }
|