Difference between revisions of "Functions:pageProductsGet"

From Whirlwind eCommerce Wiki
Jump to: navigation, search
Line 27: Line 27:
 
             [salePrice] => DECIMAL
 
             [salePrice] => DECIMAL
 
             [price] => DECIMAL
 
             [price] => DECIMAL
 +
            [lowPrice] => DECIMAL
 
             [saleFromDate] => DATETIIME
 
             [saleFromDate] => DATETIIME
 
             [saleToDate] => DATETIME
 
             [saleToDate] => DATETIME
Line 67: Line 68:
 
                                                   [priceOption] => INT
 
                                                   [priceOption] => INT
 
                                                   [weight] => DECIMAL
 
                                                   [weight] => DECIMAL
 +
                                                  [value] => STR
 
                                             )
 
                                             )
 
                                   )
 
                                   )
Line 121: Line 123:
 
|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.
 
|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
 
|11.22
 +
|-
 +
|lowPrice
 +
|DECIMAL - the lowest possible price for this product. Takes into consideration list, regular, sale (if qualifies) and price levels.
 +
|9.88
 
|-
 
|-
 
|saleFromDate
 
|saleFromDate
Line 203: Line 209:
 
|25
 
|25
 
|-
 
|-
                              [groupName] => STR
+
|groupName
                              [groupField] => STR
+
|STRING - Group name as set in administration for the group. Typically used as a title for the group when presenting within the page.
                              [optionList] => STR
+
|Size
                              [optionArray] => Array
+
|-
                                  (
+
|groupField
                                        [0] => Array
+
|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":gt;
                                                  [text] => STR
+
<OPTION value="Small{sku:SM}">Small</OPTION>
                                                  [price] => DECIMAL
+
<OPTION value="Medium{sku:ME}">Medium</OPTION>
                                                  [sku] => STR
+
<OPTION value="Large{sku:LG}{price:3.00}">Large + $3.00</OPTION>
                                                  [priceOption] => INT
+
$lt;/SELECT>
                                                  [weight] => DECIMAL
+
|-
 +
|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
 +
|optionArray
 +
|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 products and add to cart buttons (no options, not price levels)
 
<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
+
foreach($prodArr as $prod) {
$arrTopMenu = $arrMenus['t'];
+
echo "<hr><b>" . $prod['title'] . "</b> - " . $prod['productNumber'] . " - " . $eV::dollarFormat($prod['lowPrice']) . "<br>" . $prod['childDescription'];
$arrBottomMenu = $arrMenus['b'];
+
echo "<form action=\"index.php\" method=\"post\">";
 
+
echo "<input type=\"text\" size=5 maxlength=4 name=\"quantity\"> <input type=\"submit\" value=\"Add To Cart\">";
// output top menu as a list
+
echo "<input type=\"hidden\" name=\"fa\" value=\"order.cartAdd\">";
echo "<ul>";
+
echo "<input type=\"hidden\" name=\"productId\" value=\"" . $prod['productId'] . "\">";
foreach($arrTopMenu as $menuItem) echo "<li><a href=\"" . $menuItem['link'] . "\" target=\"" . $menuItem['target'] . "\">" . $menuItem['text'] . "</a></li>";
+
echo "</form>";
echo "</ul>";
+
};
 
+
// output bottom menu as &middot; separated links
+
$tempArr = Array();
+
foreach($arrBottomMenu as $menuItem) $tempArr[] = "<a href=\"" . $menuItem['link'] . "\" target=\"" . $menuItem['target'] . "\">" . $menuItem['text'] . "</a>";
+
echo implode(" &middot; ", $tempArr);
+
  
 
</source>
 
</source>
  
;Intermediate menu with varying classes for first element, last element and element linking to current page
+
;Complex example using options, price levels
 
<source lang="php">
 
<source lang="php">
// get the menus
+
// get the products
$arrMenus = eV::pageMenuGet();
+
$prodArr = eV::pageProductsGet($pageId,"title,childDescription,productNumber,lowPrice,productId,listPrice,salePrice,price,saleOn');
 
+
// shortcut the top menu
+
$arrTopMenu = $arrMenus['t'];
+
 
+
// loop thru menu items
+
for($i=0;$i>count($arrTopMenu);$i++){
+
 
+
  $menuItem = $arrTopMenu[$i];
+
 
+
  // set default class
+
  // 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\">";
+
  // only display link if not empty
+
  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
+
};
+
</source>
+
 
+
;Advanced example using tiered menus that only display sub menus items if visitor is currently navigated to a menu item
+
<source lang="php">
+
// get the menus
+
$arrMenus = eV::pageMenuGet();
+
 
+
// shortcut the left menu
+
$arrLeftMenu = $arrMenus['l'];
+
 
+
// loop thru menu items
+
for($i=0;$i>count($arrLeftMenu);$i++){
+
 
+
  $menuItem = $arrLeftMenu[$i];
+
 
+
  // only output this menu item if it is displayed OR is in top two levels
+
  // 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'];
+
      if($menuItem['focus']) $class .= "Selected";
+
 
+
      echo "<li class=\"$class\">";
+
      // only display link if not empty
+
      if(!empty($menuItem['link'])) echo "<a href=\"" . $menuItem['link'] . "\" target=\"" . $menuItem['target'] . "\">";
+
      echo $menuItem['text'];
+
      if(!empty($menuItem['link'])) echo "</a>";
+
      echo "<li>";
+
 
+
  // end if this is to be displayed
+
  };
+
  
// end loop thru menu items
+
foreach($prodArr as $prod) {
 +
echo "<hr><b>" . $prod['title'] . "</b> - " . $prod['productNumber'] . " - " . $eV::dollarFormat($prod['lowPrice']) . "<br>" . $prod['childDescription'];
 +
echo "<form action=\"index.php\" method=\"post\">";
 +
echo "<input type=\"text\" size=5 maxlength=4 name=\"quantity\"> <input type=\"submit\" value=\"Add To Cart\">";
 +
echo "<input type=\"hidden\" name=\"fa\" value=\"order.cartAdd\">";
 +
echo "<input type=\"hidden\" name=\"productId\" value=\"" . $prod['productId'] . "\">";
 +
echo "</form>";
 
};
 
};
  
 
</source>
 
</source>

Revision as of 01:12, 7 October 2008

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
            [saleFromDate] => DATETIIME
            [saleToDate] => DATETIME
            [isTaxable] => BIT
            [shippingSurcharge] => DECIMAL
            [weight] => DECIMAL
            [imageAlt] => STR
            [saleOn] => BIT
            [customContent] => STR
            [priceLevelsData] => STR
            [optionGroupsData] => STR
            [priceLevelArray] => Array
                (
                    [0] => Array
                         (
                               [quantity] => INT
                               [price] => DECIMAL
                               [price2] => DECIMAL
                               [price3] => DECIMAL
                               [price4] => DECIMAL

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

                         )
                    [1] ...
                )

        )
    [1] ...          
)

Elements from the product associative array are as follows:

listPrice
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
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
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]

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. 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":gt;

<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> $lt;/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:

optionArray 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 products and add to cart buttons (no options, not price levels)
// get the products
$prodArr = eV::pageProductsGet($pageId,"title,childDescription,productNumber,lowPrice,productId');
 
foreach($prodArr as $prod) {
echo "<hr><b>" . $prod['title'] . "</b> - " . $prod['productNumber'] . " - " . $eV::dollarFormat($prod['lowPrice']) . "<br>" . $prod['childDescription'];
echo "<form action=\"index.php\" method=\"post\">";
echo "<input type=\"text\" size=5 maxlength=4 name=\"quantity\"> <input type=\"submit\" value=\"Add To Cart\">";
echo "<input type=\"hidden\" name=\"fa\" value=\"order.cartAdd\">";
echo "<input type=\"hidden\" name=\"productId\" value=\"" . $prod['productId'] . "\">";
echo "</form>";
};
Complex example using options, price levels
// get the products
$prodArr = eV::pageProductsGet($pageId,"title,childDescription,productNumber,lowPrice,productId,listPrice,salePrice,price,saleOn');
 
foreach($prodArr as $prod) {
echo "<hr><b>" . $prod['title'] . "</b> - " . $prod['productNumber'] . " - " . $eV::dollarFormat($prod['lowPrice']) . "<br>" . $prod['childDescription'];
echo "<form action=\"index.php\" method=\"post\">";
echo "<input type=\"text\" size=5 maxlength=4 name=\"quantity\"> <input type=\"submit\" value=\"Add To Cart\">";
echo "<input type=\"hidden\" name=\"fa\" value=\"order.cartAdd\">";
echo "<input type=\"hidden\" name=\"productId\" value=\"" . $prod['productId'] . "\">";
echo "</form>";
};