Index: install/english.lang
===================================================================
--- install/english.lang (revision 13137)
+++ install/english.lang (working copy)
@@ -90,6 +90,7 @@
QW1vdW50
QXZhaWwu
QmFzZSBGZWU=
+ QmlsbGluZyBDb3VudHJ5
QnVpbHQtSW4=
Q09EIEFsbG93ZWQ=
Q29kZQ==
@@ -103,6 +104,7 @@
Q291cG9uIENvZGU=
Q291cG9uIEl0ZW0gVHlwZQ==
Q3JlZGl0IENhcmQgTnVtYmVy
+ Q3VycmVuY3k=
TmFtZQ==
U3ltYm9s
U3ltYm9sIFBvc2l0aW9u
@@ -180,6 +182,7 @@
UmV0LiBEYXRl
UmV0LiBUeXBl
U2hpcHBpbmc=
+ U2hpcHBpbmcgQ291bnRyeQ==
RnJvbSBMb2NhdGlvbg==
TmFtZQ==
TmFtZQ==
@@ -311,6 +314,8 @@
Q29zdCBUeXBl
Q291cG9uIENvZGU=
Q3JlZGl0IENhcmQgTnVtYmVy
+ Q3VycmVuY2llcw==
+ Q3VycmVuY3k=
TmFtZQ==
U3ltYm9s
U3ltYm9sIFBvc2l0aW9u
@@ -381,6 +386,7 @@
UGF5bWVudCBUeXBl
QXZhaWxhYmxlIEN1cnJlbmNpZXM=
UGF5bWVudCBUeXBlIElk
+ UGF5bWVudCBUeXBlcw==
UGVyY2VudCBTdXJjaGFyZ2U=
UGVyaW9k
QWxsb3cgUGxhY2VkIE9yZGVycyBFZGl0aW5n
Index: units/addresses/addresses_event_handler.php
===================================================================
--- units/addresses/addresses_event_handler.php (revision 13128)
+++ units/addresses/addresses_event_handler.php (working copy)
@@ -318,4 +318,21 @@
return ;
}
}
+
+ /**
+ * Sets default country for new addresses to Latvia
+ *
+ * @param kEvent $event
+ */
+ function OnAfterConfigRead(&$event)
+ {
+ parent::OnAfterConfigRead($event);
+
+ $site_helper =& $this->Application->recallObject('SiteHelper');
+ /* @var $site_helper SiteHelper */
+
+ $fields = $this->Application->getUnitOption($event->Prefix, 'Fields');
+ $fields['Country']['default'] = $site_helper->getDefaultCountry('Shipping');
+ $this->Application->setUnitOption($event->Prefix, 'Fields', $fields);
+ }
}
\ No newline at end of file
Index: units/currencies/currencies_event_handler.php
===================================================================
--- units/currencies/currencies_event_handler.php (revision 13147)
+++ units/currencies/currencies_event_handler.php (working copy)
@@ -95,6 +95,23 @@
if (!$this->Application->isAdminUser) {
$object->addFilter('status_filter', $object->TableName.'.Status = 1');
}
+
+ // site domain currency picker
+ if ($event->Special == 'selected' || $event->Special == 'available') {
+ $edit_picker_helper =& $this->Application->recallObject('EditPickerHelper');
+ /* @var $edit_picker_helper EditPickerHelper */
+
+ $edit_picker_helper->applyFilter($event, 'Currencies');
+ $object->addFilter('status_filter', '%1$s.Status = ' . STATUS_ACTIVE);
+ }
+
+ // apply domain-based currency filtering
+ $currencies = $this->Application->siteDomainField('Currencies');
+
+ if (strlen($currencies)) {
+ $currencies = explode('|', substr($currencies, 1, -1));
+ $object->addFilter('domain_filter', '%1$s.CurrencyId IN (' . implode(',', $currencies) . ')');
+ }
}
/**
Index: units/currencies/currency_rates.php
===================================================================
--- units/currencies/currency_rates.php (revision 13128)
+++ units/currencies/currency_rates.php (working copy)
@@ -17,7 +17,6 @@
var $RateSource;
var $ExchangeRates = Array();
- var $PrimaryCurrency;
function kCurrencyRates()
{
@@ -30,7 +29,7 @@
// written :) just check that it's correct
$conn =& $this->Application->GetADODBConnection();
$table = $this->Application->getUnitOption('curr', 'TableName');
- $primary = $this->GetPrimaryCurrency();
+ $primary = $this->Application->GetPrimaryCurrency();
$sql = 'SELECT "'.$primary.'" AS TARGET, ISO AS ID, RateToPrimary As RATE, 1 AS UNITS FROM '.$table.' WHERE 1';
$rates = $conn->Query($sql);
foreach ($rates as $a_rate) {
@@ -40,8 +39,8 @@
function GetRate($source_cur, $target_cur, $units = 1)
{
- $source_cur = ($source_cur == 'PRIMARY') ? $this->GetPrimaryCurrency() : $source_cur;
- $target_cur = ($target_cur == 'PRIMARY') ? $this->GetPrimaryCurrency() : $target_cur;
+ $source_cur = ($source_cur == 'PRIMARY') ? $this->Application->GetPrimaryCurrency() : $source_cur;
+ $target_cur = ($target_cur == 'PRIMARY') ? $this->Application->GetPrimaryCurrency() : $target_cur;
if($source_cur == $target_cur)
{
return 1;
@@ -76,18 +75,6 @@
$this->ExchangeRates[$target_cur]['UNITS'] = $units;
}
- function GetPrimaryCurrency()
- {
- if(!$this->PrimaryCurrency)
- {
- $conn =& $this->Application->GetADODBConnection();
- $table = $this->Application->getUnitOption('curr', 'TableName');
- $sql = 'SELECT ISO FROM '.$table.' WHERE IsPrimary = 1';
- $this->PrimaryCurrency = $conn->GetOne($sql);
- }
- return $this->PrimaryCurrency;
- }
-
function StoreRates($currencies=null)
{
$curr_object =& $this->Application->recallObject('curr', null, Array ('skip_autoload' => true));
@@ -127,7 +114,6 @@
function GetRatesData()
{
- $this->GetPrimaryCurrency();
$xml_parser = xml_parser_create();
$curl_helper =& $this->Application->recallObject('CurlHelper');
@@ -179,7 +165,6 @@
function GetRatesData()
{
- $this->GetPrimaryCurrency();
$xml_parser = xml_parser_create();
$curl_helper =& $this->Application->recallObject('CurlHelper');
@@ -225,7 +210,6 @@
$curl_helper =& $this->Application->recallObject('CurlHelper');
/* @var $curl_helper kCurlHelper */
- $this->GetPrimaryCurrency();
for($i = 0; $i < 10; $i++)
{
$time = adodb_mktime() - $i * 3600 * 24;
Index: units/orders/orders_event_handler.php
===================================================================
--- units/orders/orders_event_handler.php (revision 13128)
+++ units/orders/orders_event_handler.php (working copy)
@@ -536,17 +536,22 @@
function OnProceedToBilling(&$event)
{
$items_info = $this->Application->GetVar( $event->getPrefixSpecial(true) );
- if($items_info)
- {
- list($id,$field_values) = each($items_info);
+ if ($items_info) {
+ list($id, $field_values) = each($items_info);
$object =& $event->getObject();
$payment_type_id = $object->GetDBField('PaymentType');
- if(!$payment_type_id)
- {
- $default_type = $this->Conn->GetOne('SELECT PaymentTypeId FROM '.TABLE_PREFIX.'PaymentTypes WHERE IsPrimary = 1');
- if($default_type)
- {
+ if (!$payment_type_id) {
+ $default_type = $this->Application->siteDomainField('PrimaryPaymentTypeId');
+
+ if (!$default_type) {
+ $sql = 'SELECT PaymentTypeId
+ FROM ' . TABLE_PREFIX . 'PaymentTypes
+ WHERE IsPrimary = 1';
+ $default_type = $this->Conn->GetOne($sql);
+ }
+
+ if ($default_type) {
$field_values['PaymentType'] = $default_type;
$items_info[$id] = $field_values;
$this->Application->SetVar( $event->getPrefixSpecial(true), $items_info );
@@ -3821,15 +3826,34 @@
$fields['Number']['format'] = str_replace('%06d', '%0'.$order_number.'d', $fields['Number']['format']);
$fields['SubNumber']['format'] = str_replace('%03d', '%0'.$order_sub_number.'d', $fields['SubNumber']['format']);
+ $site_helper =& $this->Application->recallObject('SiteHelper');
+ /* @var $site_helper SiteHelper */
+
+ $fields['BillingCountry']['default'] = $site_helper->getDefaultCountry('Billing');
+ $fields['ShippingCountry']['default'] = $site_helper->getDefaultCountry('Shipping');
+
if (!$this->Application->isAdminUser) {
$user_groups = explode(',', $this->Application->RecallVar('UserGroups'));
$default_group = $this->Application->ConfigValue('User_LoggedInGroup');
if (!in_array($default_group, $user_groups)){
$user_groups[]=$default_group;
}
- $fields['PaymentType']['options_sql'] .= ' AND ';
- $fields['PaymentType']['options_sql'] .= ' (PortalGroups LIKE "%%,'.implode(',%%" OR PortalGroups LIKE "%%,', $user_groups).',%%")';
+ $sql = $fields['PaymentType']['options_sql'];
+
+ // limit payment types by domain
+ $payment_types = $this->Application->siteDomainField('PaymentTypes');
+
+ if (strlen($payment_types)) {
+ $payment_types = explode('|', substr($payment_types, 1, -1));
+ $sql .= ' AND PaymentTypeId IN (' . implode(',', $payment_types) . ')';
+ }
+
+ // limit payment types by user group
+ $sql .= ' AND (PortalGroups LIKE "%%,'.implode(',%%" OR PortalGroups LIKE "%%,', $user_groups).',%%")';
+
+ $fields['PaymentType']['options_sql'] = $sql;
+
}
$this->Application->setUnitOption($event->Prefix, 'Fields', $fields);
Index: units/payment_type/payment_type_event_handler.php
===================================================================
--- units/payment_type/payment_type_event_handler.php (revision 13128)
+++ units/payment_type/payment_type_event_handler.php (working copy)
@@ -218,4 +218,38 @@
return parent::getPassedID($event);
}
+ /**
+ * Apply system filter to themes list
+ *
+ * @param kEvent $event
+ */
+ function SetCustomQuery(&$event)
+ {
+ parent::SetCustomQuery($event);
+
+ $object =& $event->getObject();
+ /* @var $object kDBList */
+
+ if (in_array($event->Special, Array ('enabled', 'selected', 'available')) || !$this->Application->isAdminUser) {
+ // "enabled" special or Front-End
+ $object->addFilter('enabled_filter', '%1$s.Status = ' . STATUS_ACTIVE);
+ }
+
+ // site domain payment type picker
+ if ($event->Special == 'selected' || $event->Special == 'available') {
+ $edit_picker_helper =& $this->Application->recallObject('EditPickerHelper');
+ /* @var $edit_picker_helper EditPickerHelper */
+
+ $edit_picker_helper->applyFilter($event, 'PaymentTypes');
+ }
+
+ // apply domain-based payment type filtering
+ $payment_types = $this->Application->siteDomainField('PaymentTypes');
+
+ if (strlen($payment_types)) {
+ $payment_types = explode('|', substr($payment_types, 1, -1));
+ $object->addFilter('domain_filter', '%1$s.PaymentTypeId IN (' . implode(',', $payment_types) . ')');
+ }
+ }
+
}
\ No newline at end of file