Index: branches/5.2.x/units/orders/orders_config.php
===================================================================
diff -u -r14815 -r14821
--- branches/5.2.x/units/orders/orders_config.php (.../orders_config.php) (revision 14815)
+++ branches/5.2.x/units/orders/orders_config.php (.../orders_config.php) (revision 14821)
@@ -1,6 +1,6 @@
'af.PortalUserId',
'GiftCertificateCode' => 'gc.Code',
'GiftCertificateRecipient' => 'gc.Recipient',
+ 'ShippingSubTotal' => '%1$s.ShippingCost + %1$s.InsuranceFee',
),
'myorders' => Array (
@@ -262,6 +263,7 @@
'AmountWithoutVAT' => '(SubTotal+IF(ShippingTaxable=1, ShippingCost, 0)+IF(ProcessingTaxable=1, ProcessingFee, 0))',
'TotalAmount' => 'SubTotal+ShippingCost+VAT+ProcessingFee+InsuranceFee-GiftCertificateDiscount',
/*'ItemsCount' => 'COUNT(%1$s.OrderId)',*/
+ 'ShippingSubTotal' => '%1$s.ShippingCost + %1$s.InsuranceFee',
),
),
// %1$s - table name of object
@@ -466,6 +468,7 @@
'AmountWithoutVAT' => Array ('type' => 'float', 'formatter' => 'kFormatter', 'format' => '%01.2f', 'default' => '0.00'),
'SubtotalWithDiscount' => Array ('type' => 'float', 'formatter' => 'kFormatter', 'format' => '%01.2f', 'default' => '0.00'),
'SubtotalWithoutDiscount' => Array ('type' => 'float', 'formatter' => 'kFormatter', 'format' => '%01.2f', 'default' => '0.00'),
+ 'ShippingSubTotal' => Array ('type' => 'float', 'formatter' => 'kFormatter', 'format' => '%01.2f', 'default' => '0.00'),
'OrderNumber' => Array ('type' => 'string', 'default' => '', 'filter_type' => 'like'),
'CouponCode' => Array ('type' => 'string', 'default' => ''),
'CouponName' => Array ('type' => 'string', 'default' => ''),
Index: branches/5.2.x/units/payment_type/payment_type_config.php
===================================================================
diff -u -r14582 -r14821
--- branches/5.2.x/units/payment_type/payment_type_config.php (.../payment_type_config.php) (revision 14582)
+++ branches/5.2.x/units/payment_type/payment_type_config.php (.../payment_type_config.php) (revision 14821)
@@ -1,6 +1,6 @@
Array ( '' => ' SELECT %1$s.* %2$s
- FROM %1$s
- LEFT JOIN '.TABLE_PREFIX.'Gateways ON %1$s.GatewayId = '.TABLE_PREFIX.'Gateways.GatewayId',
- ), // key - special, value - list select sql
- 'ItemSQLs' => Array ( '' => 'SELECT * FROM %s',
- ),
+ 'ListSQLs' => Array (
+ '' => ' SELECT %1$s.* %2$s
+ FROM %1$s
+ LEFT JOIN ' . TABLE_PREFIX . 'Gateways ON %1$s.GatewayId = ' . TABLE_PREFIX . 'Gateways.GatewayId',
+ ),
+
'ListSortings' => Array (
'' => Array (
'ForcedSorting' => Array ('Priority' => 'desc'),
Index: branches/5.2.x/units/orders/orders_event_handler.php
===================================================================
diff -u -r14816 -r14821
--- branches/5.2.x/units/orders/orders_event_handler.php (.../orders_event_handler.php) (revision 14816)
+++ branches/5.2.x/units/orders/orders_event_handler.php (.../orders_event_handler.php) (revision 14821)
@@ -1,6 +1,6 @@
Array('self' => true),
'OnProceedToPreview' => Array('self' => true),
'OnCompleteOrder' => Array('self' => true),
- 'OnCombinedPlaceOrder' => Array('self' => true),
+ 'OnUpdateAjax' => Array('self' => true),
'OnRemoveCoupon' => Array('self' => true),
'OnRemoveGiftCertificate' => Array('self' => true),
@@ -3783,18 +3783,15 @@
}
/**
- * Enter description here...
+ * Performs order update and returns results in format, needed by FormManager
*
* @param kEvent $event
*/
- function OnCombinedPlaceOrder(&$event)
+ function OnUpdateAjax(&$event)
{
$ajax_form_helper =& $this->Application->recallObject('AjaxFormHelper');
/* @var $ajax_form_helper AjaxFormHelper */
$ajax_form_helper->transitEvent($event, 'OnUpdate');
-
-
-// $event->CallSubEvent('OnUpdate');
}
}
\ No newline at end of file
Index: branches/5.2.x/units/payment_type/payment_type_event_handler.php
===================================================================
diff -u -r14677 -r14821
--- branches/5.2.x/units/payment_type/payment_type_event_handler.php (.../payment_type_event_handler.php) (revision 14677)
+++ branches/5.2.x/units/payment_type/payment_type_event_handler.php (.../payment_type_event_handler.php) (revision 14821)
@@ -1,6 +1,6 @@
GetDBField('PaymentType');
}
+ elseif ( substr($event->Special, 0, 3) == 'gw-' ) {
+ // returns first matched enabled payment type
+ return Array (
+ 'Status' => STATUS_ACTIVE,
+ TABLE_PREFIX . 'Gateways.Name' => $event->getEventParam('gateway'),
+ );
+ }
return parent::getPassedID($event);
}
Index: branches/5.2.x/units/orders/orders_tag_processor.php
===================================================================
diff -u -r14816 -r14821
--- branches/5.2.x/units/orders/orders_tag_processor.php (.../orders_tag_processor.php) (revision 14816)
+++ branches/5.2.x/units/orders/orders_tag_processor.php (.../orders_tag_processor.php) (revision 14821)
@@ -1,6 +1,6 @@
$row) {
// if shipping types are limited - get the types
$types = $row['ShippingLimitation'] != '' ? explode('|', substr($row['ShippingLimitation'], 1, -1)) : Array ('ANY');
@@ -1084,9 +1082,9 @@
$object =& $this->getObject($params);
/* @var $object OrdersItem */
- $gw_data = $object->getGatewayData($params['payment_type_id']);
-
+ $gw_data = $object->getGatewayData( isset($params['payment_type_id']) ? $params['payment_type_id'] : null );
$this->Application->registerClass( $gw_data['ClassName'], GW_CLASS_PATH.'/'.$gw_data['ClassFile'] );
+
$gateway_object =& $this->Application->recallObject( $gw_data['ClassName'] );
/* @var $gateway_object kGWBase */
@@ -1098,22 +1096,25 @@
$object =& $this->getObject($params);
/* @var $object OrdersItem */
- $gw_data = $object->getGatewayData(array_key_exists('payment_type_id', $params) ? $params['payment_type_id'] : null);
-
+ $gw_data = $object->getGatewayData( isset($params['payment_type_id']) ? $params['payment_type_id'] : null );
$this->Application->registerClass( $gw_data['ClassName'], GW_CLASS_PATH.'/'.$gw_data['ClassFile'] );
+
$gateway_object =& $this->Application->recallObject( $gw_data['ClassName'] );
+ /* @var $gateway_object kGWBase */
- $tpl = ''."\n";
+ $tpl = ''."\n";
$hidden_fields = $gateway_object->getHiddenFields($object->GetFieldValues(), $params, $gw_data['gw_params']);
- $ret = '';
- if (!is_array($hidden_fields)) {
+ if ( !is_array($hidden_fields) ) {
return $hidden_fields;
}
- foreach($hidden_fields as $hidden_name => $hidden_value)
- {
+
+ $ret = '';
+
+ foreach ($hidden_fields as $hidden_name => $hidden_value) {
$ret .= sprintf($tpl, $hidden_name, $hidden_value);
}
+
return $ret;
}
@@ -1122,10 +1123,11 @@
$object =& $this->getObject($params);
/* @var $object OrdersItem */
- $gw_data = $object->getGatewayData();
-
+ $gw_data = $object->getGatewayData( isset($params['payment_type_id']) ? $params['payment_type_id'] : null );
$this->Application->registerClass( $gw_data['ClassName'], GW_CLASS_PATH.'/'.$gw_data['ClassFile'] );
+
$gateway_object =& $this->Application->recallObject( $gw_data['ClassName'] );
+ /* @var $gateway_object kGWBase */
return $gateway_object->NeedPlaceButton($object->GetFieldValues(), $params, $gw_data['gw_params']);
}
@@ -1277,51 +1279,77 @@
$esender->Deliver();
}
- function PrintTotals($params)
+ /**
+ * Prints order totals
+ *
+ * @param Array $params
+ * @return string
+ * @access protected
+ */
+ protected function PrintTotals($params)
{
- $order =& $this->getObject($params);
+ $object =& $this->getObject($params);
+ /* @var $object OrdersItem */
- $totals = array();
- if (ABS($order->GetDBField('SubTotal') - $order->GetDBField('AmountWithoutVAT')) > 0.01) {
- $totals[] = 'products';
+ if ( isset($params['element_order']) ) {
+ // TODO: implement
}
+ else {
+ // default element order
+ $element_order = Array (
+ 'products' => 1, 'return' => 4, 'sub_total' => 5, 'discount' => 6,
+ 'vat' => 7, 'shipping' => 8, 'processing' => 9,
+ );
- $has_tangible = $this->OrderHasTangibleItems($params);
+ // show shipping & processing costs before tax, when they are taxable
+ if ( $object->GetDBField('ShippingTaxable') ) {
+ $element_order['shipping'] = 2;
+ }
- if ($has_tangible && $order->GetDBField('ShippingTaxable')) {
+ if ( $object->GetDBField('ProcessingTaxable') ) {
+ $element_order['processing'] = 3;
+ }
+ }
+
+ $totals = Array ();
+
+ if ( abs($object->GetDBField('SubTotal') - $object->GetDBField('AmountWithoutVAT')) > 0.01 ) {
+ $totals[] = 'products';
+ }
+
+ if ( $this->OrderHasTangibleItems($params) ) {
$totals[] = 'shipping';
}
- if ($order->GetDBField('ProcessingFee') > 0 && $order->GetDBField('ProcessingTaxable')) {
+ if ( $object->GetDBField('ProcessingFee') > 0 ) {
$totals[] = 'processing';
}
- if ($order->GetDBField('ReturnTotal') > 0 && $order->GetDBField('ReturnTotal')) {
+ if ( $object->GetDBField('ReturnTotal') > 0 ) {
$totals[] = 'return';
}
+ if ( $this->HasDiscount($params) ) {
+ $totals[] = 'discount';
+ }
+
$totals[] = 'sub_total';
- if ($order->GetDBField('VAT') > 0) {
+ if ( $object->GetDBField('VAT') > 0 ) {
$totals[] = 'vat';
}
- if ($has_tangible && !$order->GetDBField('ShippingTaxable')) {
- $totals[] = 'shipping';
- }
-
- if ($order->GetDBField('ProcessingFee') > 0 && !$order->GetDBField('ProcessingTaxable')) {
- $totals[] = 'processing';
- }
-
-
$o = '';
- foreach ($totals as $type) {
+ asort($element_order, SORT_NUMERIC);
+
+ foreach ($element_order as $type => $order) {
$element = getArrayValue($params, $type . '_render_as');
- if ( $element ) {
- $o .= $this->Application->ParseBlock(array ('name' => $element), 1);
+ if ( !in_array($type, $totals) || !$element ) {
+ continue;
}
+
+ $o .= $this->Application->ParseBlock(Array ('name' => $element), 1);
}
return $o;