<% TitrePage = "Commander mon album" %>
 

<% ' ***** Begin the functions to be called by the runtime script ***** ' To find the actual runtime code scroll WAY DOWN.... ' This function is written to enable the adding of multiples of an item ' but this sample always just adds one. If you wish to add different ' quantities simply replace the value of the Querystring parameter count. ' We didn't do this because we wanted to keep the whole thing simple and ' not get into using forms so it stayed relatively readable. emailUsername = "commande@donaldguitar.com" emailPassword = "ma1703" emailHost = "mail.donaldguitar.com" Sub AddItemToCart(iItemID, iItemCount) If dictCart.Exists(iItemID) Then dictCart(iItemID) = dictCart(iItemID) + iItemCount Else dictCart.Add iItemID, iItemCount End If Response.Write "L'item a été ajouté au panier.

" & vbCrLf End Sub Sub RemoveItemFromCart(iItemID, iItemCount) If dictCart.Exists(iItemID) Then If dictCart(iItemID) <= iItemCount Then dictCart.Remove iItemID Else dictCart(iItemID) = dictCart(iItemID) - iItemCount End If Response.Write "L'item a été supprimé du panier.

" & vbCrLf Else Response.Write "Erreur ! cet item n'est pas dans le panier.

" & vbCrLf End If End Sub Sub ShowItemsInCart() Dim Key Dim aParameters ' as Variant (Array) Dim sTotal, sShipping %> <% sTotal = 0 For Each Key in dictCart aParameters = GetItemParameters(Key) %> <% sTotal = sTotal + (dictCart(Key) * CSng(aParameters(2))) Next 'Calculate shipping - you might want to pull this out into a function if your shipping ' calculations are more complicated then ours. ;) If sTotal <> 0 Then sShipping = 0 Else sShipping = 0 End If sTotal = sTotal + sShipping session ("LetotalDo") = FormatNumber(sTotal,2) %>
Photo Description Quantité Modifier panier Prix Total
<%= aParameters(1) %> <%= dictCart(Key) %>   <% if dictCart(Key) > 1 then response.write "Retirer les items" else response.write "Retirer l'item" end if %> $<%= aParameters(2) %> $<%= FormatNumber(dictCart(Key) * CSng(aParameters(2)),2) %>
(transport inclus)      Total: $<%= FormatNumber(sTotal,2) %>
 Vos coordonnées
 Votre nom : *
 Téléphone : *
 Adresse : *
 Votre courriel :
 
 

*Les champs avec un astérisque sont obligatoires.

<% End Sub Sub ShowFullCatalog() Dim aParameters ' as Variant (Array) Dim I Dim iItemCount ' Number of items we sell ' If you are really going to use this sample this should probably be pulled from a DB iItemCount = 2 %> <% For I = 1 to iItemCount aParameters = GetItemParameters(I) %> <% Next 'I %>
Photo Description Prix Ajouter au panier
<%= aParameters(1) %> $<%= aParameters(2) %> Ajouter au panier
<% End Sub Sub PlaceOrder() Dim Key Dim aParameters ' as Variant (Array) Dim sTotal, sShipping %> <% sTotal = 0 For Each Key in dictCart aParameters = GetItemParameters(Key) VarMessage = VarMessage & "Quantité : " & dictCart(Key) & " : " & dictCart(Key) & " , $" & aParameters(2) & " , $" & FormatNumber(dictCart(Key) * CSng(aParameters(2)),2) & VbCrLf %> <% sTotal = sTotal + (dictCart(Key) * CSng(aParameters(2))) Next 'Calculate shipping - you might want to pull this out into a function if your shipping ' calculations are more complicated then ours. ;) If sTotal <> 0 Then sShipping = 0 Else sShipping = 0 End If sTotal = sTotal + sShipping %>
Photo Description Quantité Prix Total
<%= aParameters(1) %> <%= dictCart(Key) %> $<%= aParameters(2) %> $<%= FormatNumber(dictCart(Key) * CSng(aParameters(2)),2) %>
(transport inclus)      Total: $<%= FormatNumber(sTotal,2) %>
<% VarMessage = VarMessage & "TOTAL : $" & FormatNumber(sTotal,2) & VbCrLf session ("LetotalDo") = FormatNumber(sTotal,2) End Sub ' We implemented this this way so if you attach it to a database you'd only need one call per item Function GetItemParameters(iItemID) Dim aParameters ' Will contain 3 string values : image path, description, price ' However we need to keep price so it can be converted to a ' single for computation hence no currency symbol. This array ' can also be expanded to contain any other information about the ' product that you might want to pull from the DB. Select Case iItemID Case 1 aParameters = Array("GuiTarPhotos/Album1_p.jpg", "Maître de ton destin
(cassette)", "8.00") Case 2 aParameters = Array("GuiTarPhotos/Album1_p.jpg", "Maître de ton destin
(CD)", "12.00") End Select ' Return array containing product info. GetItemParameters = aParameters End Function %> <% ' ***** Begin the infamous runtime script ***** ' Declare our Vars Dim dictCart ' as dictionary Dim sAction ' as string Dim iItemID ' as integer Dim iItemCount ' as integer ' Get a reference to the cart if it exists otherwise create it If IsObject(Session("cart")) Then Set dictCart = Session("cart") Else ' We use a dictionary so we can name our keys to correspond to our ' item numbers and then use their value to hold the quantity. An ' array would also work, but would be a little more complex and ' probably not as easy for readers to follow. Set dictCart = Server.CreateObject("Scripting.Dictionary") End If ' Get all the parameters passed to the script sAction = CStr(Request.QueryString("action")) iItemID = CInt(Request.QueryString("item")) iItemCount = CInt(Request.QueryString("count")) %>
<% ' Select action based on user input Select Case sAction Case "add" AddItemToCart iItemID, iItemCount ShowItemsInCart %>
<% Case "del" RemoveItemFromCart iItemID, iItemCount ShowItemsInCart %>
<% Case "viewcart" ShowItemsInCart %>
<% Case "checkout" PlaceOrder %>

De Envoyé à
<%= request.Form("Nom") %>  
<%= request.Form("Adresse") %>
Téléphone :
<%= request.Form("Telephone") %>
<%= request.Form("Courriel") %>

<%= request.Form("Message") %>
Donald Loignon 
1375 119e rue
St-Georges, Québec
Canada
G5Y 3B6

Téléphone :
(418) 228-5866

Veuillez faire imprimer ce bon de commande et envoyer un chèque ou mandat poste à l'adresse ci-haut.

<% sTotal = 0 For Each Key in dictCart aParameters = GetItemParameters(Key) NomDuCD = aParameters(1) NomDuCD = replace (NomDuCD,"
" ,"",1) VarMessage = VarMessage & "Qte : " & dictCart(Key) & " - " & NomDuCD & " , $" & aParameters(2) & " , $" & FormatNumber(dictCart(Key) * CSng(aParameters(2)),2) & VbCrLf sTotal = sTotal + (dictCart(Key) * CSng(aParameters(2))) Next 'Calculate shipping - you might want to pull this out into a function if your shipping ' calculations are more complicated then ours. ;) If sTotal <> 0 Then sShipping = 0 Else sShipping = 0 End If sTotal = sTotal + sShipping VarMessage = VarMessage & "TOTAL : $" & FormatNumber(sTotal,2) & VbCrLf if sTotal > 0 and request.form ("Envoyer") = "Oui" then Set Mail = Server.CreateObject("Persits.MailSender") Mail.Username = emailUsername Mail.Password = emailPassword Mail.Host = emailHost VarMessage = VarMessage & VbCrLf & VbCrLf & "Nom : " & request.Form("Nom") & VbCrLf VarMessage = VarMessage & "Adresse : " & request.Form("Adresse") & VbCrLf VarMessage = VarMessage & "Téléphone : " & request.Form("Telephone") & VbCrLf VarMessage = VarMessage & "Courriel : " & request.Form("Courriel") & VbCrLf VarMessage = VarMessage & "Message : " & request.Form("Message") & VbCrLf Mail.From = "commande@donaldguitar.com" Mail.FromName = "commande@donaldguitar.com" Mail.AddAddress "commande@donaldguitar.com" Mail.Priority = "3" Mail.Subject = "Commande d'album pour Donald Loignon " & date Mail.IsHTML = false Mail.Body = VarMessage On Error Resume Next Mail.Send If Err <> 0 Then Response.Write "Error encountered: " & Err.Description else end if end if Case Else ' Shop ShowFullCatalog %>
<% End Select ' Return cart to Session for storage Set Session("cart") = dictCart %>