The mgiSendOrderAN Tag
Tag Behavior
The mgiSendOrderAN tag emails shopping basket orders to a
specified address from a specified address using a specified
email server or writes shopping basket orders to separate text
files and posts customer information to AuthorizeNet for credit
card processing (requires an account with AuthorizeNet). The optional parameters of
mgiSendOrderAN can also be used for inventory control in database-driven
shopping baskets. When the mgiSendOrderAN tag is parsed, the
shopping basket order it sends is deleted from the MGI Shopping
Basket database.
Tag Syntax
The mgiSendOrderAN tag has 4 required parameters and 19 optional
parameters. The tag form is:
<mgiSendOrderAN to="Email Address" from="Email Address" fromName="Name"
mailServer="Server Address" subject="Email Subject"
merchantAccountLogin="AuthorizeNet ID"
taxrate="Decimal Number" state="US State" mode="Mode"
outputFolderLocation="Folder Name" tabDelimitedOutput="Yes/No"
taxShipping="Yes/No" paymentInfoCheck="Yes/No"
shippingInfoCheck="Yes/No" billingInfoCheck="Yes/No"
shoppingBasketURL="URL" theHutmanScenario="Yes/No"
productDatabaseFileLocation="File Path"
productTableName="Table Name" inventoryFieldName="Field Name"
inventoryFieldName="Field Name" inventoryErrorURL="Url"
pgpFunction="Function" passphraseFileLocation="File Path">
Required Parameters:
- to="Email Address" where "Email Address"
is the email address where emails are sent.
- from="Email Address" where "Email Address"
is the address that appears in the "from" line of the
email header.
- mailServer="Server Address" where "Server
Address" is the address of the SMTP mail server that will
send the email.
- merchantAccountLogin="AuthorizeNet ID" where
"AuthorizeNet ID" is unique store ID assigned by AuthorizeNet.
Optional Parameters:
- fromName="Name" where "Name" is
the real name of the person or organization whose email is listed
in the "from" parameter. Warning: Some mail servers
do not allow mail to be relayed if it contains a from name.
- subject="Email Subject" where "Email
Subject" is the subject of the email that is sent. The default
subject is "Online Order Submission".
- taxRate="Decimal Number" where "Decimal
Number" is the tax rate for shipping items in-state to the
state specified in the "state" parameter. The tax rate
should be written as a decimal number (e.g. 0.06) rather than
a percentage (6%). The default is "0.00". This
parameter must match the format of the same parameter in the
mgiConfirmOrder tag exactly.
- state="US State" where "US State"
is the full name of the US State where in-state tax applies.
The State Name is not case-sensitive and can include spaces.
By default, no orders are charged an in-state tax. This
parameter must match the format of the same parameter in the
mgiConfirmOrder tag exactly.
- mode="Mode" where "Mode" is the
way each order is processed. The modes are "emailOnly",
"textFileOnly", "emailAndTextFile",
and "emptyCustomerSB". The emailOnly mode creates
and sends a formatted email with the order information. The textFileOnly
mode writes each order to a separate text document that is named
by the date and time of the order. The emailAndTextFile mode
creates and sends a formatted email with the order information
and writes each order to a separate text document that is named
by the date and time of the order. If you
choose the textFileOnly or emailAndTextFile mode, the outputFolderLocation
parameter is required. The emptyCustomerSB mode deletes
the customer's order from the internal shopping basket database,
but does not send the order information via email or write the
order information in a text file. The default mode is emailOnly.
- outputFolderLocation="Folder Name" where
"Folder Name" is the name of the folder in your directory
where text file orders are kept.
- tabDelimitedOutput="Yes/No" where "Yes"
indicates that text file orders are delimited by tabs and can
be imported into a database program and "No" indicates
that the text file is formatted. The default is "Yes".
- taxShipping="Yes/No" where "Yes"
indicates that tax is charged on the SubTotal and Shipping and
"No" indicates that tax is charged on the SubTotal
only. The default is "No".
- paymentInfoCheck="Yes/No" where "Yes"
indicates that payment information is required and "No"
indicates that payment information is not required. The default
is "Yes".
- shippingInfoCheck="Yes/No" where "Yes"
indicates that the customer's shipping information is verified
and "No" indicates that customer's shipping
information is not verified. The default is "Yes".
- billingInfoCheck="Yes/No" where "Yes"
indicates that the customer's billing information is verified
and "No" indicates that customer's billing information
is not verified. The default is "No".
- shoppingBasketURL="URL" where "URL"
is the absolute address to the folder that contains the original
MGI Data folder (and thus contains the original MGI Shopping
Basket database). For example, "http://www.domain.com"
or "http://www.domain.com/~store/" This
parameter is required when using separate secure and unsecure
servers and a true virtual hosting application.
- theHutmanScenario="Yes/No" where "Yes"
indicates that your secure folder is hosted virtually under the
folder of another company (e.g., your hosting company) and "No"
indicates that your secure folder is not hosted virtually under
the folder of another company or all of your shopping basket
files are under one folder on a non-secure folder. See below
for examples. The default is "No".
The following folder structures require theHutmanScenario:
Secure Folder = WebStarRoot/Secure/Company/Secure Files
Non-Secure Folder = WebStarRoot/Company/Non-Secure Files
The following folder structures do not require theHutmanScenario:
Secure Folder = WebStarRoot/Company/Secure Files
Non-Secure Folder = WebStarRoot/Company/Non-Secure Files
Non-Secure Folder = WebStarRoot/Company/All Files
Optional Inventory Control Parameters:
- productDatabaseFileLocation="File Path"
where "File Path" is the location of the product database
file relative to the root of the website
(i.e., the full path name beginning with the first
folder beneath your root folder name). If the product database
is at the root level of your site, the file path is only the
name of the product database (no folder names). If the product
database is in a folder beneath your root named "Store",
then the file path would be "Store/DatabaseName". The
full path to the product database is required because the inventory
control may be performed across multiple machines (e.g., secure
servers and unsecure servers).
- productTableName="Table Name" where "Table
Name" is the case-sensitive name of the product table within
the product database.
- inventoryFieldName="Field Name" where "FieldName"
is the case-sensitive name of the inventory field within the
product table. The inventory field (which contains the current
number of items available for sale) must
be an "integer" type. Field types are chosen
when the field is created.
- productIDFieldName="Field Name" where "FieldName"
is the case-sensitive name of the product ID field within the
product table.
- inventoryErrorURL="Url" where "Url"
is the full path to the webpage where visitors will be redirected
if an inventory error occurs (e.g. if the visitor orders more
of an item than is available). The error page should not reside
on a secure server since you need to give customers access to
their shopping basket in order to make changes.
Optional Order Encryption Parameters:
- pgpFunction="Function" where "Function"
is the PGP action. Currently, the only valid function is "encryptWithPhrase".
The encryptWithPhrase function encrypts an order using the pass
phrase listed in the pass phrase file. If
the pgpFunction parameter is included, the passphraseFileLocation
parameter is required.
- passphraseFileLocation="File Path" where
"File Path" is the relative location of the file that
contains the pass phrase to encrypt the order. The passphrase
is a text only file (although it may include hidden characters
such as returns that would be necessary for decoding). The passphrase
it contains can be any size. Note: the passphrase file itself
or a folder in the path to the passphrase file should be password
protected by a WebSTAR realm. If you administer the server,
you can set the realm. If you are hosted on a virtual server,
a specific folder name or file name may be required. Contact
your system administrator for the required folder or file name.
If the passphraseFileLocation parameter
is included, the pgpFunction parameter is required
Example Usage and Output
<FORM ACTION="https://secure.authorize.net/gateway/transact.dll" METHOD="post">
<mgiSendOrderAN to="orders@domain.com" subject="AuthNet Test"
state="Washington" taxrate=".082" mailServer="mail.domain.com"
from="webmaster@domain.com" taxShipping="yes"
merchantAccountLogin="computerbooks">
<p>Your order has been sent.
<mgiConditional lhs="shoppingBasketPaymentMethod"
relationship="equals" rhs="creditCard">
<p>Click the "Authorize Credit Card" button to process your credit card payment.
<mgiButton name="Authorize Credit Card">
</mgiConditional>
</FORM>
The mgiSendOrderAN tag will email a pre-formatted email containing
payment, shipping, and shopping basket information for each order
(see below). For credit cards orders, use HTML <FORM> tags
and a submit button to post orders to the AuthorizeNet server
for credit card processing. The <FORM> action should post
to "https://secure.authorize.net/gateway/transact.dll".
The submit button is only necessary for credit card orders, therefore
a conditional is used to display the "Authorize Credit Card"
button only when the payment type is "creditCard".
The following online order has been received.
Shipping Information
====================
Name: Kevin Ellis
Company: ABC, Inc.
Address: 6472 Main Street
City: Dallas
State: Texas
Province:
Postal Code: 38291
Country: USA
Phone: 238-349-2291
Fax: 238-349-2292
Email: kellis@pagesz.net
Payment Information
===================
Payment Method: Credit Card
Credit Card Type: Visa
Credit Card Number: 1234 5678 9012 3456
Credit Card Expiration: 12 / 00
Ordered Items
=============
Product ID: 0-8053-0040-6
Quantity: 1
Product Info: Title -- Computers: Tools for an Information Age
format -- Paperback
Price (ea.): $14.95
Total Price: $14.95
Total
=====
Subtotal: $14.95
Shipping: $5.00
Tax: $0.00
Grand Total: $19.95
Inventory Control Functions:
When a customer attempts to order more items than are currently
available according to an inventory field in your database, you
can use inventory control optional parameters to redirect the
customer to a webpage detailing the discrepancies between their
order and what is actually in inventory. These functions are
flexible, so the precise content and design of the page displaying
the errors is up to the site designer.
Each inventory error is carried by a path argument from the
send order page (which may be located on a secure server) to
the inventory error page (which should be located on a non-secure
server). To display each product ID and associated quantity that
is in error, use an mgiPathArgument tag with the name "mgiInventoryErrorProductIDX" and an mgiPathArgument tag
with the name "mgiInventoryErrorQuantityX"
where "X" is the
error number in sequence beginning with "1". You should
anticipate the number of inventory errors that a customer might
have and include a set of mgiPathArgument tags to accommodate
each error. You may include as many mgiPathArgument tags as are
necessary. You may also use a combination of mgiIf comparisons
to only display errors that are actually passed via path arguments
from the send order page.
Below your display of the inventory errors, include the mgiShoppingBasket
tag, mgiSBPrice, mgiSBShippingCost tag, and "Modify Shopping
Basket" mgiButton tag as they appear on your shopping basket
display page to allow the customer to change their quantities
and re-submit their order. In order for the mgiShoppingBasket
tag to function, you must enclose it with HTML <FORM> tags
whose action is the name of the inventory error page (i.e., the
page will post to itself). In order for the customer to re-submit
their order, include an mgiButton tag enclosed by HTML <FORM>
tags whose action is the name of your check out page.
Finally, enclose all tags (including <FORM> tags) with
mgiToken tags to track the customer's unique order.
The following is an example inventory error page (that should
be located on a non-secure server):
<html>
<head>
<title>Inventory Error</title>
</head>
<body bgcolor="#ffffff">
<mgiToken>
An inventory error has occured. Please modify your shopping
basket and checkout again.
<p>
<!--Set Each Inventory Error in a Variable-->
<mgiset name="id1">
<mgipathargument name="mgiInventoryErrorProductID1">
</mgiset>
<mgiset name="quan1">
<mgipathargument name="mgiInventoryErrorQuantity1">
</mgiset>
<mgiset name="id2">
<mgipathargument name="mgiInventoryErrorProductID2">
</mgiset>
<mgiset name="quan2">
<mgipathargument name="mgiInventoryErrorQuantity2">
</mgiset>
<mgiset name="id3">
<mgipathargument name="mgiInventoryErrorProductID3">
</mgiset>
<mgiset name="quan3">
<mgipathargument name="mgiInventoryErrorQuantity3">
</mgiset>
<!--Only Display Inventory Errors that Exist in a Table-->
<table border="1">
<tr><th><b>Offending Product IDs</b></th>
<th><b>Quantity in Stock</b></th></tr>
<mgiif target="variable" name="id1" relationship="isEmpty">
<mgielse>
<tr><td align="center"><mgiget name="id1"></td>
<td align="center"><mgiget name="quan1"></td></tr>
</mgiif>
<mgiif target="variable" name="id2" relationship="isEmpty">
<mgielse>
<tr><td align="center"><mgiget name="id2"></td>
<td align="center"><mgiget name="quan2"></td></tr>
</mgiif>
<mgiif target="variable" name="id3" relationship="isEmpty">
<mgielse>
<tr><td align="center"><mgiget name="id3"></td>
<td align="center"><mgiget name="quan3"></td></tr>
</mgiif>
</table>
<p>
<!--Display the Customer's Current Shopping Basket-->
<!--and Modify Shopping Basket Button for Changes-->
<form action="redirectSB.html" method="post">
<mgiShoppingBasket productDatabaseFileLocation="Product DB2"
productTableName="Product Information"
productIDFieldName="Product ID"
formatFileLocation="Txt/sbformat.txt"
templateFileLocation="Txt/sbtemplate.txt">
<mgiSBPrice name="price" priceFieldName="Price">
<mgiSBShippingCost name="shippingCost"
method="baseplusperitem"
baseshippingcost="5.00"
shippingCostFieldName="Shipping Cost">
</mgiShoppingBasket>
<mgibutton name="Modify Shopping Basket">
</form>
<!--Display the Checkout Button to Re-Submit Order-->
<form action="checkout.html" method="post">
<input type="submit" name="checkout" value="Checkout">
</form>
</mgiToken>
</body>
</html>
Suggested Usage
- Hard-Coded Shopping Baskets
- Database-Driven Shopping Baskets
- Inventory Control
|