Index: branches/5.2.x/units/order_items/order_items_tag_processor.php
===================================================================
diff -u -N -r14569 -r14641
--- branches/5.2.x/units/order_items/order_items_tag_processor.php (.../order_items_tag_processor.php) (revision 14569)
+++ branches/5.2.x/units/order_items/order_items_tag_processor.php (.../order_items_tag_processor.php) (revision 14641)
@@ -1,6 +1,6 @@
Application->recallObject('ord');
- if ($order->GetDBField('Status') != ORDER_STATUS_INCOMPLETE) {
+ /* @var $order kDBList */
+
+ if ( $order->GetDBField('Status') != ORDER_STATUS_INCOMPLETE ) {
$params['grid'] = $params['NotEditable'];
}
else {
@@ -29,24 +30,27 @@
return $this->Application->ProcessParsedTag('m', 'ParseBlock', $params);
}
- function IsTangible($params){
- $object =& $this->Application->recallObject( $this->getPrefixSpecial() );
- if ($object->GetDBField('Type') == 1)
- return true;
- else
- return false;
+ function IsTangible($params)
+ {
+ $object =& $this->getObject($params);
+ /* @var $object kDBItem */
+
+ return $object->GetDBField('Type') == PRODUCT_TYPE_TANGIBLE;
}
function HasQty($params)
{
- $object =& $this->Application->recallObject( $this->getPrefixSpecial() );
- $type = $object->GetDBField('Type');
- return in_array($type, array(1,6));
+ $object =& $this->getObject($params);
+ /* @var $object kDBItem */
+
+ return in_array($object->GetDBField('Type'), Array (PRODUCT_TYPE_TANGIBLE, 6));
}
function HasDiscount($params)
{
- $object =& $this->Application->recallObject( $this->getPrefixSpecial() );
+ $object =& $this->getObject($params);
+ /* @var $object kDBItem */
+
return (float)$object->GetDBField('ItemDiscount') ? 1 : 0;
}
@@ -60,31 +64,34 @@
function PrintOptions($params)
{
$object =& $this->getObject($params);
+ /* @var $object kDBItem */
+
$item_data = @unserialize($object->GetDBField('ItemData'));
$render_as = $this->SelectParam($params, 'render_as');
$block_params['name'] = $render_as;
$opt_helper =& $this->Application->recallObject('kProductOptionsHelper');
+ /* @var $opt_helper kProductOptionsHelper */
$o = '';
$options = $item_data['Options'];
foreach ($options as $opt => $val) {
- if (!is_array($val)) {
+ if ( !is_array($val) ) {
$val = kUtil::unhtmlentities($val);
}
$key_data = $opt_helper->ConvertKey($opt, $object->GetDBField('ProductId'));
$parsed = $opt_helper->ExplodeOptionValues($key_data);
- if ($parsed) {
+ if ( $parsed ) {
$values = $parsed['Values'];
$prices = $parsed['Prices'];
$price_types = $parsed['PriceTypes'];
}
else {
- $values = array();
- $prices = array();
- $price_types = array();
+ $values = array ();
+ $prices = array ();
+ $price_types = array ();
}
$key = $key_data['Name'];
@@ -93,10 +100,11 @@
}*/
$lang =& $this->Application->recallObject('lang.current');
+ /* @var $lang LanguagesItem */
- if ($render_as) {
+ if ( $render_as ) {
$block_params['option'] = $key;
- if (is_array($val)) {
+ if ( is_array($val) ) {
$block_params['value'] = $val;
$block_params['type'] = $key_data['OptionType'];
$block_params['price'] = $prices;
@@ -106,9 +114,9 @@
$price_type = array_key_exists($val, $price_types) ? $price_types[$val] : '';
$price = array_key_exists($val, $prices) ? $prices[$val] : '';
- if ($price_type == '$') {
+ if ( $price_type == '$' ) {
$iso = $this->GetISO($params['currency']);
- $value = $this->AddCurrencySymbol($lang->formatNumber($this->ConvertCurrency($price_type, $iso),2), $iso, true); // true to force sign
+ $value = $this->AddCurrencySymbol($lang->formatNumber($this->ConvertCurrency($price_type, $iso), 2), $iso, true); // true to force sign
$block_params['price'] = $value;
$block_params['price_type'] = '';
$block_params['sign'] = ''; // sign is included in the formatted value
@@ -121,10 +129,10 @@
$block_params['value'] = htmlspecialchars($val);
$block_params['type'] = $key_data['OptionType'];
}
- $o.= $this->Application->ParseBlock($block_params, 1);
+ $o .= $this->Application->ParseBlock($block_params, 1);
}
else {
- $o .= $key.': '.$val.'
';
+ $o .= $key . ': ' . $val . '
';
}
}
return $o;
@@ -158,6 +166,8 @@
$block_params['name'] = $params['render_as'];
$values = $this->Application->Parser->GetParam('value');
+ /* @var $values Array */
+
$prices = $this->Application->Parser->GetParam('price');
$price_types = $this->Application->Parser->GetParam('price_type');
@@ -224,7 +234,7 @@
$this->Application->SetVar('m_cat_id', $product_object->GetDBField('CategoryId'));
- $block_params['is_last'] = ($i == $list->SelectedCount - 1);
+ $block_params['is_last'] = ($i == $list->GetSelectedCount() - 1);
$o.= $this->Application->ParseBlock($block_params, 1);
$list->GoNext();
@@ -242,17 +252,46 @@
function DisplayOptionsPricing($params)
{
$object =& $this->getObject($params);
- if ($object->GetDBField('OptionsSelectionMode') == 1) {
+ /* @var $object kDBItem */
+
+ if ( $object->GetDBField('OptionsSelectionMode') == 1 ) {
return false;
}
$item_data = unserialize($object->GetDBField('ItemData'));
- if (!is_array($item_data)) return false;
+ if ( !is_array($item_data) ) {
+ return false;
+ }
+
$options = getArrayValue($item_data, 'Options');
$helper =& $this->Application->recallObject('kProductOptionsHelper');
+ /* @var $helper kProductOptionsHelper */
+
$crc = $helper->OptionsSalt($options, true);
- $combs = $this->Conn->GetOne('SELECT COUNT(*) FROM '.TABLE_PREFIX.'ProductOptionCombinations WHERE CombinationCRC = '.$crc.' AND ProductId = '.$object->GetDBField('ProductId').' AND (Price != 0 OR (PriceType = 1 AND Price = 0))');
- return $combs == 0; // no overriding combinations found
+ $sql = 'SELECT COUNT(*)
+ FROM ' . TABLE_PREFIX . 'ProductOptionCombinations
+ WHERE CombinationCRC = ' . $crc . ' AND ProductId = ' . $object->GetDBField('ProductId') . ' AND (Price != 0 OR (PriceType = 1 AND Price = 0))';
+
+ return $this->Conn->GetOne($sql) == 0; // no overriding combinations found
}
+
+ function RowIndex($params)
+ {
+ $object =& $this->getObject($params);
+ /* @var $object kDBItem */
+
+ return $object->GetDBField('ProductId') . ':' . $object->GetDBField('OptionsSalt') . ':' . $object->GetDBField('BackOrderFlag');
+ }
+
+ function FreePromoShippingAvailable($params)
+ {
+ $object =& $this->getObject($params);
+ /* @var $object kDBItem */
+
+ $order_helper =& $this->Application->recallObject('OrderHelper');
+ /* @var $order_helper OrderHelper */
+
+ return $order_helper->eligibleForFreePromoShipping($object);
+ }
}
\ No newline at end of file