Sha256: 2fd12c407044d90f343e4b8a26603c4ea5389b7e71c03d7bd5a8cf96f548b72f

Contents?: true

Size: 2 KB

Versions: 8

Compression:

Stored size: 2 KB

Contents

# frozen_string_literal: true

xml = Builder::XmlMarkup.new
xml.instruct!
xml.Orders(pages: (@shipments.total_count / 50.0).ceil) {
  @shipments.each do |shipment|
    order = shipment.order

    xml.Order {
      xml.OrderID        shipment.id
      xml.OrderNumber    shipment.number # do not use shipment.order.number as this presents lookup issues
      xml.OrderDate      order.completed_at.strftime(SolidusBacktracs::ExportHelper::DATE_FORMAT)
      xml.OrderStatus    shipment.state
      xml.LastModified   [order.completed_at, shipment.updated_at].max.strftime(SolidusBacktracs::ExportHelper::DATE_FORMAT)
      xml.ShippingMethod shipment.shipping_method.try(:name)
      xml.OrderTotal     order.total
      xml.TaxAmount      order.tax_total
      xml.ShippingAmount order.ship_total
      xml.CustomField1   order.number

      #       if order.gift?
      #         xml.Gift
      #         xml.GiftMessage
      #       end

      xml.Customer {
        xml.CustomerCode order.email.slice(0, 50)
        SolidusBacktracs::ExportHelper.address(xml, order, :bill)
        SolidusBacktracs::ExportHelper.address(xml, order, :ship)
      }
      xml.Items {
        shipment.line_items.each do |line|
          variant = line.variant
          xml.Item {
            xml.SKU         variant.sku
            xml.Name        [variant.product.name, variant.options_text].join(' ')
            xml.ImageUrl    variant.images.first.try(:attachment).try(:url)
            xml.Weight      variant.weight.to_f
            xml.WeightUnits SolidusBacktracs.configuration.weight_units
            xml.Quantity    line.quantity
            xml.UnitPrice   line.price

            if variant.option_values.present?
              xml.Options {
                variant.option_values.each do |value|
                  xml.Option {
                    xml.Name  value.option_type.presentation
                    xml.Value value.name
                  }
                end
              }
            end
          }
        end
      }
    }
  end
}

Version data entries

8 entries across 8 versions & 2 rubygems

Version Path
solidus_bactracs-3.0.0 app/views/spree/backtracs/export.xml.builder
solidus_backtracs-2.2.6 app/views/spree/backtracs/export.xml.builder
solidus_backtracs-2.2.5 app/views/spree/backtracs/export.xml.builder
solidus_backtracs-2.2.4 app/views/spree/backtracs/export.xml.builder
solidus_backtracs-2.2.3 app/views/spree/backtracs/export.xml.builder
solidus_backtracs-2.2.2 app/views/spree/backtracs/export.xml.builder
solidus_backtracs-2.2.1 app/views/spree/backtracs/export.xml.builder
solidus_backtracs-2.2.0 app/views/spree/backtracs/export.xml.builder