Skip to content

Commit

Permalink
fix bugs
Browse files Browse the repository at this point in the history
fix bugs
  • Loading branch information
Adem Demir committed Feb 27, 2019
1 parent bc25f8d commit 00975a7
Show file tree
Hide file tree
Showing 18 changed files with 6,192 additions and 252 deletions.
24 changes: 21 additions & 3 deletions install.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
-->
<modification>
<name>MyParcel NL</name>
<version>1.0.1</version>
<version>1.0.4</version>
<code>MyParcelNL</code>
<author>MyParcel NL</author>
<link>https://www.myparcel.nl/</link>
Expand Down Expand Up @@ -403,6 +403,23 @@
</operation>
</file>

<!-- ________________ catalog/view/theme/journal2/template/journal2/checkout/address_form.twig ________________ -->
<!-- _______________________ All Address Form Info Template _______________________ -->
<!-- _________________________________________________________________________ -->
<file path="catalog/view/theme/journal2/template/journal2/checkout/address_form.twig">
<operation>
<search><![CDATA[id="input-{{ type }}-address-2" class="form-control"/>]]></search>
<add position="after"><![CDATA[
{% if( use_addition_address and use_addition_address == 2 ) %}
</div>
<div class="form-group address-3-input">
<label class="col-sm-2 control-label" for="input-{{ type }}-address-3">Address 3</label>
<input type="text" name="{{ type }}_custom_field[address][address_3]" value="{{staticCall('Journal2Utils', 'getProperty', [order_data, type ~ '_custom_field.address.address_3', ''])}}" placeholder="Address 3" id="input-{{ type }}-address-3" class="form-control"/>
{% endif %}
]]></add>
</operation>
</file>

<!-- ________________ catalog/view/theme/*/template/checkout/guest.twig ________________ -->
<!-- _______________________ Billing Info Guest Template _______________________ -->
<!-- _________________________________________________________________________ -->
Expand Down Expand Up @@ -662,8 +679,9 @@
<!-- _________________________________________________________________________ -->
<file path="catalog/view/theme/*/template/account/address_form.twig">
<operation>
<search><![CDATA[<input type="text" name="address_2" value="{{ address_2 }}" placeholder="{{ entry_address_2 }}" id="input-address-2" class="form-control" />]]></search>
<add position="after"><![CDATA[
<search regex="true"><![CDATA[/<input type="text" name="address_2" value="{{ address_2 }}" placeholder="{{ entry_address_2 }}" id="input-address-2" class="form-control"(.*?)\/>/]]></search>
<add><![CDATA[
<input type="text" name="address_2" value="{{ address_2 }}" placeholder="{{ entry_address_2 }}" id="input-address-2" class="form-control"/>
{% if( use_addition_address and use_addition_address == 2 ) %}
</div>
</div>
Expand Down
3 changes: 2 additions & 1 deletion upload/admin/language/en-gb/extension/module/myparcelnl.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php
// Heading
$heading_title = 'Myparcel NL v1.0.1';
$heading_title = 'Myparcel NL v1.0.4';
$_['heading_title'] = $heading_title;
// Text
$_['text_module'] = 'Modules';
Expand Down Expand Up @@ -85,6 +85,7 @@
$_['entry_tab_2_select_insured_up_to_500'] = 'Insured up to &euro; 500 (+ &euro; 1.65)';
$_['entry_tab_2_select_insured_500'] = '> &euro; 500 insured (+ &euro; 1.65 / &euro; 500)';

$_['entry_subtotal'] = 'Subtotal';
$_['entry_tab_3_title_delivery_option'] = 'Delivery options';
$_['entry_tab_3_label_enable_delivery'] = 'Enable MyParcel delivery options';
$_['entry_tab_3_label_home_address_only'] = 'Home address only';
Expand Down
437 changes: 225 additions & 212 deletions upload/admin/view/template/extension/module/myparcelnl.twig

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,9 @@ function address_session()
//TODO discriminate OC 2 and OC 1
if (version_compare(VERSION, '2.0.0.0', '>=')) {
$address_data = isset($session->data['shipping_address']) ? $session->data['shipping_address'] : (isset($session->data['payment_address']) ? $session->data['payment_address'] : null);
$address_data['address_1'] = !empty($_POST['address_1']) ? $_POST['address_1'] : $address_data['address_1'];
$address_data['address_2'] = !empty($_POST['address_2']) ? $_POST['address_2'] : $address_data['address_2'];
$address_data['city'] = !empty($_POST['city']) ? $_POST['city'] : $address_data['city'];
} else {
if (MyParcel()->helper->isModuleExist('d_quickcheckout', true)) {
$address_data['address_1'] = $session->data['shipping_address']['address_1'];
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
.dropdown-menu .button-myparcel-total-details, .checkout-cart .button-myparcel-total-details {
display: none;
}

.journal-checkout .checkout-cart .button-myparcel-total-details {
display: inline-block;
}
#d_quickcheckout iframe#myparcel-iframe {
height: 400px;
}
74 changes: 71 additions & 3 deletions upload/system/library/myparcelnl/assets/js/checkout.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,13 @@ var MYPARCEL_CHECKOUT = MYPARCEL_CHECKOUT || {};
return true;
}

// For journal theme
if (settings.url.indexOf('route=journal2/checkout/shipping') > 0) {
$("#myparcel-iframe").css({'height': '650px'});
var a = MYPARCEL_CHECKOUT.activateIframe();
return true;
}

if (
settings.url.indexOf('checkout/shipping_address') >= 0
||
Expand Down Expand Up @@ -176,7 +183,11 @@ var MYPARCEL_CHECKOUT = MYPARCEL_CHECKOUT || {};
},
success: function (res) {
if (res.status == 'success') {
$('.button-myparcel-total-details').closest('tr').after(res.html);
button.closest('tr').after(res.html);
// For journal theme
if (button.parents('.cart-wrapper').length > 0) {
button.closest('tbody').find('.myparcel-total td:first').removeAttr('colspan');
}
}
},
complete: function () {
Expand All @@ -192,7 +203,7 @@ var MYPARCEL_CHECKOUT = MYPARCEL_CHECKOUT || {};
}
return false;
});
},
}
};

MYPARCEL_CHECKOUT.helper = {
Expand Down Expand Up @@ -360,11 +371,24 @@ var MYPARCEL_CHECKOUT = MYPARCEL_CHECKOUT || {};
$('#delivery-options-wrapper').data('loaded', true);
});

// journal2 theme guest checkout
var data = {};
var currentTheme = window.myparcel_current_theme;//$(".journal-checkout").length;
if (currentTheme == 'journal2') {
if($('input[name="account"]').is(":checked") && ($('input[name="account"]:checked').val() == 'guest' || $('input[name="account"]:checked').val() == 'register')) {
var type = $('input[name="shipping_address"]').is(":checked") ? 'payment' : 'shipping';
data.address_1 = $('input[name="' + type + '_address_1"]').val();
data.address_2 = $('input[name="' + type + '_address_2"]').val();
data.city = $('input[name="' + type + '_city"]').val();
}
}

// Retrieve address from session
$.ajax({
return $.ajax({
url: window.myparcel_ajax_get_address_from_session_url,
type: 'POST',
dataType: 'json',
data: data,
beforeSend: function() {
$('#myparcel-iframe').before('<p>' + window.entry_loading + '</p>');
$('#delivery-options-wrapper').hide();
Expand All @@ -389,8 +413,52 @@ var MYPARCEL_CHECKOUT = MYPARCEL_CHECKOUT || {};
});
};

MYPARCEL_CHECKOUT.journalThemeEventActivated = function () {
var currentTheme = window.myparcel_current_theme;//$(".journal-checkout").length;
if (currentTheme == 'journal2') {
$.ajax({
cache: false,
url: 'index.php?route=journal2/checkout/save',
type: 'post',
data: $('.parcel-shipping-method, #mypa-input, #mypa-signed:checked, #mypa-recipient-only:checked'),
dataType: 'json',
success: function () {
$.ajax({
cache: false,
url: 'index.php?route=journal2/checkout/cart_update',
type: 'post',
dataType: 'json',
success: function (json) {
setTimeout(function () {
$('#cart-total').html(json['total']);
}, 100);

$('#cart ul').load('index.php?route=common/cart/info ul li');
}
});
$(document).trigger('journal_checkout_reload_payment');
$(document).trigger('journal_checkout_reload_cart');
},
error: function (xhr, ajaxOptions, thrownError) {
console.error && console.error(thrownError + "\r\n" + xhr.statusText + "\r\n" + xhr.responseText);
}
});
}
}

$(document).ready(function ($) {
MYPARCEL_CHECKOUT.initialize.onReady();

$(document).delegate('input[name*="address_1"], input[name*="address_2"]', 'change', function () {
var $this = $('input[name="shipping_address"]');

if ($this.is(':checked')) {
$(document).trigger('journal_checkout_address_changed', 'payment');
} else {
$(document).trigger('journal_checkout_address_changed', 'payment');
$(document).trigger('journal_checkout_address_changed', 'shipping');
}
});
});

window.mypaLoaded = function() {
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

13 changes: 13 additions & 0 deletions upload/system/library/myparcelnl/assets/js/myparcelnl.js
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,19 @@ $(document).ready(function() {
}
});

$('.checkbox_delivery_options_2').change(function(){
var container = $(this);
var input = container.closest('.form-group').find('.col-input');

if (container.prop('checked')) {
if(input.hasClass('hidden'))
input.removeClass('hidden').addClass('show');
}else{
if(input.hasClass('show'))
input.removeClass('show').addClass('hidden');
}
});

$("#checkbox_insured").change(function(){
if($(this).prop('checked') == true){
if ($('#div_checkbox_insured').hasClass("hidden")) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -697,6 +697,7 @@ function set_module_text($language)
$data['entry_tab_2_select_insured_up_to_500'] = $language->get('entry_tab_2_select_insured_up_to_500');
$data['entry_tab_2_select_insured_500'] = $language->get('entry_tab_2_select_insured_500');

$data['entry_subtotal'] = $language->get('entry_subtotal');
$data['entry_tab_3_title_delivery_option'] = $language->get('entry_tab_3_title_delivery_option');
$data['entry_tab_3_label_enable_delivery'] = $language->get('entry_tab_3_label_enable_delivery');
$data['entry_tab_3_label_home_address_only'] = $language->get('entry_tab_3_label_home_address_only');
Expand Down
Loading

0 comments on commit 00975a7

Please sign in to comment.