Skip to content

Commit

Permalink
TQLG-244: fix issue with payment method (#87)
Browse files Browse the repository at this point in the history
* TQLG-244: fix issue with payment method

* TQLG-244: fix issue with payment method
  • Loading branch information
adnansaadeddine authored Nov 12, 2024
1 parent c45353f commit 79906ba
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 2 deletions.
3 changes: 1 addition & 2 deletions components/Account/Order/AccountOrderItem.vue
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,11 @@ const props = defineProps<{
orderId: string;
}>();
const { order, loadOrderDetails, shippingMethod, paymentMethod, status, shippingAddress, billingAddress } =
const { order, loadOrderDetails, shippingMethod, paymentMethod, paymentState, status, shippingAddress, billingAddress } =
useOrderDetails(props.orderId, {
stateMachineState: {},
});
const { state: paymentState } = useOrderPayment(order);
const shippingStatus = computed(() => {
const stateName = order.value?.deliveries?.[0]?.stateMachineState?.translated?.name;
Expand Down
32 changes: 32 additions & 0 deletions composables/useOrderDetails.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
import { useOrderDetails as useBaseOrderDetails } from '@shopware-pwa/composables-next';
import type { UseOrderDetailsReturn } from '@shopware-pwa/composables-next';
import type { Schemas } from '@shopware/api-client/api-types';
import type { ComputedRef } from 'vue';

export type UseCustomOrderDetailsReturn = UseOrderDetailsReturn & {
paymentState: ComputedRef<Schemas["StateMachineState"] | undefined>;
}

export function useOrderDetails(
orderId: string,
associations?: Schemas["Criteria"]["associations"],
): UseCustomOrderDetailsReturn {
const baseUserDetails = useBaseOrderDetails(orderId, associations);
const paymentMethod = computed(() => {
const transactions = baseUserDetails.order.value?.transactions;

return transactions?.[transactions.length - 1]?.paymentMethod;
});

const paymentState = computed(() => {
const transactions = baseUserDetails.order.value?.transactions;

return transactions?.[transactions.length - 1]?.stateMachineState;
});

return {
...baseUserDetails,
paymentMethod,
paymentState,
};
}

0 comments on commit 79906ba

Please sign in to comment.