I am wanting to modify the Export_ADNSF.csv that is created by OrderShipment2.aspx.cs as the OrderNumber is being appended with the customers ShippingAddressID and we don't need it as it is causing problems with our new shipping software.
I've tracked it back to a piece of DB code that only appears in the initial "Create AspDotNetStorefront Database" sql command.
Code:
CREATE proc dbo.aspdnsf_WorldShipExport
AS
SET NOCOUNT ON
BEGIN
SELECT CAST(o.OrderNumber AS varchar(10)) + '-' + CAST(a.ShippingAddressID AS varchar(10)) OrderNumber,
o.ShippingTrackingNumber, o.ShippedOn, o.ShippingMethod, o.CustomerID, o.FirstName + ' ' + o.LastName [Name],
o.Email, ad.FirstName + ' ' + ad.LastName AS ShippingName, o.ShippingCompany, ad.Address1 ShippingAddress1,
ad.Address2 ShippingAddress2, ad.Suite ShippingSuite, ad.City ShippingCity, ad.State ShippingState, ad.Zip ShippingZip, ad.Country ShippingCountry,
ad.Phone ShippingPhone, b.AddressSubTotal OrderSubtotal,
o.OrderTax, o.OrderShippingCosts, o.OrderTotal, o.OrderDate, CASE WHEN (c.AddressCount = 1) THEN o.OrderWeight ELSE b.AddressWeightTotal END OrderWeight
FROM dbo.Orders o with (nolock)
JOIN (SELECT OrderNumber, ShippingAddressID FROM dbo.orders_shoppingcart with (nolock) GROUP BY OrderNumber, ShippingAddressID HAVING COUNT(DISTINCT ShippingAddressID) = 1 ) a ON O.OrderNumber = A.OrderNumber
JOIN (SELECT OrderNumber, ShippingAddressID, SUM(OrderedProductPrice * Quantity) AddressSubTotal, SUM(PV.Weight * Quantity) AddressWeightTotal FROM dbo.orders_shoppingcart os with (nolock) JOIN productvariant pv with (nolock) on os.variantid = pv.variantid group by ordernumber, shippingaddressid ) b on b.ordernumber = a.ordernumber and b.ShippingAddressID = a.ShippingAddressID
JOIN (SELECT OrderNumber, count(ShippingAddressID) AddressCount FROM dbo.orders_shoppingcart with (nolock) group by ordernumber ) c on c.ordernumber = a.ordernumber
JOIN dbo.Address ad on ad.addressid = b.shippingaddressid
WHERE o.ReadyToShip = 1 AND o.ShippedOn IS NULL AND TransactionState IN ('AUTHORIZED', 'CAPTURED')
ORDER BY ordernumber
END
I think by changing this statement to the following it should fix the issue...
Code:
CREATE proc dbo.aspdnsf_WorldShipExport
AS
SET NOCOUNT ON
BEGIN
SELECT CAST(o.OrderNumber AS varchar(10)) + '-' + CAST(a.ShippingAddressID AS varchar(10)) OrderNumber,
o.ShippingTrackingNumber, o.ShippedOn, o.ShippingMethod, o.CustomerID, o.FirstName + ' ' + o.LastName [Name],
o.Email, ad.FirstName + ' ' + ad.LastName AS ShippingName, o.ShippingCompany, ad.Address1 ShippingAddress1,
ad.Address2 ShippingAddress2, ad.Suite ShippingSuite, ad.City ShippingCity, ad.State ShippingState, ad.Zip ShippingZip, ad.Country ShippingCountry,
ad.Phone ShippingPhone, b.AddressSubTotal OrderSubtotal,
o.OrderTax, o.OrderShippingCosts, o.OrderTotal, o.OrderDate, CASE WHEN (c.AddressCount = 1) THEN o.OrderWeight ELSE b.AddressWeightTotal END OrderWeight
FROM dbo.Orders o with (nolock)
JOIN (SELECT OrderNumber FROM dbo.orders_shoppingcart with (nolock) GROUP BY OrderNumber = A.OrderNumber
JOIN (SELECT OrderNumber, ShippingAddressID, SUM(OrderedProductPrice * Quantity) AddressSubTotal, SUM(PV.Weight * Quantity) AddressWeightTotal FROM dbo.orders_shoppingcart os with (nolock) JOIN productvariant pv with (nolock) on os.variantid = pv.variantid group by ordernumber, shippingaddressid ) b on b.ordernumber = a.ordernumber and b.ShippingAddressID = a.ShippingAddressID
JOIN (SELECT OrderNumber, count(ShippingAddressID) AddressCount FROM dbo.orders_shoppingcart with (nolock) group by ordernumber ) c on c.ordernumber = a.ordernumber
JOIN dbo.Address ad on ad.addressid = b.shippingaddressid
WHERE o.ReadyToShip = 1 AND o.ShippedOn IS NULL AND TransactionState IN ('AUTHORIZED', 'CAPTURED')
ORDER BY ordernumber
END
Before I go and run this through >Configuration>Advanced>Run SQL can someone run their eye over it and make sure I haven't missed anything...!?!
Thanks in advance!