Skip to content

Commit

Permalink
SUG-385 : Add simplecheckout support
Browse files Browse the repository at this point in the history
  • Loading branch information
Sp0i3eR committed Dec 9, 2014
1 parent 67838c4 commit 7a04c51
Show file tree
Hide file tree
Showing 4 changed files with 84 additions and 19 deletions.
50 changes: 50 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
# Created by .gitignore support plugin (hsz.mobi)
### JetBrains template
# Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm

*.iml

## Directory-based project format:
.idea/
# if you remove the above rule, at least ignore the following:

# User-specific stuff:
# .idea/workspace.xml
# .idea/tasks.xml
# .idea/dictionaries

# Sensitive or high-churn files:
# .idea/dataSources.ids
# .idea/dataSources.xml
# .idea/sqlDataSources.xml
# .idea/dynamic.xml
# .idea/uiDesigner.xml

# Gradle:
# .idea/gradle.xml
# .idea/libraries

# Mongo Explorer plugin:
# .idea/mongoSettings.xml

## File-based project format:
*.ipr
*.iws

## Plugin-specific files:

# IntelliJ
out/

# mpeltonen/sbt-idea plugin
.idea_modules/

# JIRA plugin
atlassian-ide-plugin.xml

# Crashlytics plugin (for Android Studio and IntelliJ)
com_crashlytics_export_strings.xml
crashlytics.properties
crashlytics-build.properties


6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,10 @@ $ mysql opencart -u opencart -p < zone.sql

После заполнения всех полей необходимо сохранить настройки.

#### Настройки для работы с модулем simple checkout

Для корректного выбора региона - установите Российскую федерацию в качестве страны по умолчанию в настройках модуля *Simple Checkout > Поля > country_id > Значение по умолчанию*

### 3. Пользуйтесь подсказками!

Подсказки работают при вводе ФИО и адреса во время регистрации и оформления заказа:
Expand All @@ -55,6 +59,8 @@ $ mysql opencart -u opencart -p < zone.sql

История изменений
-----------------
* 1.2
* Добавлена поддержка simplecheckout (спасибо deeman)

* 1.1
* Добавлена возможность использовать платную версию сервиса
Expand Down
19 changes: 12 additions & 7 deletions upload/catalog/view/javascript/jquery/dadata/dadata.js
Original file line number Diff line number Diff line change
Expand Up @@ -97,23 +97,28 @@
return;
}
$('.dadata-additional').remove();
var $where = $(this).parents(".simplecheckout-block");

if (!$where.length) {
$where = $(document);
}
var address = suggestion.data;
if ($options.additional == '1') {
$(this).next('.suggestions-wrapper').after(
self.getAdditional(address)
);
}
$("input[name=\'postcode\']").val(
$where.find("input[name*=postcode]").val(
nvl(address.postal_code)
);
$("input[name='city']").val(
$where.find("input[name*=city]").val(
self.getCity(address)
);
$("input[name=\'address_1\']").val(
$where.find("input[name*=address_1]").val(
self.getStreetAddress(address)
);
if (address.region) {
self.selectRegion(address, $("select[name='zone_id']"));
self.selectRegion(address, $where.find("select[name*=zone_id]"));
}
}

Expand Down Expand Up @@ -146,10 +151,10 @@
if (address.street_type && address.street) {
address_1 += address.street_type + ' ' + address.street;
}
if(address.house_type != null && address.house != null) {
if(address.house_type !== null && address.house !== null) {
address_1 += (address_1 ? ', ' : '') + address.house_type + ' ' + address.house;
}
if(address.flat_type != null && address.flat != null) {
if(address.flat_type !== null && address.flat !== null) {
address_1 += (address_1 ? ', ' : '') + address.flat_type + ' ' + address.flat;
}
return address_1;
Expand All @@ -165,7 +170,7 @@
selectRegion: function(address, $el) {
$el.children("option").each(function() {
if (this.text.indexOf(address.region) !== -1) {
$(this).attr("selected", "selected")
$(this).attr("selected", "selected");
}
});
}
Expand Down
28 changes: 16 additions & 12 deletions upload/catalog/view/theme/default/template/module/dadata.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -11,25 +11,25 @@
FullNameSuggestions.init({
name: $('input[name=\'firstname\']'),
surname: $('input[name=\'lastname\']'),
name: $('input[name*=firstname]'),
surname: $('input[name*=lastname]'),
url: dadataUrl,
token: "<?php echo $dadata_api; ?>",
tips: "<?php echo $dadata_tips;?>",
correction: "<?php echo $dadata_correction; ?>",
view_gender: "<?php echo $dadata_gender; ?>"
});
var addressParent = $('input[name="address_1"]').parents("tbody");
if (addressParent.length>0) addressParent.prepend('<tr><td colspan = "2">' + addressInputHtml + '</td></tr >')
var addressParent = $('input[name*=address_1]').parents("tbody");
if (addressParent.length > 0) addressParent.prepend('<tr><td colspan = "2">' + addressInputHtml + '</td></tr >')
else {
addressParent = $('input[name="address_1"]').prevAll("span");
addressParent = $('input[name*=address_1]').prevAll("span");
if (addressParent.length > 0)
addressParent.before(addressInputHtml);
addressParent.before(addressInputHtml);
}
FullAddressSuggestions.init({
address: $('input[name=\'address\']'),
address: $('input[name=address]'),
url: dadataUrl,
token: "<?php echo $dadata_api; ?>",
tips: "<?php echo $dadata_tips;?>",
Expand All @@ -42,13 +42,17 @@
$(document).ready(function () {
initFields();
$(document).ajaxComplete( function (e, xhr, settings) {
if (settings.url=="index.php?route=checkout/guest" ||
settings.url== "index.php?route=checkout/guest_shipping" ||
$(document).ajaxComplete(function (e, xhr, settings) {
if (settings.url == "index.php?route=checkout/guest" ||
settings.url == "index.php?route=checkout/guest_shipping" ||
settings.url == "index.php?route=checkout/register" ||
settings.url == "index.php?route=checkout/shipping_address" ||
settings.url == "index.php?route=checkout/payment_address")
initFields();
settings.url == "index.php?route=checkout/payment_address" ||
settings.url.indexOf("route=checkout/simplecheckout") > 0 ||
settings.url.indexOf("route=account/simpleaddress") > 0 ||
settings.url.indexOf("route=account/simpleedit") > 0 ||
settings.url.indexOf("route=account/simpleregister") > 0)
initFields();
});
});
//--></script>

0 comments on commit 7a04c51

Please sign in to comment.