Skip to content

Commit

Permalink
Merge pull request #267 from Pinelab-studio/fix/picqer-contactname
Browse files Browse the repository at this point in the history
fix(picqer): dont set contactname if its the same as customer name
  • Loading branch information
martijnvdbrug authored Oct 10, 2023
2 parents 2d283e0 + c02f0e2 commit 34397c5
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 5 deletions.
4 changes: 3 additions & 1 deletion packages/vendure-plugin-picqer/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
// TODO set correct version number + date and the changes you've made connected to the PR. See this example for the correct format: https://github.com/Pinelab-studio/pinelab-vendure-plugins/blob/main/packages/vendure-plugin-invoices/CHANGELOG.md
# 1.0.7

- Don't set contact name in Picqer if it's the same as customer name ([#267](https://github.com/Pinelab-studio/pinelab-vendure-plugins/pull/267))
2 changes: 1 addition & 1 deletion packages/vendure-plugin-picqer/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@pinelab/vendure-plugin-picqer",
"version": "1.0.6",
"version": "1.0.7",
"description": "Vendure plugin syncing to orders and stock with Picqer",
"author": "Martijn van de Brug <[email protected]>",
"homepage": "https://pinelab-plugins.com/",
Expand Down
17 changes: 14 additions & 3 deletions packages/vendure-plugin-picqer/src/api/picqer.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1074,13 +1074,21 @@ export class PicqerService implements OnApplicationBootstrap {
customerId?: number
): OrderInput {
const shippingAddress = order.shippingAddress;

const customerFullname = [
order.customer?.firstName,
order.customer?.lastName,
]
.join(' ')
.trim();
let invoiceData: Partial<OrderInput> = {
invoicename:
order.billingAddress?.company ||
order.billingAddress?.fullName ||
undefined,
invoicecontactname: order.billingAddress?.fullName || undefined,
invoicecontactname:
order.billingAddress?.fullName === customerFullname
? undefined
: order.billingAddress?.fullName,
invoiceaddress:
order.billingAddress?.streetLine1 || order.billingAddress?.streetLine2
? [order.billingAddress.streetLine1, order.billingAddress.streetLine2]
Expand All @@ -1097,7 +1105,10 @@ export class PicqerService implements OnApplicationBootstrap {
idcustomer: customerId, // If none given, this creates a guest order
reference: order.code,
deliveryname: shippingAddress.company || shippingAddress.fullName,
deliverycontactname: shippingAddress.fullName,
deliverycontactname:
shippingAddress.fullName === customerFullname
? undefined
: shippingAddress.fullName,
deliveryaddress: `${shippingAddress.streetLine1} ${shippingAddress.streetLine2}`,
deliveryzipcode: shippingAddress.postalCode,
deliverycity: shippingAddress.city,
Expand Down

0 comments on commit 34397c5

Please sign in to comment.