Skip to content

Instantly share code, notes, and snippets.

@nfriend21
Created October 7, 2015 19:41
Show Gist options
  • Save nfriend21/65ba82101141013e1de7 to your computer and use it in GitHub Desktop.
Save nfriend21/65ba82101141013e1de7 to your computer and use it in GitHub Desktop.
xml.instruct!
xml.tag!('LLXML', { 'id' => 'Lab Order' }) do
xml.Creator 'Art Storefronts'
xml.Version 'ASF 2.12'
xml.Orders do
@exportable_orders.each do |order|
xml.Order do
xml.OrderID order.number
xml.OrderHeader do
xml.OrderTimeStamp order.created_at
xml.OrderDate order.created_at
xml.OrderLastUpdatedAt order.updated_at
xml.OrderTotal order.total.round(2)
xml.OrderTaxable order.tax_method_id.present? ? 'Yes' : 'No'
xml.OrderNotes
xml.OrderReference order.number
xml.OrderFor
xml.OrderChargeNum
xml.OrderPromoCode
xml.OrderStatus order.order_status
xml.OrderShippingStatus order.shipping_status
xml.OrderPaymentStatus order.payment_status
xml.OrderInternalMemo order.internal_memo
xml.OrderMessage order.message
xml.OrderAssetsDownloadURL order.download_zip_url
xml.WebsiteName order.website.name
xml.WebsiteID order.website_id
xml.Customer do
xml.CustomerID
xml.AccountName order.orderer.full_name
xml.Phone1 (order.contact_object.phone_business || '000-000-0000')
xml.Email order.orderer.email
end
xml.Billing do
xml.Address1 order.billing_address.street
xml.Address2 order.billing_address.street2
xml.City order.billing_address.city
xml.State order.billing_address.state
xml.PostalCode order.billing_address.zip
xml.Country order.billing_address.country
end
xml.Shipping do
xml.DropShip
xml.CustomerName order.shipping_address.full_name
xml.Address1 order.shipping_address.street
xml.Address2 order.shipping_address.street2
xml.City order.shipping_address.city
xml.State order.shipping_address.state
xml.PostalCode order.shipping_address.zip
xml.Country order.shipping_address.country
xml.Phone1 order.contact_object.phone_business
xml.ShippingMethod order.shipping_method.try(:name)
xml.ShippingPrice order.shipping_total
xml.ShipperNumber
end
xml.Payment do
# if the order is unpaid, leave all fields blank for lablogix
xml.EncryptionType
xml.CardNum
xml.CardExp
xml.CardCCID
xml.CardConfirmation
xml.EncryptionToken
xml.PaymentType (order.payment_status == 'Paid' ? 'Prepaid' : '')
xml.PaymentNote (order.payment_status == 'Paid' ? order.payment_status : '')
xml.CardType
xml.CardNum
xml.CardExp
xml.CardCCID
xml.CardConfirmation
xml.CardName
xml.CardTel
xml.CardAmt (order.payment_status == 'Paid' ? order.total : '')
end
end
xml.OrderItems do
order.line_items.each do |item|
xml.OrderItemInfo do
# this is an incrementing item count, needs to start at 1.
xml.OISequence order.line_items.index(item) + 1
xml.ItemCode item.item_code
xml.ServiceType
xml.Description
xml.FDescription item.attrs_as_string
xml.FPrice item.final_unit_price
xml.Qty item.quantity_of_images
xml.Each item.quantity # quantity of prints
xml.ProductName item.product.name
xml.ProductID item.product_id
xml.StorePageName item.product.store.page.try(:name)
xml.StoreID item.product.store.id
xml.Artist item.product.try(:artist)
end
end
end
end
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment