<%option explicit shopcheckadmin ""%> <% '************************************************************************** ' Version 6.00 Nov 12, 2005 ' This routines does quite a lot ' sets up e-mail messages for merchant and customer ' Updates stock ' Adds points ' calculated affiliate commission ' updates gifts ' mails to suupliers ' updates project payments ' updates session variables to clear order details ' This is final file in order process ' calls shopthanksmerchant, shopmailformat and shopmail ' calls giftmailing, stock control. ' Mail affiliate '************************************************************************** Dim maillist(20) Dim Maillistcount Dim Textarray(500) Dim TextCount dim my_system dim my_from dim my_fromAddress dim my_subject dim my_to dim my_toAddress Dim attachmentarray(20),attachmentcount dim htmlformat Dim arrCart, scartItem dim mailtype dim body Dim merchant Dim customer dim ordernumber Dim myconn Dim attachmentfile Dim returnlocation dim bypassstockcontrol Dim Merchantemailformat,customeremailformat,paytype ' used to add extra information to messages from shopthanksmerchnat dim merchantextraInfo, CustomerExtraInfo ' dim affiliateid ' start main ordernumber=Getsess("oid") if ordernumber="" then shoperror getlang("langShopThanks03") end if attachmentcount=0 Setsess "emailformat",getconfig("xemailformat") Merchantemailformat="" Customeremailformat="" Merchantextrainfo="This order was paid in your gateway and has been closed" Customerextrainfo="" bypassstockcontrol=false OpenOrderDB myconn ' Open database ShopThanksLinks myconn, ordernumber, attachmentarray,attachmentcount ShopThanksMerchant myconn, ordernumber 'VP-ASP 6.50 - send pin numbers when order processed Shoppinnumbers myconn, ordernumber, "no" sql = "select * from orders where orderid=" & clng(ordernumber) Set rsorder = myconn.Execute(SQL) affiliateid=rsorder("oaffid") ' get affilaite ' if there is a merchant email address then do the stuff If getconfig("xemailname")<>"" then ' this is name to email strSQL = "select * FROM oitems where orderid = " & rsorder("orderid") Set Items = myconn.Execute(strSQL) ' get the record st for order and order items If getconfig("xemailwithtemplates")="Yes" then TemplateFormatMail rsorder, items, merchant, customer ' format the mail message else FormatMail rsorder, items, merchant, customer ' format the mail message end if SetupmailMerchant ' Setup Aspmail or Cdonts etc SetupmailCustomer items.close set items=nothing end if ShopGiftControl ' Giftceritificate e-mails MailToSuppliers MailtoGiftRegistry SendSmsMerchant rsorder CloseRecordset rsorder ShopStockControl ' Update stock if necessary ShopCouponControl ' Update stock if necessary ShopProjectControl ' update project payments ShopCommissionControl ' calculate commission ShopBillControl ' installment billing ShopCancelOrder ' WriteMailError ShopCloseDatabase myconn ' Close the database responseredirect getconfig("xmysite") & "shopa_formatorder.asp?oid=" & clng(ordernumber) ' '*********** end main **************** ' ' Sub MailPerson (toname, toaddress, fromname, fromaddress, subject, tobody,attachmentYesNo) dim acount SetSess "mailerror","" my_system=getconfig("xemailsystem") ' mail.mysystem.com mailtype=getconfig("xemailtype") ' aspmail, jmail, cdonts my_subject=subject my_to=toname my_toAddress=toaddress my_from=fromname my_fromAddress=fromaddress if my_toAddress= "" then exit sub end if if my_from = "" then my_from="Unknown" end if if my_fromAddress="" then my_fromAddress="unknown@unknown.com" end if body=tobody if getconfig("xDebug")="Yes" then debugwrite "mailing to " & toname & " " & toaddress end if htmlformat=Getsess("EmailFormat") If attachmentYesNo="Yes" then acount=attachmentcount else acount=0 end if ExecuteMail mailtype,My_from,my_fromaddress,my_to,my_toaddress,my_subject,body,htmlformat,attachmentarray,acount writemailerror end sub Sub SetupMailMerchant() dim subject if getconfig("Xemailmerchant")<>"Yes" then exit sub If merchantemailformat<>"" then SetSess "emailformat",merchantemailformat end if If merchantextrainfo<>"" then merchant=merchant & merchantextrainfo end if subject=getconfig("xemailsubject") & " " & getlang("langproductordernumber") & " " & ordernumber MailPerson getconfig("xemailname"),getconfig("xemail"),rsorder("olastname"), rsorder("oemail"), subject, Merchant,"No" end sub Sub SetupMailCustomer() if getconfig("Xemailcustomer")<>"Yes" then exit sub If customeremailformat<>"" then SetSess "emailformat",customeremailformat end if dim toname, subject toname=rsorder("ofirstname") & " " toname= toname & rsorder("olastname") ' this is name to email 'debugwrite "toname=" & toname subject=getconfig("xemailsubject") & " " & getlang("langproductordernumber") & " " & ordernumber If customerextrainfo<>"" then customer=customer & customerextrainfo end if MailPerson toname,rsorder("oemail"),getconfig("xemailname"), getconfig("xemail"), subject, Customer,"Yes" end sub ' ' Stock control logic Sub ShopStockControl 'need to pypass this if PayPal was used and stock already updated 'If left(paytype,6) <> "PayPal" then ' bypassstockcontrol=true ' Update stock if necessary 'end if 'on error resume next if bypassstockcontrol=true then exit sub if ucase(getconfig("xstockControl"))="YES" Then UpdateStock ordernumber end if end sub ' Sub ShopCouponControl If GetSess("Coupon")<>"" then UpdateCoupon end if end sub Sub ShopGiftControl If GetSess("Giftid")<>"" then ShopGiftmail ordernumber ' mail gift cerificates in shopgiftdb.asp end if end sub Sub MailToSuppliers if getconfig("xmailtosuppliers")="Yes" then Shopmailtosuppliers end if end sub Sub WriteMailError If GetSess("Mailerror")="" then exit sub If getconfig("xDebug")<>"Yes" then exit sub shopwriteError GetSess("mailerror") end sub ' Sub MailToGiftregistry if getconfig("xgiftregistry")<>"Yes" then exit sub If getSess(REGISTRANTID)<>"" then bypassstockcontrol=true else ProcessGiftRegistryEmails end if end sub ' Sub Shopprojectcontrol if getconfig("xprojectupdate")<>"Yes" then exit sub UpdateProjectpayment myconn, ordernumber end sub Sub ShopCommissionControl ' Calculate affiliate commission if not isnull(affiliateid) then if affiliateid>0 then shopthankscommission myconn, ordernumber, affiliateid shopmailaffiliate myconn, ordernumber, affiliateid end if end if end sub Sub ShopBillControl if getconfig("xbilling")="Yes" then Generatebilling myconn,ordernumber end if end sub '==================================== %>