Changeset View
Changeset View
Standalone View
Standalone View
branches/5.2.x/units/orders/orders_tag_processor.php
Show First 20 Lines • Show All 510 Lines • ▼ Show 20 Line(s) | |||||
$this->Application->SetVar('pt_id', $payment_type_id); | $this->Application->SetVar('pt_id', $payment_type_id); | ||||
$block_params['name'] = $this->SelectParam($params, $this->UsingCreditCard($params) ? 'cc_render_as,block_cc' : 'default_render_as,block_default' ); | $block_params['name'] = $this->SelectParam($params, $this->UsingCreditCard($params) ? 'cc_render_as,block_cc' : 'default_render_as,block_default' ); | ||||
return $this->Application->ParseBlock($block_params); | return $this->Application->ParseBlock($block_params); | ||||
} | } | ||||
return ''; | return ''; | ||||
} | } | ||||
/** | /** | ||||
* Returns true in case if credit card was used as payment type for order | * Returns true in case if credit card was used as payment type for order. | ||||
* | * | ||||
* @param Array $params | * @param array $params Tag params. | ||||
* @return bool | * | ||||
* @return boolean | |||||
* @throws Exception When payment type not found. | |||||
*/ | */ | ||||
function UsingCreditCard($params) | protected function UsingCreditCard(array $params) | ||||
{ | { | ||||
static $payment_types; | |||||
if ( !isset($payment_types) ) { | |||||
$pt_table = $this->Application->getUnitOption('pt', 'TableName'); | |||||
$sql = 'SELECT g.RequireCCFields, pt.PaymentTypeId | |||||
FROM ' . $pt_table . ' pt | |||||
JOIN ' . TABLE_PREFIX . 'Gateways g ON g.GatewayId = pt.GatewayId'; | |||||
$payment_types = $this->Conn->GetCol($sql, 'PaymentTypeId'); | |||||
} | |||||
/** @var kDBItem $object */ | |||||
$object = $this->getObject($params); | $object = $this->getObject($params); | ||||
$payment_type = $object->GetDBField('PaymentType'); | |||||
$pt = $object->GetDBField('PaymentType'); | if ( !$payment_type ) { | ||||
$payment_type = $this->getPrimaryPaymentType(); | |||||
$object->SetDBField('PaymentType', $payment_type); | |||||
} | |||||
if (!$pt) { | if ( !isset($payment_types[$payment_type]) ) { | ||||
$pt = $this->Conn->GetOne('SELECT PaymentTypeId FROM '.TABLE_PREFIX.'PaymentTypes WHERE IsPrimary = 1'); | throw new Exception('Unknown payment type: ' . $payment_type); | ||||
$object->SetDBField('PaymentType', $pt); | |||||
} | } | ||||
$pt_table = $this->Application->getUnitOption('pt','TableName'); | return $payment_types[$payment_type]; | ||||
$sql = 'SELECT GatewayId FROM %s WHERE PaymentTypeId = %s'; | } | ||||
$gw_id = $this->Conn->GetOne( sprintf( $sql, $pt_table, $pt ) ); | |||||
/** | |||||
* Get primary payment type. | |||||
* | |||||
* @return string | |||||
*/ | |||||
protected function getPrimaryPaymentType() | |||||
{ | |||||
static $primary_payment_type; | |||||
$sql = 'SELECT RequireCCFields FROM %s WHERE GatewayId = %s'; | if ( !isset($primary_payment_type) ) { | ||||
$pt_table = $this->Application->getUnitOption('pt', 'TableName'); | |||||
$sql = 'SELECT PaymentTypeId FROM ' . $pt_table . ' WHERE IsPrimary = 1'; | |||||
$primary_payment_type = $this->Conn->GetOne($sql); | |||||
} | |||||
return $this->Conn->GetOne( sprintf($sql, TABLE_PREFIX.'Gateways', $gw_id) ); | return $primary_payment_type; | ||||
} | } | ||||
function PaymentTypeDescription($params) | function PaymentTypeDescription($params) | ||||
{ | { | ||||
return $this->Application->ProcessParsedTag('pt', 'Field', array_merge($params, Array( | return $this->Application->ProcessParsedTag('pt', 'Field', array_merge($params, Array( | ||||
'field' => 'Description' | 'field' => 'Description' | ||||
)) ); | )) ); | ||||
} | } | ||||
▲ Show 20 Lines • Show All 1095 Lines • ▼ Show 20 Line(s) | |||||
foreach ($address_fields as $address_field) { | foreach ($address_fields as $address_field) { | ||||
if ( $object->GetDBField('Shipping' . $address_field) != $object->GetDBField('Billing' . $address_field) ) { | if ( $object->GetDBField('Shipping' . $address_field) != $object->GetDBField('Billing' . $address_field) ) { | ||||
return false; | return false; | ||||
} | } | ||||
} | } | ||||
return true; | return true; | ||||
} | } | ||||
} | } | ||||
No newline at end of file |