Index: branches/5.2.x/units/orders/orders_tag_processor.php
===================================================================
diff -u -N -r14258 -r14641
--- branches/5.2.x/units/orders/orders_tag_processor.php (.../orders_tag_processor.php) (revision 14258)
+++ branches/5.2.x/units/orders/orders_tag_processor.php (.../orders_tag_processor.php) (revision 14641)
@@ -1,6 +1,6 @@
-1));
- $o_items = $this->Application->ProcessParsedTag(rtrim('orditems.'.$this->Special, '.'), 'PrintList', $tag_params);
+ $o_items = $this->Application->ProcessParsedTag(rtrim('orditems.' . $this->Special, '.'), 'PrintList', $tag_params);
- if ($o_items) {
- $cart_params = array('name' => $params['header_render_as']);
- $o = $this->Application->ParseBlock($cart_params);
+ if ( $o_items ) {
+ if ( isset($params['header_render_as']) ) {
+ $cart_params = array ('name' => $params['header_render_as']);
+ $o .= $this->Application->ParseBlock($cart_params);
+ }
+
$o .= $o_items;
- $cart_params = array('name' => $params['footer_render_as']);
- $o .= $this->Application->ParseBlock($cart_params);
- } else {
- $cart_params = array('name' => $params['empty_cart_render_as']);
+
+ if ( isset($params['footer_render_as']) ) {
+ $cart_params = array ('name' => $params['footer_render_as']);
+ $o .= $this->Application->ParseBlock($cart_params);
+ }
+ }
+ elseif ( isset($params['empty_cart_render_as']) ) {
+ $cart_params = array ('name' => $params['empty_cart_render_as']);
$o = $this->Application->ParseBlock($cart_params);
}
@@ -203,7 +210,7 @@
return $this->CartNotEmpty($params) ? false : true;
}
- function CartHasBackorders($params)
+ function CartHasBackorders($params = Array ())
{
$object =& $this->getObject($params);
@@ -219,63 +226,82 @@
function PrintShippings($params)
{
$o = '';
+ $limitations_cache = Array ();
+
$object =& $this->getObject($params);
- $ord_id = $object->GetId();
+ /* @var $object kDBItem */
- $shipping_option = $object->GetDBField('ShippingOption');
- $backorder_select = $shipping_option == 0 ? '0 As BackOrderFlag' : 'BackOrderFlag';
+ $ord_id = $object->GetID();
+ $oi_table = $this->Application->getUnitOption('orditems', 'TableName');
- $order_items =& $this->Application->recallObject('orditems', 'orditems_List', Array('skip_autoload' => true) );
- $oi_table = $order_items->TableName;
+ if ( $object->IsTempTable() ) {
+ $oi_table = $this->Application->GetTempName($oi_table, 'prefix' . $object->Prefix);
+ }
- list($split_shipments, $limit_types) = $this->GetShippingLimitations($ord_id);
- foreach ($split_shipments as $group => $data)
- {
- $query = 'UPDATE '.$oi_table.' SET SplitShippingGroup = '.$group.'
- WHERE ProductId IN ('.implode(',', $data['Products']).')';
- $this->Conn->Query($query);
+ list ($split_shipments, $limit_types) = $this->GetShippingLimitations($ord_id);
+
+ foreach ($split_shipments as $group => $data) {
+ $sql = 'UPDATE ' . $oi_table . '
+ SET SplitShippingGroup = ' . $group . '
+ WHERE ProductId IN (' . implode(',', $data['Products']) . ')';
+ $this->Conn->Query($sql);
+
$limitations_cache[$group] = $data['Types'];
}
+
$shipping_group_option = $object->GetDBField('ShippingGroupOption');
- $shipping_group_select = $shipping_group_option == 0 ? '0 AS SplitShippingGroup' : 'SplitShippingGroup';
- if (count($split_shipments) > 1) {
- $this->Application->SetVar('shipping_limitations_apply', 1);
+ $shipping_group_select = $shipping_group_option == ORDER_GROUP_SHIPPMENTS_AUTO ? '0' : 'oi.SplitShippingGroup';
+
+ if ( count($split_shipments) > 1 ) {
// different shipping limitations apply
- if ($limit_types == 'NONE') {
+ $this->Application->SetVar('shipping_limitations_apply', 1);
+
+ if ( $limit_types == 'NONE' ) {
// order can't be shipped with single shipping type
+ $shipping_group_option = ORDER_GROUP_SHIPPMENTS_MANUAL;
+ $shipping_group_select = 'oi.SplitShippingGroup';
$this->Application->SetVar('shipping_limitations_apply', 2);
- $shipping_group_select = 'SplitShippingGroup';
- $shipping_group_option = 1;
}
}
else {
$this->Application->SetVar('shipping_limitations_apply', 0);
}
+
+
+
+ $shipping_option = $object->GetDBField('ShippingOption');
+
$weight_sql = 'IF(oi.Weight IS NULL, 0, oi.Weight * oi.Quantity)';
- $query = 'SELECT
- '.$backorder_select.',
- oi.ProductName,
- oi.ShippingTypeId,
- SUM(oi.Quantity) AS TotalItems,
- SUM('.$weight_sql.') AS TotalWeight,
- SUM(oi.Price * oi.Quantity) AS TotalAmount,'.
- // calculate free Totals => SUM(ALL) - SUM(PROMO) '
- 'SUM(oi.Quantity) - SUM(IF(p.MinQtyFreePromoShipping > 0 AND p.MinQtyFreePromoShipping <= oi.Quantity, oi.Quantity, 0)) AS TotalItemsPromo,
- SUM('.$weight_sql.') - SUM(IF(p.MinQtyFreePromoShipping > 0 AND p.MinQtyFreePromoShipping <= oi.Quantity, '.$weight_sql.', 0)) AS TotalWeightPromo,
- SUM(oi.Price * oi.Quantity) - SUM(IF(p.MinQtyFreePromoShipping > 0 AND p.MinQtyFreePromoShipping <= oi.Quantity, oi.Price * oi.Quantity, 0)) AS TotalAmountPromo,
- '.$shipping_group_select.'
- FROM '.$oi_table.' oi
- LEFT JOIN '.$this->Application->getUnitOption('p', 'TableName').' p
- ON oi.ProductId = p.ProductId
- WHERE oi.OrderId = '.$ord_id.' AND p.Type = 1
- GROUP BY BackOrderFlag, SplitShippingGroup
- ORDER BY BackOrderFlag ASC, SplitShippingGroup ASC';
- $shipments = $this->Conn->Query($query);
+ $sql = 'SELECT
+ ' . ($shipping_option == ORDER_SHIP_ALL_TOGETHER ? '0' : 'oi.BackOrderFlag') . ' AS BackOrderFlagCalc,
+ oi.ProductName,
+ oi.ShippingTypeId,
- $block_params = Array();
+ SUM(oi.Quantity) AS TotalItems,
+ SUM(' . $weight_sql . ') AS TotalWeight,
+ SUM(oi.Price * oi.Quantity) AS TotalAmount,
+
+ SUM(oi.Quantity) - SUM(IF(p.MinQtyFreePromoShipping > 0 AND p.MinQtyFreePromoShipping <= oi.Quantity, oi.Quantity, 0)) AS TotalItemsPromo,
+ SUM(' . $weight_sql . ') - SUM(IF(p.MinQtyFreePromoShipping > 0 AND p.MinQtyFreePromoShipping <= oi.Quantity, ' . $weight_sql . ', 0)) AS TotalWeightPromo,
+ SUM(oi.Price * oi.Quantity) - SUM(IF(p.MinQtyFreePromoShipping > 0 AND p.MinQtyFreePromoShipping <= oi.Quantity, oi.Price * oi.Quantity, 0)) AS TotalAmountPromo,
+
+ ' . $shipping_group_select . ' AS SplitShippingGroupCalc
+ FROM ' . $oi_table . ' oi
+ LEFT JOIN ' . TABLE_PREFIX . 'Products p ON oi.ProductId = p.ProductId
+ WHERE oi.OrderId = ' . $ord_id . ' AND p.Type = ' . PRODUCT_TYPE_TANGIBLE . '
+ GROUP BY BackOrderFlagCalc, SplitShippingGroupCalc
+ ORDER BY BackOrderFlagCalc ASC, SplitShippingGroupCalc ASC';
+ $shipments = $this->Conn->Query($sql);
+
+
+
+
+
+
+ $block_params = Array ();
$block_params['name'] = $this->SelectParam($params, 'render_as,block');
$block_params['user_country_id'] = $object->GetDBField('ShippingCountry');
$block_params['user_state_id'] = $object->GetDBField('ShippingState');
@@ -285,54 +311,51 @@
$block_params['user_addr2'] = $object->GetDBField('ShippingAddress2');
$block_params['user_name'] = $object->GetDBField('ShippingTo');
- if( ($block_params['user_addr1'] == '' || $block_params['user_city'] == '' ||
- $block_params['user_zip'] == '' || $block_params['user_country_id'] == '') &&
- getArrayValue($params, 'invalid_address_render_as'))
- {
- $block_params['name'] = $params['invalid_address_render_as'];
- return $this->Application->ParseBlock($block_params);
- }
-
$group = 1;
foreach ($shipments as $shipment) {
- $where = array('OrderId = '.$ord_id);
- if ($shipping_group_option != 0) {
- $where[] = 'SplitShippingGroup = '.$shipment['SplitShippingGroup'];
+ $where = Array ('OrderId = ' . $ord_id);
+
+ if ( $shipping_group_option == ORDER_GROUP_SHIPPMENTS_MANUAL ) {
+ $where[] = 'SplitShippingGroup = ' . $shipment['SplitShippingGroupCalc'];
}
- if ($shipping_option > 0) { // not all together
- $where[] = 'BackOrderFlag = '.$shipment['BackOrderFlag'];
+
+ if ( $shipping_option != ORDER_SHIP_ALL_TOGETHER ) {
+ $where[] = 'BackOrderFlag = ' . $shipment['BackOrderFlagCalc'];
}
- $query = 'UPDATE '.$oi_table.' SET PackageNum = '.$group.'
- '.($where ? 'WHERE '.implode(' AND ', $where) : '');
- $this->Conn->Query($query);
+ $sql = 'UPDATE ' . $oi_table . '
+ SET PackageNum = ' . $group . '
+ WHERE ' . implode(' AND ', $where);
+ $this->Conn->Query($sql);
+
$group++;
}
- $this->Application->RemoveVar('LastShippings');
+
$group = 1;
+ $this->Application->RemoveVar('LastShippings');
$this->Application->SetVar('ShipmentsExists', 1);
+
foreach ($shipments as $shipment) {
+ $block_params['package_num'] = $group;
+ $block_params['limit_types'] = $shipping_group_option == ORDER_GROUP_SHIPPMENTS_AUTO ? $limit_types : $limitations_cache[ $shipment['SplitShippingGroupCalc'] ];
+ $this->Application->SetVar('ItemShipmentsExists', 1); // also set from Order_PrintShippingTypes tag
- $block_params['package_num'] = $group;
-
- $block_params['limit_types'] = strpos($shipping_group_select, '0 AS') !== false ? $limit_types : $limitations_cache[$shipment['SplitShippingGroup']];
-
- $this->Application->SetVar('ItemShipmentsExists', 1);
-
- switch ($shipment['BackOrderFlag']) {
+ switch ( $shipment['BackOrderFlagCalc'] ) {
case 0:
- if ( $this->CartHasBackOrders(Array()) && $shipping_option == 0 ) {
+ if ( $this->CartHasBackOrders() && $shipping_option == ORDER_SHIP_ALL_TOGETHER ) {
$block_params['shipment'] = $this->Application->Phrase('lu_all_available_backordered');
}
else {
$block_params['shipment'] = $this->Application->Phrase('lu_ship_all_available');;
}
break;
+
case 1:
$block_params['shipment'] = $this->Application->Phrase('lu_ship_all_backordered');;
break;
+
default:
$block_params['shipment'] = $this->Application->Phrase('lu_ship_backordered');
break;
@@ -345,133 +368,127 @@
$block_params['weight_metric'] = $shipment['TotalWeight'];
$block_params['weight'] = $shipment['TotalWeight'];
- $regional =& $this->Application->recallObject('lang.current');
- if ($block_params['weight_metric'] == '')
- {
+ if ( $block_params['weight_metric'] == '' ) {
$block_params['weight'] = $this->Application->Phrase('lu_NotAvailable');
}
- elseif ($regional->GetDBField('UnitSystem') == 1)
- {
- $block_params['weight'] .= ' '.$this->Application->Phrase('lu_kg');
+ else {
+ $block_params['weight'] = $this->_formatWeight( $block_params['weight'] );
}
- elseif ($regional->GetDBField('UnitSystem') == 2)
- {
- list($pounds, $ounces) = kUtil::Kg2Pounds($block_params['weight']);
- $block_params['weight'] = $pounds.' '.$this->Application->Phrase('lu_pounds').' '.
- $ounces.' '.$this->Application->Phrase('lu_ounces');
- }
+
$block_params['items'] = $shipment['TotalItems'];
- $iso = $this->GetISO($params['currency']);
- $amount = $this->ConvertCurrency($shipment['TotalAmount'], $iso);
+ $amount = $this->ConvertCurrency($shipment['TotalAmount'], $this->GetISO( $params['currency'] ));
$amount = sprintf("%.2f", $amount);
-// $block_params['amount'] = $this->AddCurrencySymbol($amount, $iso);
$block_params['amount'] = $shipment['TotalAmount'];
- $block_params['field_name'] = $this->InputName(Array('field' => 'ShippingTypeId')).'['.($group).']';
+ $block_params['field_name'] = $this->InputName( Array('field' => 'ShippingTypeId') ) . '[' . $group . ']';
$parsed_block = $this->Application->ParseBlock($block_params);
- if($this->Application->GetVar('ItemShipmentsExists'))
- {
+ if ( $this->Application->GetVar('ItemShipmentsExists') ) {
$o .= $parsed_block;
}
- else
- {
+ else {
$this->Application->SetVar('ShipmentsExists', 0);
- if(getArrayValue($params, 'no_shipments_render_as'))
- {
+
+ if ( getArrayValue($params, 'no_shipments_render_as') ) {
$block_params['name'] = $params['no_shipments_render_as'];
+
return $this->Application->ParseBlock($block_params);
}
}
+
$group++;
}
- if(getArrayValue($params, 'table_header_render_as'))
- {
- $o = $this->Application->ParseBlock( Array('name' => $params['table_header_render_as']) ).$o;
- }
- if(getArrayValue($params, 'table_footer_render_as'))
- {
- $o .= $this->Application->ParseBlock( Array('name' => $params['table_footer_render_as']) );
- }
-
return $o;
}
- function GetShippingLimitations($ord_id)
+ /**
+ * Checks, that all given address fields are valid
+ *
+ * @param Array $params
+ * @return bool
+ */
+ function AddressValid($params)
{
- /*$query = 'SELECT
- c.CachedShippingLimitation
- FROM '.TABLE_PREFIX.'OrderItems AS oi
- LEFT JOIN '.TABLE_PREFIX.'Products AS p
- ON p.ProductId = oi.ProductId
- LEFT JOIN '.TABLE_PREFIX.'CategoryItems AS ci
- ON ci.ItemResourceId = p.ResourceId
- LEFT JOIN '.TABLE_PREFIX.'Category AS c
- ON c.CategoryId = ci.CategoryId
- WHERE
- oi.OrderId = '.$ord_id.'
- AND
- ci.PrimaryCat = 1
- AND
- c.CachedShippingMode = 1;';
- $cat_limitations = $this->Conn->GetCol($query);*/
- $cat_limitations = array();
+ $object =& $this->getObject($params);
+ /* @var $object kDBItem */
- $query = 'SELECT ShippingLimitation, ShippingMode, oi.ProductId as ProductId
- FROM '.TABLE_PREFIX.'Products AS p
- LEFT JOIN '.TABLE_PREFIX.'OrderItems AS oi ON
- oi.ProductId = p.ProductId
- WHERE oi.OrderId = '.$ord_id.' AND p.Type = 1'; // .' AND p.ShippingMode = 1';
- $limitations = $this->Conn->Query($query, 'ProductId');
+ $address_type = isset($params['type']) ? strtolower($params['type']) : 'shipping';
+ $address_type = ucfirst($address_type);
- $split_shipments = array();
+ $check_fields = Array ('Address1', 'City', 'Zip', 'Country');
+ foreach ($check_fields as $check_field) {
+ if ( $object->GetDBField($address_type . $check_field) == '' ) {
+ return false;
+ }
+ }
+
+ return true;
+ }
+
+ function GetShippingLimitations($ord_id)
+ {
$limit = false;
+ $types_index = $split_shipments = $cat_limitations = Array ();
- $types_index = array();
+ $sql = 'SELECT p.ShippingLimitation, p.ShippingMode, oi.ProductId AS ProductId
+ FROM ' . TABLE_PREFIX . 'Products p
+ LEFT JOIN ' . TABLE_PREFIX . 'OrderItems AS oi ON oi.ProductId = p.ProductId
+ WHERE oi.OrderId = ' . $ord_id . ' AND p.Type = ' . PRODUCT_TYPE_TANGIBLE;
+ $limitations = $this->Conn->Query($sql, 'ProductId');
- // group products by shipping type range and caculate intersection of all types available for ALL products
- // the intersaction caclulation is needed to determine if the order can be shipped with single type or not
+ // group products by shipping type range and calculate intersection of all types available for ALL products
+ // the intersection calculation is needed to determine if the order can be shipped with single type or not
+
if ($limitations) {
- $limit_types = null;
- foreach ($limitations as $product_id => $row)
- {
+ $limit_types = false;
+
+ foreach ($limitations as $product_id => $row) {
// if shipping types are limited - get the types
- $types = $row['ShippingLimitation'] != '' ? explode('|', substr($row['ShippingLimitation'], 1, -1)) : array('ANY');
+ $types = $row['ShippingLimitation'] != '' ? explode('|', substr($row['ShippingLimitation'], 1, -1)) : Array ('ANY');
+
// if shipping is NOT limited to selected types (default - so products with no limitations at all also counts)
- if ($row['ShippingMode'] == 0) {
+ if ($row['ShippingMode'] == PRODUCT_SHIPPING_MODE_ANY_AND_SELECTED) {
array_push($types, 'ANY'); // can be shipped with ANY (literally) type
$types = array_unique($types);
}
+
//adding product id to split_shipments group by types range
$i = array_search(serialize($types), $types_index);
if ($i === false) {
$types_index[] = serialize($types);
- $i = count($types_index)-1;
+ $i = count($types_index) - 1;
}
+
$split_shipments[$i]['Products'][] = $product_id;
$split_shipments[$i]['Types'] = serialize($types);
- if ($limit_types == null) { //it is null only when we process first item with limitations
- $limit_types = $types; //initial scope
+
+ if ($limit_types === false) {
+ // it is false only when we process first item with limitations
+ $limit_types = $types; // initial scope
}
// this is to avoid ANY intersect CUST_1 = (), but allows ANY intersect CUST_1,ANY = (ANY)
- if (in_array('ANY', $limit_types) && !in_array('ANY', $types)) {
+ if ( in_array('ANY', $limit_types) && !in_array('ANY', $types) ) {
array_splice($limit_types, array_search('ANY', $limit_types), 1, $types);
}
+
// this is to avoid CUST_1 intersect ANY = (), but allows CUST_1 intersect CUST_1,ANY = (ANY)
- if (!in_array('ANY', $limit_types) && in_array('ANY', $types)) {
+ if ( !in_array('ANY', $limit_types) && in_array('ANY', $types) ) {
array_splice($types, array_search('ANY', $types), 1, $limit_types);
}
+
$limit_types = array_intersect($limit_types, $types);
}
+
$limit_types = count($limit_types) > 0 ? serialize(array_unique($limit_types)) : 'NONE';
}
- return array($split_shipments, $limit_types);
+
+ return Array ($split_shipments, $limit_types);
}
function PaymentTypeForm($params)
@@ -915,33 +932,132 @@
function CartHasError($params)
{
- return $this->Application->GetVar('checkout_error') > 0;
+ return $this->Application->RecallVar('checkout_errors');
}
function CheckoutError($params)
{
- $error_codes = Array (
- 1 => 'state_changed',
- 2 => 'qty_unavailable',
- 3 => 'outofstock',
- 4 => 'invalid_code',
- 5 => 'code_expired',
- 6 => 'min_qty',
- 7 => 'code_removed',
- 8 => 'code_removed_automatically',
- 9 => 'changed_after_login',
- 10 => 'coupon_applied',
- 104 => 'invalid_gc_code',
- 105 => 'gc_code_expired',
- 107 => 'gc_code_removed',
- 108 => 'gc_code_removed_automatically',
- 110 => 'gift_certificate_applied',
- );
+ $errors = $this->Application->RecallVar('checkout_errors');
- $error_param = $error_codes[ $this->Application->GetVar('checkout_error') ];
- return $this->Application->Phrase($params[$error_param]);
+ if ( !$errors ) {
+ return '';
+ }
+
+// $this->Application->RemoveVar('checkout_errors');
+ $errors = unserialize($errors);
+
+ if ( isset($errors[OrderCheckoutErrorType::COUPON]) ) {
+ $mapping = Array (
+ OrderCheckoutError::COUPON_APPLIED => 'coupon_applied',
+ OrderCheckoutError::COUPON_REMOVED => 'code_removed',
+ OrderCheckoutError::COUPON_REMOVED_AUTOMATICALLY => 'code_removed_automatically',
+ OrderCheckoutError::COUPON_CODE_INVALID => 'invalid_code',
+ OrderCheckoutError::COUPON_CODE_EXPIRED => 'code_expired',
+ );
+
+ $error_phrase = $mapping[ $errors[OrderCheckoutErrorType::COUPON] ];
+ }
+ elseif ( isset($errors[OrderCheckoutErrorType::GIFT_CERTIFICATE]) ) {
+ $mapping = Array (
+ OrderCheckoutError::GC_APPLIED => 'gift_certificate_applied',
+ OrderCheckoutError::GC_REMOVED => 'gc_code_removed',
+ OrderCheckoutError::GC_REMOVED_AUTOMATICALLY => 'gc_code_removed_automatically',
+ OrderCheckoutError::GC_CODE_INVALID => 'invalid_gc_code',
+ OrderCheckoutError::GC_CODE_EXPIRED => 'gc_code_expired',
+
+ );
+
+ $error_phrase = $mapping[ $errors[OrderCheckoutErrorType::GIFT_CERTIFICATE] ];
+ }
+ else {
+ $mapping = Array (
+ OrderCheckoutError::QTY_UNAVAILABLE => 'qty_unavailable',
+ OrderCheckoutError::QTY_OUT_OF_STOCK => 'outofstock',
+ OrderCheckoutError::QTY_CHANGED_TO_MINIMAL => 'min_qty',
+ );
+
+ foreach ($errors as $error_type => $error_code) {
+ if ( isset($mapping[$error_code]) ) {
+ $error_phrase = $mapping[$error_code];
+ break;
+ }
+ }
+
+ if ( !isset($error_phrase) ) {
+ $error_phrase = 'state_changed'; // 'changed_after_login'
+ }
+ }
+
+ return $this->Application->Phrase( $params[$error_phrase] );
}
+ /**
+ * Returns checkout errors in JSON format
+ *
+ * @param Array $params
+ * @return string
+ */
+ function PrintOrderInfo($params)
+ {
+ $order_helper =& $this->Application->recallObject('OrderHelper');
+ /* @var $order_helper OrderHelper */
+
+ $object =& $this->getObject($params);
+ /* @var $object kDBItem */
+
+ $currency = isset($params['currency']) ? $params['currency'] : 'selected';
+
+ return json_encode( $order_helper->getOrderInfo($object, $currency) );
+ }
+
+ /**
+ * Returns currency mark (%s is $amount placemark)
+ *
+ * @param Array $params
+ * @return string
+ */
+ function CurrencyMask($params)
+ {
+ $iso = $this->GetISO( $params['currency'] );
+
+ return $this->AddCurrencySymbol('%s', $iso);
+ }
+
+ function CheckoutErrorNew($params)
+ {
+ $errors = $this->Application->RecallVar('checkout_errors');
+
+ if ( !$errors ) {
+ return '';
+ }
+
+// $this->Application->RemoveVar('checkout_errors');
+ $errors = unserialize($errors);
+
+ $reflection = new ReflectionClass('OrderCheckoutErrorType');
+ $error_types = $reflection->getConstants();
+
+ $reflection = new ReflectionClass('OrderCheckoutError');
+ $error_codes = $reflection->getConstants();
+
+ $ret = Array ();
+
+ foreach ($errors as $error_type => $error_code) {
+ $error_type = explode(':', $error_type);
+
+ $error_explained = '' . array_search($error_type[0], $error_types) . '';
+
+ if ( $error_type[0] == OrderCheckoutErrorType::PRODUCT ) {
+ $error_explained .= ' (ProductId = ' . $error_type[1] . '; OptionsSalt: ' . $error_type[2] . '; BackOrderFlag: ' . $error_type[3] . '; Field: ' . $error_type[4] . ')';
+ }
+
+ $error_explained .= ' - ' . array_search($error_code, $error_codes) . '';
+ $ret[] = $error_explained;
+ }
+
+ return implode('
', $ret);
+ }
+
function GetFormAction($params)
{
$object =& $this->getObject($params);
@@ -1311,14 +1427,6 @@
return $max <= 0 ? true : $address_list->GetRecordsCount() < $max;
}
- function FreePromoShippingAvailable($params)
- {
- $object =& $this->Application->recallObject('orditems');
- $free_ship = $object->GetDBField('MinQtyFreePromoShipping');
- $tangible = ($object->GetDBField('Type') == 1)? 1 : 0;
- return ($tangible && ($free_ship > 0 && $free_ship <= $object->GetDBField('Quantity')))? 1 : 0;
- }
-
/**
* Creates link for removing coupon or gift certificate
*
@@ -1358,22 +1466,29 @@
return $this->Application->Phrase('lu_NotAvailable');
}
+ return $this->_formatWeight($total_weight);
+ }
+
+ function _formatWeight($weight)
+ {
$regional =& $this->Application->recallObject('lang.current');
+ /* @var $regional kDBItem */
- switch ($regional->GetDBField('UnitSystem')) {
+ switch ( $regional->GetDBField('UnitSystem') ) {
case 1:
// metric system -> add kg sign
- $total_weight .= ' '.$this->Application->Phrase('lu_kg');
+ $weight .= ' ' . $this->Application->Phrase('lu_kg');
break;
case 2:
// uk system -> convert to pounds
- list($pounds, $ounces) = kUtil::Kg2Pounds($total_weight);
- $total_weight = $pounds.' '.$this->Application->Phrase('lu_pounds').' '.$ounces.' '.$this->Application->Phrase('lu_ounces');
+ list ($pounds, $ounces) = kUtil::Kg2Pounds($weight);
+
+ $weight = $pounds . ' ' . $this->Application->Phrase('lu_pounds') . ' ' . $ounces . ' ' . $this->Application->Phrase('lu_ounces');
break;
}
- return $total_weight;
+ return $weight;
}
function InitCatalogTab($params)
@@ -1494,5 +1609,4 @@
return $o;
}
-
}
\ No newline at end of file