QuickBooks sales receipts for completed WooCommerce orders
Create QuickBooks sales receipts for completed WooCommerce orders
Creating QuickBooks sales receipts for completed WooCommerce orders using Zapier involves setting up a Zap that connects WooCommerce and QuickBooks, along with custom scripts to enhance the workflow. Here’s a solution overview along with four custom scripts:
Solution Overview
Zapier Flow:
Trigger: New Order in WooCommerce.
Action: Create Sales Receipt in QuickBooks.
Custom Scripts: Additional custom scripts to enhance the workflow.
Step-by-Step Implementation
Step 1: Trigger – New Order in WooCommerce
App: WooCommerce
Trigger Event: Order Completed
Details: Set up the trigger to fire whenever a new order is marked as completed in WooCommerce.
Step 2: Action – Create Sales Receipt in QuickBooks
App: QuickBooks Online
Action Event: Create Sales Receipt
Details: Use the order details from WooCommerce to create a corresponding sales receipt in QuickBooks.
Step 3: Custom Scripts
To enhance the functionality of this Zap, here are four custom scripts that can be added:
Custom Script 1: Validate Order Data
Before creating the sales receipt in QuickBooks, ensure that the WooCommerce order data is valid and complete.
// Script to validate WooCommerce order data
const orderTotal = inputData.orderTotal;
const customerName = inputData.customerName;
if (orderTotal > 0 && customerName) {
return { valid: true };
} else {
throw new Error("Order data is incomplete or invalid.");
}
Usage: Use this script as a filter step in Zapier to proceed only if the order data is valid.
Custom Script 2: Format Line Items for QuickBooks
If the WooCommerce order includes multiple products, this script can format the line items for QuickBooks.
// Script to format WooCommerce line items for QuickBooks
const lineItems = inputData.lineItems.map(item => {
return {
"Description": item.name,
"Amount": item.price * item.quantity,
"Quantity": item.quantity,
"ItemRef": {
"name": item.sku
}
};
});
return { lineItems };
Usage: This script can be used to format the WooCommerce order items in a way that QuickBooks can process.
Custom Script 3: Apply Discounts or Coupons
Automatically apply any discounts or coupons from the WooCommerce order to the QuickBooks sales receipt.
// Script to apply discounts to QuickBooks sales receipt
const discountTotal = inputData.discountTotal;
if (discountTotal > 0) {
return {
"DiscountLineDetail": {
"Amount": discountTotal
}
};
} else {
return {};
}
Usage: Add this script as part of the "Create Sales Receipt" action to reflect discounts on the receipt.
Custom Script 4: Log Receipt Creation in a Google Sheet
Keep a log of all sales receipts created in QuickBooks in a Google Sheet for auditing purposes.
// Script to log sales receipt creation in Google Sheets
const orderId = inputData.orderId;
const receiptId = inputData.receiptId;
const timestamp = new Date().toISOString();
return {
spreadsheetId: "your-google-sheet-id",
range: "Sheet1!A1",
values: [
[orderId, receiptId, timestamp]
]
};
Usage: Use this script to append a new row to a Google Sheet every time a sales receipt is created in QuickBooks.
Final Zap Setup
Trigger: Order Completed in WooCommerce.
Action: Custom Script 1 - Validate Order Data.
Action: Custom Script 2 - Format Line Items for QuickBooks.
Action: Custom Script 3 - Apply Discounts or Coupons.
Action: Create Sales Receipt in QuickBooks.
Action: Custom Script 4 - Log Receipt Creation in Google Sheets.
Summary
This solution not only creates a sales receipt in QuickBooks when a WooCommerce order is completed but also enhances the workflow with validation, line item formatting, discount application, and logging capabilities using custom scripts. This ensures accuracy, consistency, and traceability in your sales processes.