Difference between revisions of "Functions:pageProductsGet"

From Whirlwind eCommerce Wiki
Jump to: navigation, search
(New page: == Description == retrieves product data for use in displaying products in page template management. == Syntax == $array = eV::pageProductsGet($pageId[,$fieldList]); == Paramaters == *$...)
 
(Return Values: added prodLayout_isConfigurable)
 
(22 intermediate revisions by 2 users not shown)
Line 1: Line 1:
 +
{{Page Template Functions Shortcuts}}
 
== Description ==
 
== Description ==
 
retrieves product data for use in displaying products in page template management.  
 
retrieves product data for use in displaying products in page template management.  
Line 27: Line 28:
 
             [salePrice] => DECIMAL
 
             [salePrice] => DECIMAL
 
             [price] => DECIMAL
 
             [price] => DECIMAL
 +
            [lowPrice] => DECIMAL
 +
            [lowFlatPrice] => DECIMAL
 
             [saleFromDate] => DATETIIME
 
             [saleFromDate] => DATETIIME
 
             [saleToDate] => DATETIME
 
             [saleToDate] => DATETIME
Line 34: Line 37:
 
             [imageAlt] => STR
 
             [imageAlt] => STR
 
             [saleOn] => BIT
 
             [saleOn] => BIT
 +
            [minQuantity] => INT
 +
            [maxQuantity] => INT
 +
            [increments] => INT
 
             [customContent] => STR
 
             [customContent] => STR
 
             [priceLevelsData] => STR
 
             [priceLevelsData] => STR
 
             [optionGroupsData] => STR
 
             [optionGroupsData] => STR
 +
            [prodLayout_isConfigurable] => BIT
 
             [priceLevelArray] => Array
 
             [priceLevelArray] => Array
 
                 (
 
                 (
Line 48: Line 55:
  
 
                         )
 
                         )
 +
                    [1] ...
 
                 )
 
                 )
 
             [optionGroupArray] => Array
 
             [optionGroupArray] => Array
Line 55: Line 63:
 
                               [groupId] => INT
 
                               [groupId] => INT
 
                               [groupName] => STR
 
                               [groupName] => STR
 +
                              [groupTitle] => STR
 +
                              [groupField] => STR
 
                               [optionList] => STR
 
                               [optionList] => STR
 
                               [optionArray] => Array
 
                               [optionArray] => Array
Line 65: Line 75:
 
                                                   [priceOption] => INT
 
                                                   [priceOption] => INT
 
                                                   [weight] => DECIMAL
 
                                                   [weight] => DECIMAL
 +
                                                  [value] => STR
 
                                             )
 
                                             )
 
                                   )
 
                                   )
  
 
                         )
 
                         )
 +
                    [1] ...
 
                 )
 
                 )
 +
            [custom_field_#] => MIXED
 +
            [custom_field_{name}] => MIXED
  
             
+
        )
 +
    [1] ...         
 
)
 
)
 
</pre>
 
</pre>
  
Elements from the menu item associative array are as follows:  
+
Elements from the product associative array are as follows:  
 
{|border=2
 
{|border=2
 
|-
 
|-
Line 82: Line 97:
 
|Example
 
|Example
 
|-
 
|-
|location
+
|productId
|String: Reflects the menu bar location, either 'l' for left, 'r' for right, 't' for top, 'b' for bottom
+
|INTEGER - the unique id assigned to the product when created in administration
|r
+
|123
 
|-
 
|-
|id
+
|title
|Integer: Returns the database unique id for this menu item. Useful to target specific menu items for individual display results or if individual menu items need to be tracked for certain purposes.
+
|STRING - as set in administration console for this product, typically used as a short title for the product when displaying it in a page and / or when displaying it in the shopping cart
|196
+
|Shirt
 
|-
 
|-
|text
+
|childDescription
|String: The output text of the link. This is what the web site visitors should see as the link. This text is rawurlencoded in the database but rawurldecoded before the value is placed in this element.
+
|STRING - as set in administration for this product, typically used to further describe the product when it is listed in a page.
|Category X<br>
+
|This is an oversized long sleeve shirt
Specials<br>
+
|-
Subcategory Y
+
|imagePath
 +
|STRING - path to the image representing the product as set in administration for this product. Typically used in the shopping cart.
 +
|/folder/folder/image.jpg
 +
|-
 +
|productNumber
 +
|STRING - stock code as assigned in administration for this product. Synonymous with SKU, this number is usually displayed in the page containing the product, the shopping cart, throughout the checkout process and even in order management after the sale.
 +
|SLSO1
 +
|-
 +
|catalogNumber
 +
|STRING - an alternative number associated with the product. Typically used in print catalogs, this number is usually used for catalog quick order forms and/or a way for the customer to verify they are ordering the same item online as it appears in the catalog. Usually this is the same as the SKU.
 +
|SHRTLSO
 +
|-
 +
|listPrice
 +
|DECIMAL - the list price as set in administration for the product. Typically used to show the visitor the discount they are receiving. When the visitor purchases they will receive the best price of the following :listPrice, salePrice (if qualifies), price, qualifying price level(s)
 +
|12.34
 +
|-
 +
|salePrice
 +
|DECIMAL - The sale price as set in administration for the product. Typically used for special promotions or sales for the product, it can be controlled via the saleFromDate and saleToDate fields (use saleOn is a quick test to see if the sale price qualifies)
 +
|10.45
 +
|-
 +
|price
 +
|DECIMAL - the price as set in administration for the product. This is typically the 'regular price' of the product, what it is typically sold for on the web site. Note, as you are building the page template that contains products you can display this information anyway you wish - as clients typically want their regular price to look like a special price even though it is not.
 +
|11.22
 +
|-
 +
|lowPrice
 +
|DECIMAL - the lowest possible price for this product. Takes into consideration list, regular, sale (if qualifies) and price levels.
 +
|9.88
 +
|-
 +
|lowFlatPrice
 +
|DECIMAL - the lowest flat price for this product. Takes into consideration list, regular, sale (if qualifies). DOES NOT take into consideration price levels.
 +
|10.25
 
|-
 
|-
|textRaw
+
|saleFromDate
|String: non-rawurldecoded version of "text" used for debugging.
+
|DATETIME - The starting date that the sale price will be available, as set in administration for this product. If this value is empty, than the sale price has no starting date and is considered available until the saleToDate is reached.
|Category%20X<br>
+
|2008-08-25 00:00:00
Specials<br>
+
Subcategory%20Y<br>
+
 
|-
 
|-
|link
+
|saleToDate
|String: use as the href value when linking the menu item. It is recommended that you test this element for content before creating the link, so that content managers can leave the content empty for non-linked menu elements (category headers, etc)
+
|DATETIME - the ending date that the sale price will be available until, as set in administration for this product. If this value is empty, than the sale price never ends and is considered available so long as the saleFromDate is passed.
|index.php?pageId=125
+
|2008-08-30 00:00:00
http://www.google.com
+
 
|-
 
|-
|newWindow
+
|isTaxable
|Integer: either 1 or 0 to designate if clicking this link should open a new window or place the targetted url in the current window. This element is replaced by the target element.
+
|BIT - Flag set in administration to mark if the product qualifies for taxation rules or not.
 
|1
 
|1
 
|-
 
|-
|level
+
|shippingSurcharge
|Integer: For tiered menus, designates what level of the tier this menu item is on. 0 for the top tier, increasing as the tiers lower. As many designs will have different styles for different tiers in the menu listing (especially for the left menu bar) this is useful to identify the current tier and output the appropriate style.
+
|DECIMAL - additional surcharge added to shipping for this product. This shipping surcharge is multiplied by the product quantity
|2
+
|11.22
 
|-
 
|-
|target
+
|weight
|String: the actual window the link is targeted towards (_self or _blank). This replaces the newWindow element. Simply place in the 'target' attribute of the href tag.
+
|DECIMAL - the weight for the product as set in administration. Used to calculate shipping via weighted shipping tables. Stated in Lbs.
|_blank
+
|5.45
 
|-
 
|-
|display
+
|imageAlt
|Boolean: For reactive menus that display elements only as parent elements are selected, this will dignate
+
|STRING - image alt value as set in administration. To be applied to the imagePath image with it is displayed.
(via TRUE or FALSE) if this menu item is slated for display. This will also slate the parent menu item(s) to be displayed when a lower level menu item is selected
+
|Picture of a shirt
|TRUE
+
 
|-
 
|-
|focus
+
|saleOn
|Boolean: States if this menu item is actually the current page the visitor is on. This is done by URL matching the contents of the 'link' element and the current URL. As some designs call for menu items that are current pages to be styled differently, this will allow identification of such menu items.
+
|BIT - an easy flag that set to 1 if a sale price is set and the saleFromDate, saleToDate are met. Set to 0 if not.
|FALSE
+
|1
 +
|-
 +
|customContent
 +
|STRING - depriciated
 +
|
 +
|-
 +
|priceLevelArray
 +
|Array - multidimensional array containing price levels and prices/quantities associated with each level. Prices will be calculated automatically when item(s) are added to the shopping cart, so this information is for display purposes only. See below table for breakdown
 +
|[Array]
 +
|-
 +
|optionGroupArray
 +
|Array - multidimensional array containing option group information. See below table for breakdown
 +
|[Array]
 +
|-
 +
|prodLayout_isConfigurable
 +
|BIT - 1 if configuration (personalization) settings are in place, 0 if not
 +
|1
 +
|-
 +
|minQuantity
 +
|Integer - minimum quantity required to order
 +
|5
 +
|-
 +
|maxQuantity
 +
|Integer - maximum quantity allowed to be ordered
 +
|100
 +
|-
 +
|increments
 +
|Integer - quantity ordered must be divisible by this number
 +
|10
 +
|-
 +
|custom_field_#
 +
|Mixed - value of custom field. # is the id of the field as per the product template.
 +
|Anything
 +
|-
 +
|custom_field_{name}
 +
|Mixed - value of custom field. {name} is the name of the custom field as specified in the product template.
 +
|Anything
 +
|}
 +
 
 +
Elements from the priceLevelArray associative array are as follows:
 +
{|border=2
 +
|-
 +
|Element
 +
|Description
 +
|Example
 +
|-
 +
|quantity
 +
|INTEGER - quantity floor threshold to qualify for this price.
 +
|3
 +
|-
 +
|price
 +
|DECIMAL - price (per item) that the product will qualify for if quantity threshold is met
 +
|9.00
 +
|-
 +
|price2
 +
|DECIMAL - alternate price (per item) that the product will qualify for if quantity threshold is met AND an option is selected that contains the {priceOption:2} flag, as set in administration.
 +
|8.00
 +
|-
 +
|price3
 +
|DECIMAL - alternate price (per item) that the product will qualify for if quantity threshold is met AND an option is selected that contains the {priceOption:3} flag, as set in administration.
 +
|7.00
 +
|-
 +
|price4
 +
|DECIMAL - alternate price (per item) that the product will qualify for if quantity threshold is met AND an option is selected that contains the {priceOption:4} flag, as set in administration.
 +
|6.00
 +
|-
 +
|}
 +
 
 +
Elements from the optionGroupArray associative array are as follows:
 +
{|border=2
 +
|-
 +
|Element
 +
|Description
 +
|Example
 +
|-
 +
|groupId
 +
|INTEGER - the unique ID assigned to the group when it is created in administration
 +
|25
 +
|-
 +
|groupName
 +
|STRING - Group name as set in administration for the group. Used for site admins to uniquely identify the group
 +
|Size
 +
|-
 +
|groupTitle
 +
|STRING - Group title as set in administration for the group. Typically used as a title for the group when presenting within the page.
 +
|Size
 +
|-
 +
|groupField
 +
|STRING - complete code for select field containing this groups' options. Simply plop into your page template where you want the drop down to appear.
 +
|&lt;SELECT name="group52"&gt;
 +
&lt;OPTION value="Small{sku:SM}"&gt;Small&lt;/OPTION&gt;
 +
&lt;OPTION value="Medium{sku:ME}"&gt;Medium&lt;/OPTION&gt;
 +
&lt;OPTION value="Large{sku:LG}{price:3.00}"&gt;Large + $3.00&lt;/OPTION&gt;
 +
&lt;/SELECT&gt;
 +
|-
 +
|optionArray
 +
|ARRAY - multidimensional array of option values for this group. See the following table for details
 +
|[ARRAY]
 +
|}
 +
 
 +
Elements from the optionArray associative array are as follows:
 +
{|border=2
 +
|-
 +
|Element
 +
|Description
 +
|Example
 +
|-
 +
|text
 +
|STRING - The text output of the option
 +
|large
 +
|-
 +
|price
 +
|DECIMAL - the price offset of the option. This offset will be automatically added to the product cost, if this option is selected, when it is placed in the shopping cart.
 +
|3.00
 +
|-
 +
|sku
 +
|STRING - if this field has value, it will automatically be appended to the products' SKU (productNumber) when it is added to the shopping cart, if this option is selected.
 +
|_LG
 +
|-
 +
|priceOption
 +
|INTEGER - 1 through 4. If an option with this set is selected, the appropriate price level alt price (see priceLevelArray above) will be applied to the product price.
 +
|2
 +
|-
 +
|weight
 +
|DECIMAL - weight offset of the option. This offset is automatically added to the product weight if this option is selected, when the item is added to the shopping cart.
 +
|1.15
 +
|-
 +
|value
 +
|STRING - the full data value of the option including the text, price, weight, priceOption, sku. This is what is used to populate the value attribute of the form field (weather option, radio) when building custom product page forms.
 +
|Large{sku:_LG}{price:3.00}{weight:1.15}{priceOption:2}
 
|}
 
|}
  
 
== Examples ==
 
== Examples ==
;Simple listed menu output for the top and bottom menu
+
===Simple example displaying only a single product and add to cart buttons (no options, not price levels)===
 +
Only the first product in the page will be addresses, others will be ignored.
 
<source lang="php">
 
<source lang="php">
// get the menus
+
// get the products
$arrMenus = eV::pageMenuGet();
+
$prodArr = eV::pageProductsGet($pageId,"title,childDescription,productNumber,lowPrice,productId");
  
// shortcut the applicable menus
+
// display first product
$arrTopMenu = $arrMenus['t'];
+
if(count($prodArr)){
$arrBottomMenu = $arrMenus['b'];
+
  // shortcut first product
 +
  $prod = $prodArr[0];
 +
  // output product data
 +
  echo "<hr><b>" . $prod['title'] . "</b> - " . $prod['productNumber'] . " - " . eV::dollarFormat($prod['lowPrice']) . "<br>" . $prod['childDescription'];
  
// output top menu as a list
+
  // product order form
echo "<ul>";
+
  echo "<form action=\"index.php\" method=\"post\">";
foreach($arrTopMenu as $menuItem) echo "<li><a href=\"" . $menuItem['link'] . "\" target=\"" . $menuItem['target'] . "\">" . $menuItem['text'] . "</a></li>";
+
  echo "<input type=\"text\" size=5 maxlength=4 name=\"quantity\"> <input type=\"submit\" value=\"Add To Cart\">";
echo "</ul>";
+
  // hidden fields fa,productId required
 +
  echo "<input type=\"hidden\" name=\"fa\" value=\"order.cartAdd\">";
 +
  echo "<input type=\"hidden\" name=\"productId\" value=\"" . $prod['productId'] . "\">";
 +
  echo "</form>";
 +
// end product loop
 +
} else {
 +
// no products set up
 +
};
  
// output bottom menu as &middot; separated links
+
</source>
$tempArr = Array();
+
 
foreach($arrBottomMenu as $menuItem) $tempArr[] = "<a href=\"" . $menuItem['link'] . "\" target=\"" . $menuItem['target'] . "\">" . $menuItem['text'] . "</a>";
+
 
echo implode(" &middot; ", $tempArr);
+
===Simple example displaying products and add to cart buttons (no options, not price levels)===
 +
<source lang="php">
 +
// get the products
 +
$prodArr = eV::pageProductsGet($pageId,"title,childDescription,productNumber,lowPrice,productId");
 +
 
 +
// loop thru products
 +
foreach($prodArr as $prod) {
 +
  // output product data
 +
  echo "<hr><b>" . $prod['title'] . "</b> - " . $prod['productNumber'] . " - " . eV::dollarFormat($prod['lowPrice']) . "<br>" . $prod['childDescription'];
 +
 
 +
  // product order form
 +
  echo "<form action=\"index.php\" method=\"post\">";
 +
  echo "<input type=\"text\" size=5 maxlength=4 name=\"quantity\"> <input type=\"submit\" value=\"Add To Cart\">";
 +
  // hidden fields fa,productId required
 +
  echo "<input type=\"hidden\" name=\"fa\" value=\"order.cartAdd\">";
 +
  echo "<input type=\"hidden\" name=\"productId\" value=\"" . $prod['productId'] . "\">";
 +
  echo "</form>";
 +
// end product loop
 +
};
  
 
</source>
 
</source>
  
;Intermediate menu with varying classes for first element, last element and element linking to current page
+
===Complex example displaying products, price levels and options (with simple option field output)===
 
<source lang="php">
 
<source lang="php">
// get the menus
+
// get the products
$arrMenus = eV::pageMenuGet();
+
$prodArr = eV::pageProductsGet($pageId,"title,childDescription,productNumber,lowPrice,productId");
  
// shortcut the top menu
 
$arrTopMenu = $arrMenus['t'];
 
  
// loop thru menu items
 
for($i=0;$i>count($arrTopMenu);$i++){
 
  
  $menuItem = $arrTopMenu[$i];
+
// loop thru products
  
  // set default class
+
foreach($prodArr as $prod) {
  // of course the following classes need to be defined in a style sheet before this displays
+
  $class = "menuItem";
+
  if($menuItem['focus']){
+
    // the current URL is this menu item
+
    $class = "menuItemSelected";
+
  } else if ($i == 0) {
+
    // menu item is not selected, but is first item to appear
+
    $class = "menuItemFirst";
+
  } else if ($i == count($arrTopMenu)-1) {
+
    // menu item is not selected, but is last menu item to appear
+
    $class = "menuItemLast";
+
  };
+
  
  echo "<li class=\"$class\">";
+
    // output base product data
  // only display link if not empty
+
    echo "<hr><b>" . $prod['title'] . "</b> - " . $prod['productNumber'] . " - as low as: " . eV::dollarFormat($prod['lowPrice']) . " each<br>" . $prod['childDescription'];
  if(!empty($menuItem['link'])) echo "<a href=\"" . $menuItem['link'] . "\" target=\"" . $menuItem['target'] . "\">";
+
  echo $menuItem['text'];
+
  if(!empty($menuItem['link'])) echo "</a>";
+
  echo "<li>";
+
  
// end loop thru menu items
+
  // start price level table
 +
  echo "<table><tr><td>Quantity</td><td>Price Each</td></tr>";
 +
  // loop thru price levels and output
 +
  foreach($prod['priceLevelArray'] as $priceLevel) echo "<tr><td>" . $priceLevel['quantity'] . "</td><td>" . eV::dollarFormat($priceLevel['price']) . " each</td></tr>";
 +
  // end price level table
 +
  echo "</table>";
 +
 
 +
  // start order form
 +
  echo "<form action=\"index.php\" method=\"post\" name=\"prodForm" . $prod['productId'] . "\">";
 +
  // loop thru option groups (must be inside of form, as they need to be submitted with form
 +
  foreach($prod['optionGroupArray'] as $optionGroup) echo '<br>' . $optionGroup['groupTitle'] . " : " . $optionGroup['groupField'];
 +
 
 +
  // quantity and submit button
 +
  echo "<br><input type=\"text\" size=5 maxlength=4 name=\"quantity\"> <input type=\"submit\" value=\"Add To Cart\">";
 +
 
 +
  // hidden fields fa, productId (required)
 +
  echo "<input type=\"hidden\" name=\"fa\" value=\"ORDER.cartAdd\">";
 +
  echo "<input type=\"hidden\" name=\"productId\" value=\"" . $prod['productId'] . "\">";
 +
 
 +
  // end order form
 +
  echo "</form>";
 +
// end product loop
 
};
 
};
 
</source>
 
</source>
  
;Advanced example using tiered menus that only display sub menus items if visitor is currently navigated to a menu item
+
===Complex example demonstrationg the javascript live price display===
 
<source lang="php">
 
<source lang="php">
// get the menus
+
// get the products
$arrMenus = eV::pageMenuGet();
+
$prodArr = eV::pageProductsGet($pageId,"title,childDescription,productNumber,lowPrice,productId");
  
// shortcut the left menu
+
/* javascript live price display
$arrLeftMenu = $arrMenus['l'];
+
Uses a series of javascript functions to set page elements to the price of products. As the product price changes (due to quantity changes, or options selected that effect price), the price in the element will update live.
 +
The javascript will automatically attach events to the quantity and option group fields so as they are changed, the price change is triggered.
 +
*/
 +
/*
 +
Call engine core javascript functions
 +
This only needs to be called once, so if already calling it in an include no need to call it again here
 +
*/
 +
echo "\n<script language=\"javascript\" src=\"/common/fnEtc.js\"></script>";
 +
/*
 +
Call the code that will setup and initialize the live price display.
 +
Note that three attributes need to be passed to the src script:
 +
1) pageId - set this to the current pageId which will instruct the script as to which products (product children to the page) will need to be addresses
 +
2) formNameRE - the format of the form names. Each product in the page must have it's own form name, the form name must contain the productId AND the form names must all follow the same naming convention. Enter that naming convention here, replacing the productId with the '#' symbol. For example, if the form names are product3Form, product5Form, product8Form, then enter product#Form; if the names are prod5, prod12, prod16, then enter prod#. Since # is reserved for specifying an anchor in the url, be sure to escape (urlencode) the # sign.
 +
3) elementIdRE - the format of the elements that will be populated with the resulting price. All these elements' id's must follow the same naming convention. Enter that naming convention here, replacing the productId with the '#' symbol. For example, if the elements ids are outputPrice4, outputPrice16, outputPrice42 then elementIdRE should be outputPrice#. Since # is reserved for specifying an anchor in the url, be sure to escape (urlencode) the # sign.
 +
*/
 +
echo "\n<script language=\"javascript\" src=\"index.php?fa=PAGE.prodPriceInitJS&pageId=$pageId&formNameRE=prodForm" . urlencode('#') . "&elementIdRE=prodPriceOutput" . urlencode('#') . "\"></script>\n";
  
// loop thru menu items
 
for($i=0;$i>count($arrLeftMenu);$i++){
 
  
  $menuItem = $arrLeftMenu[$i];
+
// loop thru products
  
  // only output this menu item if it is displayed OR is in top two levels
+
foreach($prodArr as $prod) {
  // i.e. always show the top two levels
+
  if($menuItem['display'] || $menuItem['level'] <= 1) {
+
      // assumes style classes are setup for:
+
      // leftMenuTier0,leftMenuTier0Selected
+
      // leftMenuTier1,leftMenuTier1Selected
+
      // leftMenuTier2,leftMenuTier2Selected
+
      // leftMenuTier3,leftMenuTier3Selected
+
  
      $class = "leftMenuTier" . $menuItem['level'];
+
    // output base product data
      if($menuItem['focus']) $class .= "Selected";
+
    echo "<hr><b>" . $prod['title'] . "</b> - " . $prod['productNumber'] . " - as low as: " . eV::dollarFormat($prod['lowPrice']) . " each<br>" . $prod['childDescription'];
  
      echo "<li class=\"$class\">";
+
  // start price level table
      // only display link if not empty
+
  echo "<table><tr><td>Quantity</td><td>Price Each</td></tr>";
      if(!empty($menuItem['link'])) echo "<a href=\"" . $menuItem['link'] . "\" target=\"" . $menuItem['target'] . "\">";
+
  // loop thru price levels and output
      echo $menuItem['text'];
+
  foreach($prod['priceLevelArray'] as $priceLevel) echo "<tr><td>" . $priceLevel['quantity'] . "</td><td>" . eV::dollarFormat($priceLevel['price']) . " each</td></tr>";
      if(!empty($menuItem['link'])) echo "</a>";
+
  // end price level table
      echo "<li>";
+
  echo "</table>";
  
  // end if this is to be displayed
+
  // start order form
  };
+
  echo "<form action=\"index.php\" method=\"post\" name=\"prodForm" . $prod['productId'] . "\">";
 +
  // loop thru option groups (must be inside of form, as they need to be submitted with form
 +
  foreach($prod['optionGroupArray'] as $optionGroup) echo '<br>' . $optionGroup['groupTitle'] . " : " . $optionGroup['groupField'];
  
// end loop thru menu items
+
  // quantity and submit button
 +
  echo "<br><input type=\"text\" size=5 maxlength=4 name=\"quantity\"> <input type=\"submit\" value=\"Add To Cart\">";
 +
 
 +
// this part is only necessary if using the javascript live price update functions
 +
echo "<br>Price:<div id=\"prodPriceOutput" . $prod['productId'] . "\">$0.00</div>";
 +
 
 +
  // hidden fields fa, productId (required)
 +
  echo "<input type=\"hidden\" name=\"fa\" value=\"ORDER.cartAdd\">";
 +
  echo "<input type=\"hidden\" name=\"productId\" value=\"" . $prod['productId'] . "\">";
 +
 
 +
  // end order form
 +
  echo "</form>";
 +
// end product loop
 
};
 
};
 +
</source>
 +
 +
===Complex example displaying products with options (with complex option field output)===
 +
<source lang="php">
 +
// get the products
 +
$prodArr = eV::pageProductsGet($pageId,"title,childDescription,productNumber,lowPrice,productId");
 +
 +
// loop thru products
 +
foreach($prodArr as $prod) {
 +
 +
    // output base product data
 +
    echo "<hr><b>" . $prod['title'] . "</b> - " . $prod['productNumber'] . " - as low as: " . eV::dollarFormat($prod['lowPrice']) . " each<br>" . $prod['childDescription'];
 +
 +
    // start order form
 +
    echo "<form action=\"index.php\" method=\"post\">";
 +
 +
    // loop thru option groups (must be inside of form, as they need to be submitted with form
 +
    foreach($prod['optionGroupArray'] as $optionGroup) {
 +
        echo '<br>' . $optionGroup['groupTitle'] . " : ";
 +
        // start option group select field, be sure to get the name of this field correct
 +
        echo "<select name=\"group" . $optionGroup['groupId'] . "\">
 +
        // loop thru options and output
 +
 +
        foreach($optionGroup['optionArray'] as $option] {
 +
            // start option field
 +
            echo "<option value=\"" . $option['value'] . "\">" . $option['text'];
 +
            // show price increase in field
 +
            if(!empty($option['price'])) echo " +" . eV::dollarFormat($option['price']);
 +
            // end option field
 +
            echo "</option>";
 +
        // end options loop
 +
        };
 +
 +
        // end option group select field
 +
        echo "</select>";
 +
 +
    // end option group loop
 +
    };
 +
 +
  // quantity and submit button
 +
  echo "<br><input type=\"text\" size=5 maxlength=4 name=\"quantity\"> <input type=\"submit\" value=\"Add To Cart\">";
 +
 +
  // hidden fields fa, productId (required)
 +
  echo "<input type=\"hidden\" name=\"fa\" value=\"ORDER.cartAdd\">";
 +
  echo "<input type=\"hidden\" name=\"productId\" value=\"" . $prod['productId'] . "\">";
 +
 +
  // end order form
 +
  echo "</form>";
 +
// end product loop
 +
};
 +
</source>
 +
 +
===Complex example demonstrating multiple products all submitted with one form with separate quantities===
 +
<source lang="php">
 +
// get the products
 +
$prodArr = eV::pageProductsGet($pageId,"title,childDescription,productNumber,lowPrice,productId");
 +
 +
 +
// form opened outside of loop so all contents of all products in form will be submitted together
 +
// at end of form is a single quantity field that will drive the quantity of all products submitted in the form
 +
// at end of form is the master_productId field which designates which product will be master - others will be slaves
 +
echo "<form action=\"index.php\" method=\"post\" name=\"prodForm\">";
 +
// loop thru products
 +
foreach($prodArr as $prod) {
 +
 +
    // output base product data
 +
    echo "<hr><b>" . $prod['title'] . "</b> - " . $prod['productNumber'] . " - as low as: " . eV::dollarFormat($prod['lowPrice']) . " each<br>" . $prod['childDescription'];
 +
 +
  // start price level table
 +
  echo "<table><tr><td>Quantity</td><td>Price Each</td></tr>";
 +
  // loop thru price levels and output
 +
  foreach($prod['priceLevelArray'] as $priceLevel) echo "<tr><td>" . $priceLevel['quantity'] . "</td><td>" . eV::dollarFormat($priceLevel['price']) . " each</td></tr>";
 +
  // end price level table
 +
  echo "</table>";
 +
 +
  // start order form
 +
  // loop thru option groups (must be inside of form, as they need to be submitted with form
 +
  foreach($prod['optionGroupArray'] as $optionGroup) echo '<br>' . $optionGroup['groupTitle'] . " : " . $optionGroup['groupField'];
 +
 +
  // quantity and submit button
 +
// field name "quantity" must be appended with productId so cart addition process knows what product it applies to
 +
  echo "<br><input type=\"text\" size=5 maxlength=4 name=\"quantity" . $prod['productId'] . "\"> <input type=\"submit\" value=\"Add To Cart\">";
 +
 +
  // hidden fields fa, productId (required)
 +
  echo "<input type=\"hidden\" name=\"fa\" value=\"ORDER.cartAdd\">";
 +
// product Id being submitted multiple times, so must append name with [] for php
 +
  echo "<input type=\"hidden\" name=\"productId[]\" value=\"" . $prod['productId'] . "\">";
 +
 +
 
 +
 
 +
// end product loop
 +
};
 +
// end order form
 +
echo "</form>";
 +
</source>
 +
 +
===Complex example demonstrating multiple products all submitted with one form with one master quantity===
 +
<source lang="php">
 +
// get the products
 +
$prodArr = eV::pageProductsGet($pageId,"title,childDescription,productNumber,lowPrice,productId");
 +
 +
 +
// form opened outside of loop so all contents of all products in form will be submitted together
 +
echo "<form action=\"index.php\" method=\"post\" name=\"prodForm\">";
 +
 +
// loop thru products
 +
foreach($prodArr as $prod) {
 +
 +
    // output base product data
 +
    echo "<hr><b>" . $prod['title'] . "</b> - " . $prod['productNumber'] . " - as low as: " . eV::dollarFormat($prod['lowPrice']) . " each<br>" . $prod['childDescription'];
 +
 +
  // start price level table
 +
  echo "<table><tr><td>Quantity</td><td>Price Each</td></tr>";
 +
  // loop thru price levels and output
 +
  foreach($prod['priceLevelArray'] as $priceLevel) echo "<tr><td>" . $priceLevel['quantity'] . "</td><td>" . eV::dollarFormat($priceLevel['price']) . " each</td></tr>";
 +
  // end price level table
 +
  echo "</table>";
 +
 +
  // start order form
 +
  // loop thru option groups (must be inside of form, as they need to be submitted with form
 +
  foreach($prod['optionGroupArray'] as $optionGroup) echo '<br>' . $optionGroup['groupTitle'] . " : " . $optionGroup['groupField'];
 +
 +
 
 +
  // hidden fields fa, productId (required)
 +
  echo "<input type=\"hidden\" name=\"fa\" value=\"ORDER.cartAdd\">";
 +
// product Id being submitted multiple times, so must append name with [] for php
 +
  echo "<input type=\"hidden\" name=\"productId[]\" value=\"" . $prod['productId'] . "\">";
 +
 +
 
 +
 
 +
// end product loop
 +
};
 +
 +
 +
// quantity  and submit button
 +
// for single quantity reprisenting multiple products, display outside loop and do NOT include productId in field name
 +
echo "<br><input type=\"text\" size=5 maxlength=4 name=\"quantity\">
 +
<input type=\"submit\" value=\"Add All To Cart\">";
 +
 +
// end order form
 +
echo "</form>";
 +
</source>
 +
 +
=== Complex example demonstrating multiple products submitted as master / slaves ===
 +
<source lang="php">
 +
// get the products
 +
$prodArr = eV::pageProductsGet($pageId,"title,childDescription,productNumber,lowPrice,productId");
 +
 +
 +
// form opened outside of loop so all contents of all products in form will be submitted together
 +
echo "<form action=\"index.php\" method=\"post\" name=\"prodForm\">";
 +
 +
// loop thru products
 +
foreach($prodArr as $prod) {
 +
 +
    // output base product data
 +
    echo "<hr><b>" . $prod['title'] . "</b> - " . $prod['productNumber'] . " - as low as: " . eV::dollarFormat($prod['lowPrice']) . " each<br>" . $prod['childDescription'];
 +
 +
  // start price level table
 +
  echo "<table><tr><td>Quantity</td><td>Price Each</td></tr>";
 +
  // loop thru price levels and output
 +
  foreach($prod['priceLevelArray'] as $priceLevel) echo "<tr><td>" . $priceLevel['quantity'] . "</td><td>" . eV::dollarFormat($priceLevel['price']) . " each</td></tr>";
 +
  // end price level table
 +
  echo "</table>";
 +
 +
  // start order form
 +
  // loop thru option groups (must be inside of form, as they need to be submitted with form
 +
  foreach($prod['optionGroupArray'] as $optionGroup) echo '<br>' . $optionGroup['groupTitle'] . " : " . $optionGroup['groupField'];
 +
 +
 
 +
  // hidden fields fa, productId (required)
 +
  echo "<input type=\"hidden\" name=\"fa\" value=\"ORDER.cartAdd\">";
 +
// product Id being submitted multiple times, so must append name with [] for php
 +
  echo "<input type=\"hidden\" name=\"productId[]\" value=\"" . $prod['productId'] . "\">";
 +
 +
 
 +
 
 +
// end product loop
 +
};
 +
  
 +
// quantity  and submit button
 +
// all master / slave product pages must use single quantity representing multiple products
 +
// for single quantity representing multiple products, display outside loop and do NOT include productId in field name
 +
echo "<br><input type=\"text\" size=5 maxlength=4 name=\"quantity\"> ";
 +
// master_productId signifies which product will be the master - all others will be slaves
 +
echo "<input type=\"hidden\" name=\"master_productId\" value=\"" . $prodArr[0]['productId']. "\">
 +
<input type=\"submit\" value=\"Add All To Cart\">";
 +
 +
// end order form
 +
echo "</form>";
 
</source>
 
</source>

Latest revision as of 02:36, 11 March 2010

Page Template Managers

Page Template Functions

Description

retrieves product data for use in displaying products in page template management.

Syntax

$array = eV::pageProductsGet($pageId[,$fieldList]);

Paramaters

  • $pageId INT
specifies the parent page whos products will be retrieved (as selected in relationships for the page). Use the core variable $pageId to call products for the current page.

Return Values

Returns a multidimensional array containing product data. The first dimension is the product index, the second dimension is an associative array of product information for the product index. Return array is as follows:

Array
(
    [0] => Array
        (
            [productId] => INT
            [title] => STR
            [childDescription] => STR
            [imagePath] => STR
            [productNumber] => STR
            [catalogNumber] => STR
            [listPrice] => DECIMAL
            [salePrice] => DECIMAL
            [price] => DECIMAL
            [lowPrice] => DECIMAL
            [lowFlatPrice] => DECIMAL
            [saleFromDate] => DATETIIME
            [saleToDate] => DATETIME
            [isTaxable] => BIT
            [shippingSurcharge] => DECIMAL
            [weight] => DECIMAL
            [imageAlt] => STR
            [saleOn] => BIT
            [minQuantity] => INT
            [maxQuantity] => INT
            [increments] => INT
            [customContent] => STR
            [priceLevelsData] => STR
            [optionGroupsData] => STR
            [prodLayout_isConfigurable] => BIT
            [priceLevelArray] => Array
                (
                    [0] => Array
                         (
                               [quantity] => INT
                               [price] => DECIMAL
                               [price2] => DECIMAL
                               [price3] => DECIMAL
                               [price4] => DECIMAL

                         )
                    [1] ...
                )
            [optionGroupArray] => Array
                (
                    [0] => Array
                         (
                               [groupId] => INT
                               [groupName] => STR
                               [groupTitle] => STR
                               [groupField] => STR
                               [optionList] => STR
                               [optionArray] => Array
                                   (
                                        [0] => Array
                                             (
                                                  [text] => STR
                                                  [price] => DECIMAL
                                                  [sku] => STR
                                                  [priceOption] => INT
                                                  [weight] => DECIMAL
                                                  [value] => STR
                                             )
                                   )

                         )
                    [1] ...
                )
            [custom_field_#] => MIXED
            [custom_field_{name}] => MIXED

        )
    [1] ...          
)

Elements from the product associative array are as follows:

Element Description Example
productId INTEGER - the unique id assigned to the product when created in administration 123
title STRING - as set in administration console for this product, typically used as a short title for the product when displaying it in a page and / or when displaying it in the shopping cart Shirt
childDescription STRING - as set in administration for this product, typically used to further describe the product when it is listed in a page. This is an oversized long sleeve shirt
imagePath STRING - path to the image representing the product as set in administration for this product. Typically used in the shopping cart. /folder/folder/image.jpg
productNumber STRING - stock code as assigned in administration for this product. Synonymous with SKU, this number is usually displayed in the page containing the product, the shopping cart, throughout the checkout process and even in order management after the sale. SLSO1
catalogNumber STRING - an alternative number associated with the product. Typically used in print catalogs, this number is usually used for catalog quick order forms and/or a way for the customer to verify they are ordering the same item online as it appears in the catalog. Usually this is the same as the SKU. SHRTLSO
listPrice DECIMAL - the list price as set in administration for the product. Typically used to show the visitor the discount they are receiving. When the visitor purchases they will receive the best price of the following :listPrice, salePrice (if qualifies), price, qualifying price level(s) 12.34
salePrice DECIMAL - The sale price as set in administration for the product. Typically used for special promotions or sales for the product, it can be controlled via the saleFromDate and saleToDate fields (use saleOn is a quick test to see if the sale price qualifies) 10.45
price DECIMAL - the price as set in administration for the product. This is typically the 'regular price' of the product, what it is typically sold for on the web site. Note, as you are building the page template that contains products you can display this information anyway you wish - as clients typically want their regular price to look like a special price even though it is not. 11.22
lowPrice DECIMAL - the lowest possible price for this product. Takes into consideration list, regular, sale (if qualifies) and price levels. 9.88
lowFlatPrice DECIMAL - the lowest flat price for this product. Takes into consideration list, regular, sale (if qualifies). DOES NOT take into consideration price levels. 10.25
saleFromDate DATETIME - The starting date that the sale price will be available, as set in administration for this product. If this value is empty, than the sale price has no starting date and is considered available until the saleToDate is reached. 2008-08-25 00:00:00
saleToDate DATETIME - the ending date that the sale price will be available until, as set in administration for this product. If this value is empty, than the sale price never ends and is considered available so long as the saleFromDate is passed. 2008-08-30 00:00:00
isTaxable BIT - Flag set in administration to mark if the product qualifies for taxation rules or not. 1
shippingSurcharge DECIMAL - additional surcharge added to shipping for this product. This shipping surcharge is multiplied by the product quantity 11.22
weight DECIMAL - the weight for the product as set in administration. Used to calculate shipping via weighted shipping tables. Stated in Lbs. 5.45
imageAlt STRING - image alt value as set in administration. To be applied to the imagePath image with it is displayed. Picture of a shirt
saleOn BIT - an easy flag that set to 1 if a sale price is set and the saleFromDate, saleToDate are met. Set to 0 if not. 1
customContent STRING - depriciated
priceLevelArray Array - multidimensional array containing price levels and prices/quantities associated with each level. Prices will be calculated automatically when item(s) are added to the shopping cart, so this information is for display purposes only. See below table for breakdown [Array]
optionGroupArray Array - multidimensional array containing option group information. See below table for breakdown [Array]
prodLayout_isConfigurable BIT - 1 if configuration (personalization) settings are in place, 0 if not 1
minQuantity Integer - minimum quantity required to order 5
maxQuantity Integer - maximum quantity allowed to be ordered 100
increments Integer - quantity ordered must be divisible by this number 10
custom_field_# Mixed - value of custom field. # is the id of the field as per the product template. Anything
custom_field_{name} Mixed - value of custom field. {name} is the name of the custom field as specified in the product template. Anything

Elements from the priceLevelArray associative array are as follows:

Element Description Example
quantity INTEGER - quantity floor threshold to qualify for this price. 3
price DECIMAL - price (per item) that the product will qualify for if quantity threshold is met 9.00
price2 DECIMAL - alternate price (per item) that the product will qualify for if quantity threshold is met AND an option is selected that contains the {priceOption:2} flag, as set in administration. 8.00
price3 DECIMAL - alternate price (per item) that the product will qualify for if quantity threshold is met AND an option is selected that contains the {priceOption:3} flag, as set in administration. 7.00
price4 DECIMAL - alternate price (per item) that the product will qualify for if quantity threshold is met AND an option is selected that contains the {priceOption:4} flag, as set in administration. 6.00

Elements from the optionGroupArray associative array are as follows:

Element Description Example
groupId INTEGER - the unique ID assigned to the group when it is created in administration 25
groupName STRING - Group name as set in administration for the group. Used for site admins to uniquely identify the group Size
groupTitle STRING - Group title as set in administration for the group. Typically used as a title for the group when presenting within the page. Size
groupField STRING - complete code for select field containing this groups' options. Simply plop into your page template where you want the drop down to appear. <SELECT name="group52">

<OPTION value="Small{sku:SM}">Small</OPTION> <OPTION value="Medium{sku:ME}">Medium</OPTION> <OPTION value="Large{sku:LG}{price:3.00}">Large + $3.00</OPTION> </SELECT>

optionArray ARRAY - multidimensional array of option values for this group. See the following table for details [ARRAY]

Elements from the optionArray associative array are as follows:

Element Description Example
text STRING - The text output of the option large
price DECIMAL - the price offset of the option. This offset will be automatically added to the product cost, if this option is selected, when it is placed in the shopping cart. 3.00
sku STRING - if this field has value, it will automatically be appended to the products' SKU (productNumber) when it is added to the shopping cart, if this option is selected. _LG
priceOption INTEGER - 1 through 4. If an option with this set is selected, the appropriate price level alt price (see priceLevelArray above) will be applied to the product price. 2
weight DECIMAL - weight offset of the option. This offset is automatically added to the product weight if this option is selected, when the item is added to the shopping cart. 1.15
value STRING - the full data value of the option including the text, price, weight, priceOption, sku. This is what is used to populate the value attribute of the form field (weather option, radio) when building custom product page forms. Large{sku:_LG}{price:3.00}{weight:1.15}{priceOption:2}

Examples

Simple example displaying only a single product and add to cart buttons (no options, not price levels)

Only the first product in the page will be addresses, others will be ignored.

// get the products
$prodArr = eV::pageProductsGet($pageId,"title,childDescription,productNumber,lowPrice,productId");
 
// display first product
if(count($prodArr)){
   // shortcut first product
   $prod = $prodArr[0];
   // output product data
   echo "<hr><b>" . $prod['title'] . "</b> - " . $prod['productNumber'] . " - " . eV::dollarFormat($prod['lowPrice']) . "<br>" . $prod['childDescription'];
 
   // product order form
   echo "<form action=\"index.php\" method=\"post\">";
   echo "<input type=\"text\" size=5 maxlength=4 name=\"quantity\"> <input type=\"submit\" value=\"Add To Cart\">";
   // hidden fields fa,productId required
   echo "<input type=\"hidden\" name=\"fa\" value=\"order.cartAdd\">";
   echo "<input type=\"hidden\" name=\"productId\" value=\"" . $prod['productId'] . "\">";
   echo "</form>";
// end product loop
} else {
// no products set up
};


Simple example displaying products and add to cart buttons (no options, not price levels)

// get the products
$prodArr = eV::pageProductsGet($pageId,"title,childDescription,productNumber,lowPrice,productId");
 
// loop thru products
foreach($prodArr as $prod) {
   // output product data
   echo "<hr><b>" . $prod['title'] . "</b> - " . $prod['productNumber'] . " - " . eV::dollarFormat($prod['lowPrice']) . "<br>" . $prod['childDescription'];
 
   // product order form
   echo "<form action=\"index.php\" method=\"post\">";
   echo "<input type=\"text\" size=5 maxlength=4 name=\"quantity\"> <input type=\"submit\" value=\"Add To Cart\">";
   // hidden fields fa,productId required
   echo "<input type=\"hidden\" name=\"fa\" value=\"order.cartAdd\">";
   echo "<input type=\"hidden\" name=\"productId\" value=\"" . $prod['productId'] . "\">";
   echo "</form>";
// end product loop
};

Complex example displaying products, price levels and options (with simple option field output)

// get the products
$prodArr = eV::pageProductsGet($pageId,"title,childDescription,productNumber,lowPrice,productId");
 
 
 
// loop thru products
 
foreach($prodArr as $prod) {
 
    // output base product data 
    echo "<hr><b>" . $prod['title'] . "</b> - " . $prod['productNumber'] . " - as low as: " . eV::dollarFormat($prod['lowPrice']) . " each<br>" . $prod['childDescription'];
 
   // start price level table
   echo "<table><tr><td>Quantity</td><td>Price Each</td></tr>";
   // loop thru price levels and output
   foreach($prod['priceLevelArray'] as $priceLevel) echo "<tr><td>" . $priceLevel['quantity'] . "</td><td>" . eV::dollarFormat($priceLevel['price']) . " each</td></tr>";
   // end price level table
   echo "</table>";
 
   // start order form
   echo "<form action=\"index.php\" method=\"post\" name=\"prodForm" . $prod['productId'] . "\">";
   // loop thru option groups (must be inside of form, as they need to be submitted with form
   foreach($prod['optionGroupArray'] as $optionGroup) echo '<br>' . $optionGroup['groupTitle'] . " : " . $optionGroup['groupField'];
 
   // quantity and submit button
   echo "<br><input type=\"text\" size=5 maxlength=4 name=\"quantity\"> <input type=\"submit\" value=\"Add To Cart\">";
 
   // hidden fields fa, productId (required)
   echo "<input type=\"hidden\" name=\"fa\" value=\"ORDER.cartAdd\">";
   echo "<input type=\"hidden\" name=\"productId\" value=\"" . $prod['productId'] . "\">";
 
   // end order form
   echo "</form>";
// end product loop
};

Complex example demonstrationg the javascript live price display

// get the products
$prodArr = eV::pageProductsGet($pageId,"title,childDescription,productNumber,lowPrice,productId");
 
/* javascript live price display
Uses a series of javascript functions to set page elements to the price of products. As the product price changes (due to quantity changes, or options selected that effect price), the price in the element will update live.
The javascript will automatically attach events to the quantity and option group fields so as they are changed, the price change is triggered.
*/
/*
Call engine core javascript functions
This only needs to be called once, so if already calling it in an include no need to call it again here
*/
echo "\n<script language=\"javascript\" src=\"/common/fnEtc.js\"></script>";
/*
Call the code that will setup and initialize the live price display. 
Note that three attributes need to be passed to the src script:
1) pageId - set this to the current pageId which will instruct the script as to which products (product children to the page) will need to be addresses
2) formNameRE - the format of the form names. Each product in the page must have it's own form name, the form name must contain the productId AND the form names must all follow the same naming convention. Enter that naming convention here, replacing the productId with the '#' symbol. For example, if the form names are product3Form, product5Form, product8Form, then enter product#Form; if the names are prod5, prod12, prod16, then enter prod#. Since # is reserved for specifying an anchor in the url, be sure to escape (urlencode) the # sign.
3) elementIdRE - the format of the elements that will be populated with the resulting price. All these elements' id's must follow the same naming convention. Enter that naming convention here, replacing the productId with the '#' symbol. For example, if the elements ids are outputPrice4, outputPrice16, outputPrice42 then elementIdRE should be outputPrice#. Since # is reserved for specifying an anchor in the url, be sure to escape (urlencode) the # sign.
*/
echo "\n<script language=\"javascript\" src=\"index.php?fa=PAGE.prodPriceInitJS&pageId=$pageId&formNameRE=prodForm" . urlencode('#') . "&elementIdRE=prodPriceOutput" . urlencode('#') . "\"></script>\n";
 
 
// loop thru products
 
foreach($prodArr as $prod) {
 
    // output base product data 
    echo "<hr><b>" . $prod['title'] . "</b> - " . $prod['productNumber'] . " - as low as: " . eV::dollarFormat($prod['lowPrice']) . " each<br>" . $prod['childDescription'];
 
   // start price level table
   echo "<table><tr><td>Quantity</td><td>Price Each</td></tr>";
   // loop thru price levels and output
   foreach($prod['priceLevelArray'] as $priceLevel) echo "<tr><td>" . $priceLevel['quantity'] . "</td><td>" . eV::dollarFormat($priceLevel['price']) . " each</td></tr>";
   // end price level table
   echo "</table>";
 
   // start order form
   echo "<form action=\"index.php\" method=\"post\" name=\"prodForm" . $prod['productId'] . "\">";
   // loop thru option groups (must be inside of form, as they need to be submitted with form
   foreach($prod['optionGroupArray'] as $optionGroup) echo '<br>' . $optionGroup['groupTitle'] . " : " . $optionGroup['groupField'];
 
   // quantity and submit button
   echo "<br><input type=\"text\" size=5 maxlength=4 name=\"quantity\"> <input type=\"submit\" value=\"Add To Cart\">";
 
// this part is only necessary if using the javascript live price update functions
echo "<br>Price:<div id=\"prodPriceOutput" . $prod['productId'] . "\">$0.00</div>";
 
   // hidden fields fa, productId (required)
   echo "<input type=\"hidden\" name=\"fa\" value=\"ORDER.cartAdd\">";
   echo "<input type=\"hidden\" name=\"productId\" value=\"" . $prod['productId'] . "\">";
 
   // end order form
   echo "</form>";
// end product loop
};

Complex example displaying products with options (with complex option field output)

// get the products
$prodArr = eV::pageProductsGet($pageId,"title,childDescription,productNumber,lowPrice,productId");
 
// loop thru products
foreach($prodArr as $prod) {
 
    // output base product data 
    echo "<hr><b>" . $prod['title'] . "</b> - " . $prod['productNumber'] . " - as low as: " . eV::dollarFormat($prod['lowPrice']) . " each<br>" . $prod['childDescription'];
 
    // start order form
    echo "<form action=\"index.php\" method=\"post\">";
 
    // loop thru option groups (must be inside of form, as they need to be submitted with form
    foreach($prod['optionGroupArray'] as $optionGroup) {
        echo '<br>' . $optionGroup['groupTitle'] . " : ";
        // start option group select field, be sure to get the name of this field correct
        echo "<select name=\"group" . $optionGroup['groupId'] . "\">
        // loop thru options and output
 
        foreach($optionGroup['optionArray'] as $option] {
            // start option field
            echo "<option value=\"" . $option['value'] . "\">" . $option['text'];
            // show price increase in field
            if(!empty($option['price'])) echo " +" . eV::dollarFormat($option['price']);
            // end option field
            echo "</option>";
        // end options loop
        };
 
        // end option group select field
        echo "</select>";
 
    // end option group loop
    };
 
   // quantity and submit button
   echo "<br><input type=\"text\" size=5 maxlength=4 name=\"quantity\"> <input type=\"submit\" value=\"Add To Cart\">";
 
   // hidden fields fa, productId (required)
   echo "<input type=\"hidden\" name=\"fa\" value=\"ORDER.cartAdd\">";
   echo "<input type=\"hidden\" name=\"productId\" value=\"" . $prod['productId'] . "\">";
 
   // end order form
   echo "</form>";
// end product loop
};

Complex example demonstrating multiple products all submitted with one form with separate quantities

// get the products
$prodArr = eV::pageProductsGet($pageId,"title,childDescription,productNumber,lowPrice,productId");
 
 
// form opened outside of loop so all contents of all products in form will be submitted together
// at end of form is a single quantity field that will drive the quantity of all products submitted in the form
// at end of form is the master_productId field which designates which product will be master - others will be slaves
echo "<form action=\"index.php\" method=\"post\" name=\"prodForm\">";
// loop thru products
foreach($prodArr as $prod) {
 
    // output base product data 
    echo "<hr><b>" . $prod['title'] . "</b> - " . $prod['productNumber'] . " - as low as: " . eV::dollarFormat($prod['lowPrice']) . " each<br>" . $prod['childDescription'];
 
   // start price level table
   echo "<table><tr><td>Quantity</td><td>Price Each</td></tr>";
   // loop thru price levels and output
   foreach($prod['priceLevelArray'] as $priceLevel) echo "<tr><td>" . $priceLevel['quantity'] . "</td><td>" . eV::dollarFormat($priceLevel['price']) . " each</td></tr>";
   // end price level table
   echo "</table>";
 
   // start order form
   // loop thru option groups (must be inside of form, as they need to be submitted with form
   foreach($prod['optionGroupArray'] as $optionGroup) echo '<br>' . $optionGroup['groupTitle'] . " : " . $optionGroup['groupField'];
 
   // quantity and submit button
// field name "quantity" must be appended with productId so cart addition process knows what product it applies to
   echo "<br><input type=\"text\" size=5 maxlength=4 name=\"quantity" . $prod['productId'] . "\"> <input type=\"submit\" value=\"Add To Cart\">";
 
   // hidden fields fa, productId (required)
   echo "<input type=\"hidden\" name=\"fa\" value=\"ORDER.cartAdd\">";
// product Id being submitted multiple times, so must append name with [] for php
   echo "<input type=\"hidden\" name=\"productId[]\" value=\"" . $prod['productId'] . "\">";
 
 
 
// end product loop
};
// end order form
echo "</form>";

Complex example demonstrating multiple products all submitted with one form with one master quantity

// get the products
$prodArr = eV::pageProductsGet($pageId,"title,childDescription,productNumber,lowPrice,productId");
 
 
// form opened outside of loop so all contents of all products in form will be submitted together
echo "<form action=\"index.php\" method=\"post\" name=\"prodForm\">";
 
// loop thru products
foreach($prodArr as $prod) {
 
    // output base product data 
    echo "<hr><b>" . $prod['title'] . "</b> - " . $prod['productNumber'] . " - as low as: " . eV::dollarFormat($prod['lowPrice']) . " each<br>" . $prod['childDescription'];
 
   // start price level table
   echo "<table><tr><td>Quantity</td><td>Price Each</td></tr>";
   // loop thru price levels and output
   foreach($prod['priceLevelArray'] as $priceLevel) echo "<tr><td>" . $priceLevel['quantity'] . "</td><td>" . eV::dollarFormat($priceLevel['price']) . " each</td></tr>";
   // end price level table
   echo "</table>";
 
   // start order form
   // loop thru option groups (must be inside of form, as they need to be submitted with form
   foreach($prod['optionGroupArray'] as $optionGroup) echo '<br>' . $optionGroup['groupTitle'] . " : " . $optionGroup['groupField'];
 
 
   // hidden fields fa, productId (required)
   echo "<input type=\"hidden\" name=\"fa\" value=\"ORDER.cartAdd\">";
// product Id being submitted multiple times, so must append name with [] for php
   echo "<input type=\"hidden\" name=\"productId[]\" value=\"" . $prod['productId'] . "\">";
 
 
 
// end product loop
};
 
 
// quantity  and submit button
// for single quantity reprisenting multiple products, display outside loop and do NOT include productId in field name
echo "<br><input type=\"text\" size=5 maxlength=4 name=\"quantity\"> 
<input type=\"submit\" value=\"Add All To Cart\">";
 
// end order form
echo "</form>";

Complex example demonstrating multiple products submitted as master / slaves

// get the products
$prodArr = eV::pageProductsGet($pageId,"title,childDescription,productNumber,lowPrice,productId");
 
 
// form opened outside of loop so all contents of all products in form will be submitted together
echo "<form action=\"index.php\" method=\"post\" name=\"prodForm\">";
 
// loop thru products
foreach($prodArr as $prod) {
 
    // output base product data 
    echo "<hr><b>" . $prod['title'] . "</b> - " . $prod['productNumber'] . " - as low as: " . eV::dollarFormat($prod['lowPrice']) . " each<br>" . $prod['childDescription'];
 
   // start price level table
   echo "<table><tr><td>Quantity</td><td>Price Each</td></tr>";
   // loop thru price levels and output
   foreach($prod['priceLevelArray'] as $priceLevel) echo "<tr><td>" . $priceLevel['quantity'] . "</td><td>" . eV::dollarFormat($priceLevel['price']) . " each</td></tr>";
   // end price level table
   echo "</table>";
 
   // start order form
   // loop thru option groups (must be inside of form, as they need to be submitted with form
   foreach($prod['optionGroupArray'] as $optionGroup) echo '<br>' . $optionGroup['groupTitle'] . " : " . $optionGroup['groupField'];
 
 
   // hidden fields fa, productId (required)
   echo "<input type=\"hidden\" name=\"fa\" value=\"ORDER.cartAdd\">";
// product Id being submitted multiple times, so must append name with [] for php
   echo "<input type=\"hidden\" name=\"productId[]\" value=\"" . $prod['productId'] . "\">";
 
 
 
// end product loop
};
 
 
// quantity  and submit button
// all master / slave product pages must use single quantity representing multiple products
// for single quantity representing multiple products, display outside loop and do NOT include productId in field name
echo "<br><input type=\"text\" size=5 maxlength=4 name=\"quantity\"> ";
// master_productId signifies which product will be the master - all others will be slaves
echo "<input type=\"hidden\" name=\"master_productId\" value=\"" . $prodArr[0]['productId']. "\">
<input type=\"submit\" value=\"Add All To Cart\">";
 
// end order form
echo "</form>";