Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add payment method to order data #258

Merged
merged 1 commit into from
Dec 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion DataLayer/Event/Purchase.php
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,8 @@ public function get(): array
'tax' => $this->priceFormatter->format((float)$order->getTaxAmount()),
'shipping' => $this->priceFormatter->format((float)$order->getShippingAmount()),
'coupon' => $order->getCouponCode(),
'items' => $this->orderItems->setOrder($order)->get()
'payment_method' => $order->getPayment()?->getMethod() ?? '',
'items' => $this->orderItems->setOrder($order)->get(),
]
];
}
Expand Down
3 changes: 2 additions & 1 deletion DataLayer/Event/Refund.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,8 @@ public function get(): array
'tax' => $this->priceFormatter->format((float)$order->getTaxAmount()),
'shipping' => $this->priceFormatter->format((float)$order->getShippingAmount()),
'coupon' => $order->getCouponCode(),
'items' => $this->orderItems->setOrder($order)->get()
'payment_method' => $order->getPayment()?->getMethod() ?? '',
'items' => $this->orderItems->setOrder($order)->get(),
]
];
}
Expand Down
1 change: 1 addition & 0 deletions DataLayer/Mapper/OrderDataMapper.php
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ public function mapByOrder(OrderInterface $order): array
'coupon' => $order->getCouponCode(),
'date' => date("Y-m-d", strtotime($order->getCreatedAt())),
'paymentType' => $this->getPaymentType($order),
'payment_method' => $order->getPayment()?->getMethod() ?? '',
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I know that this is similar to paymentType above. However, paymentType is the title of the payment method, which is, IMHO, not suitable for tracking as it can change regularly, differs by language etc.

'customer' => $this->getCustomerData($order),
];
}
Expand Down
3 changes: 2 additions & 1 deletion DataLayer/Tag/Order/Order.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,8 @@ public function merge(): array
'shipping' => $this->priceFormatter->format((float)$order->getShippingAmount()),
'affiliation' => $this->config->getStoreName(),
'transaction_id' => $order->getIncrementId(),
'coupon' => $order->getCouponCode()
'coupon' => $order->getCouponCode(),
'payment_method' => $order->getPayment()?->getMethod() ?? '',
];
}

Expand Down
Loading