Hi George,
It looks like it's working after I realized a parameter was not named right! (Doh!) Ok, I fixed it in the stored proc, instead of renaming the XML.
Thanks for letting me know I was not spinning my wheels here. IT was really driving me a little nuts. So as promised here is my stored proc.
Actually the stored proc I use requires a view, so I will also add it below. Please create the view first, otherwise the proc will give you a few errors.
Here is the view:
C#/VB.NET Code:
/*
© Copyright 2007 RevGenetics, LLC. All Rights Reserved.
First: This code is Copyrighted, but freely usable and distributable
as long as these comments are not edited.
My Comments:
1- Yes, it's a view, simple but true.
2- Replace the text 'Fixed Category' with something you like, or join another table if you wish to extrapolate the category.
3- Create the stored proc GetGANLink (It should be available at the link below)
(see http://forums.aspdotnetstorefront.com/showthread.php?t=21077) if you forgot where you saved GetGANLink...
*/
Create View [dbo].[vw_GANview]
as
SELECT od.[OrderNumber] as OrderID
,o.ordersubtotal as SubTotal
,od.[OrderedProductSKU] as ProductSKU
,od.[OrderedProductSKU] as ProductName
,od.[Quantity] as ProductQTY
,od.[OrderedProductPrice] as ProductPrice
,'Fixed Category' as ProdCategory
,od.[ShoppingCartRecID] as OrderDetailID
FROM
[dbo].[Orders] o inner join [dbo].[Orders_ShoppingCart] od
on o.OrderNumber = od.OrderNumber
inner join [dbo].[customer] c
on o.[CustomerID] = c.[CustomerID]
inner join [dbo].[address] BillAddr
on c.[BillingAddressID] = BillAddr.[AddressID]
inner join [dbo].[address] ShipAddr
on c.[ShippingAddressID] = ShipAddr.[AddressID]
Go
Ok... now that you created the view in your SQL database... you then create the proc below:
C#/VB.NET Code:
/*
© Copyright 2007 RevGenetics, LLC. All Rights Reserved.
First: This code is Copyrighted, but freely usable and distributable
as long as these comments are not edited.
My Comments:
0- Yes, I know nvarchar(2000) is overkill, but its a nvarchar! not fixed, so it's great.
1- To make this work you will need the view called: vw_GANview (It should be available at the link below)
2- Replace the text 'K??????' at the end of the @GANstart variable to your GAN account number
3- work on the page.orderconfirmation.xml.config, and add the following in the apprpriate places per :
This XML was driving me nuts, so have fun:
exec GetGANLink @OrderNumber
<xsl:param name="GANLink"><xsl:value-of select="/root/Orders/Order/GANLink" /></xsl:param>
<img src="{$GANLink}" width="1" height="1"/>
Don't know where to put the XML? No problem, look at link below:
(see http://forums.aspdotnetstorefront.com/showthread.php?t=21077) for details
*/
Create Procedure [dbo].[GetGANLink]
@OrderNumber int
As
Declare @GANstart nvarchar(2000)
set @GANstart = 'https://clickserve.cc-dt.com/link/order?vid=K??????'
/* All nifty stuff below here */
Declare @OrderID as nvarchar(20),
@VendorID as nvarchar(20),
@SubTotal as nvarchar(20),
@ProdSKU as nvarchar(2000),
@ProdName as nvarchar(2000),
@ProdQTY as nvarchar(2000),
@ProdPrice as nvarchar(2000),
@ProdCatID as nvarchar(2000),
@FinalURL as nvarchar(2000),
@OrderDetailID as nvarchar(15)
set @OrderID = @OrderNumber
Select OrderID, SubTotal, ProductSKU, ProductName, ProductQTY, ProductPrice, ProdCategory, OrderDetailID
into #tmpTable
From vw_GANview with (NOLOCK)
where orderID = @OrderID
-- Select * from #tmpTable
declare @counter int, @records int
select @counter = count(*) from #tmpTable
set @records = @counter
while @counter >0
begin
IF @counter = @records
Begin
Select top 1
@OrderID='&oid='+ltrim(rtrim(ISNULL(convert(nvarchar,OrderID),''))),
@SubTotal='&amt='+ltrim(rtrim(ISNULL(SubTotal,''))),
@ProdSKU='&prdsku='+ltrim(rtrim(ISNULL(ProductSKU,''))),
@ProdName='&prdnm='+ltrim(rtrim(ISNULL(ProductName,''))),
@ProdQTY='&prdqn='+ltrim(rtrim(ISNULL(ProductQTY,''))),
@ProdPrice='&prdpr='+ltrim(rtrim(ISNULL(ProductPrice,''))),
@ProdCatID='&prcatid='+ltrim(rtrim(ISNULL(ProdCategory,''))),
@OrderDetailID=OrderDetailID
From #tmpTable
End
else
Begin
Select top 1
@ProdSKU=ISNULL(@ProdSKU, '')+'^'+ltrim(rtrim(ISNULL(ProductSKU,''))),
@ProdName=ISNULL(@ProdName, '')+'^'+ltrim(rtrim(ISNULL(ProductName,''))),
@ProdQTY=ISNULL(@ProdQTY, '')+'^'+ltrim(rtrim(ISNULL(ProductQTY,''))),
@ProdPrice=ISNULL(@ProdPrice, '')+'^'+ltrim(rtrim(ISNULL(ProductPrice,''))),
@ProdCatID=ISNULL(@ProdCatID, '')+'^'+ltrim(rtrim(ISNULL(ProdCategory,''))),
@OrderDetailID=OrderDetailID
From #tmpTable
End
Delete #tmpTable where OrderDetailID = @OrderDetailID
set @counter = @counter - 1
End
drop table #tmpTable
/* All nifty stuff above here */
Select @FinalURL = @GANstart + @OrderID +@SubTotal+ @ProdSKU+@ProdName+@ProdQTY+@ProdPrice+@ProdCatID
--Print @GANstart + @OrderID +@SubTotal+ @ProdSKU+@ProdName+@ProdQTY+@ProdPrice+@ProdCatID
Select o.*,@FinalURL as GANLink from Orders o with (NOLOCK) where OrderNumber=@OrderNumber
Well, this view and this proc, along with your comments George, will most definitely allow folks to easily add GAN to ADNSF...
Just replace "K??????" in the main proc to your affiliate Company ID/vid, and you guys should be set. Oh, and rename the category in the view to something you like...
Thanks Again!!