Skip to content

Commit

Permalink
Merge pull request #448 from myparcelnl/show/hide-standard-delivery
Browse files Browse the repository at this point in the history
show and hide the standard delivery
  • Loading branch information
RichardPerdaan authored Jan 8, 2019
2 parents f56ca23 + f15cc1f commit f5b4090
Show file tree
Hide file tree
Showing 5 changed files with 49 additions and 21 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,7 @@ public function infoAction()
$delivery['delivery_title'] = $helper->getConfig('delivery_title', 'delivery');
$delivery['standard_delivery_titel'] = $helper->getConfig('standard_delivery_titel', 'delivery');
}
$delivery['standard_delivery_active'] = $helper->getConfig('standard_delivery_active', 'delivery') == "1";

$delivery['only_recipient_active'] = $helper->getConfig('only_recipient_active', 'delivery') == "1" && $data['address']['country'] == 'NL' ? true : false;
$delivery['only_recipient_title'] = $helper->getConfig('only_recipient_title', 'delivery');
Expand Down
3 changes: 2 additions & 1 deletion app/code/community/TIG/MyParcel2014/etc/config.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<config>
<modules>
<TIG_MyParcel2014>
<version>1.17.2</version>
<version>1.17.3-beta.1</version>
</TIG_MyParcel2014>
</modules>
<global>
Expand Down Expand Up @@ -282,6 +282,7 @@
<standard_delivery_titel></standard_delivery_titel>
<retrieve_address_title>Adres ophalen...</retrieve_address_title>
<busy_loading_title>Bezig met laden...</busy_loading_title>
<standard_delivery_active>1</standard_delivery_active>
<only_recipient_active>1</only_recipient_active>
<only_recipient_title>Niet bij de buren bezorgen</only_recipient_title>
<only_recipient_fee>0.29</only_recipient_fee>
Expand Down
9 changes: 9 additions & 0 deletions app/code/community/TIG/MyParcel2014/etc/system.xml
Original file line number Diff line number Diff line change
Expand Up @@ -299,6 +299,15 @@
<show_in_website>1</show_in_website>
<show_in_store>1</show_in_store>
</busy_loading_title>
<standard_delivery_active translate="label" module="tig_myparcel">
<label>Standard delivery active</label>
<frontend_type>select</frontend_type>
<source_model>tig_myparcel/system_config_source_yesno</source_model>
<sort_order>157</sort_order>
<show_in_default>1</show_in_default>
<show_in_website>1</show_in_website>
<show_in_store>1</show_in_store>
</standard_delivery_active>
<age_check translate="label" module="tig_myparcel">
<label>Age check 18+</label>
<comment>The age 18+ check is intended for parcel shipments for which the recipient must show 18+ by means of a proof of identity. With this shipping option "Signature for receipt" and "Delivery only at recipient" are included. The age 18+ is further excluded from the delivery options morning and evening delivery.</comment>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -158,12 +158,12 @@ $toggleOptions = $helper->getConfig('toggle_options', 'checkout') == '1' ? true
<div id="mypa-delivery-option-form">
<table class="mypa-delivery-option-table">
<tbody>
<tr>
<tr id="mypa-delivery-title-section">
<td>
<input name="mypa-deliver-or-pickup" id="mypa-select-delivery" value="mypa-deliver" type="radio">
</td>
<td colspan="2">
<label id="mypa-select-delivery-titel" for="mypa-select-delivery"><span id="mypa-delivery-titel"></span></label>
<label id="mypa-select-delivery-titel" for="mypa-select-delivery"><span id="mypa-delivery-title"></span></label>
</td>
</tr>
<tr id="mypa-delivery-date-select">
Expand All @@ -178,7 +178,7 @@ $toggleOptions = $helper->getConfig('toggle_options', 'checkout') == '1' ? true
<div name="mypa-delivery-date-text" id="mypa-date" title="Delivery date"></div>
</td>
</tr>
<tr id="method-myparcel-delivery-morning-div">
<tr id="method-myparcel-delivery-morning-section">
<td></td>
<td>
<div class="mypa-delivery-option" >
Expand All @@ -192,7 +192,7 @@ $toggleOptions = $helper->getConfig('toggle_options', 'checkout') == '1' ? true
</div>
</td>
</tr>
<tr>
<tr id="method-myparcel-delivery-standard-section">
<td></td>
<td>
<div id="mypa-delivery" class="mypa-delivery-option">
Expand All @@ -206,7 +206,7 @@ $toggleOptions = $helper->getConfig('toggle_options', 'checkout') == '1' ? true
</div>
</td>
</tr>
<tr id="method-myparcel-delivery-evening-div">
<tr id="method-myparcel-delivery-evening-section">
<td></td>
<td>
<div class="mypa-delivery-option">
Expand Down
47 changes: 32 additions & 15 deletions skin/frontend/base/default/js/TIG/MyParcel2014/myparcel.js
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ MyParcel = {
"carrier": "1",

"priceMorningDelivery": data.morningDelivery['fee'],
"priceNormalDelivery": data.general['base_price'],
"priceStandardDelivery": data.general['base_price'],
"priceEveningDelivery": data.eveningDelivery['fee'],
"priceSignature": data.delivery['signature_fee'],
"pricePickup": data.pickup['fee'],
Expand All @@ -115,6 +115,7 @@ MyParcel = {

"allowMondayDelivery": data.general['monday_delivery_active'],
"allowMorningDelivery": data.morningDelivery['active'],
"allowStandardDelivery": data.delivery['standard_delivery_active'],
"allowEveningDelivery": data.eveningDelivery['active'],
"allowSignature": data.delivery['signature_active'],
"allowOnlyRecipient": data.delivery['only_recipient_active'],
Expand Down Expand Up @@ -157,8 +158,10 @@ MyParcel = {
}

/* Titels of the options*/
if (MyParcel.data.config.deliveryTitel){
mypajQuery('#mypa-delivery-titel').html(MyParcel.data.config.deliveryTitel);
mypajQuery('#mypa-delivery-title-section').hide();
if (MyParcel.data.config.allowMorningDelivery || MyParcel.data.config.allowStandardDelivery || MyParcel.data.config.allowEveningDelivery){
mypajQuery('#mypa-delivery-title').html(MyParcel.data.config.deliveryTitel);
mypajQuery('#mypa-delivery-title-section').show();
}
if (MyParcel.data.config.onlyRecipientTitel){
mypajQuery('#mypa-only-recipient-titel').html(MyParcel.data.config.onlyRecipientTitel);
Expand All @@ -173,7 +176,7 @@ MyParcel = {
/* Prices */
mypajQuery('#mypa-morning-delivery').html(MyParcel.getPriceHtml(this.data.config.priceMorningDelivery));
mypajQuery('#mypa-evening-delivery').html(MyParcel.getPriceHtml(this.data.config.priceEveningDelivery));
mypajQuery('#mypa-normal-delivery').html(MyParcel.getPriceHtml(this.data.config.priceNormalDelivery));
mypajQuery('#mypa-normal-delivery').html(MyParcel.getPriceHtml(this.data.config.priceStandardDelivery));
mypajQuery('#mypa-signature-price').html(MyParcel.getPriceHtml(this.data.config.priceSignature));
mypajQuery('#mypa-only-recipient-price').html(MyParcel.getPriceHtml(this.data.config.priceOnlyRecipient));
mypajQuery('#mypa-pickup-price').html(MyParcel.getPriceHtml(this.data.config.pricePickup));
Expand Down Expand Up @@ -214,6 +217,7 @@ MyParcel = {
var selectDateKey = MyParcel.storeDeliveryOptions.data.delivery[selectedDate]['time'];

MyParcel.hideMorningDelivery();
MyParcel.hideStandardDelivery();
MyParcel.hideEveningDelivery();

mypajQuery.each(selectDateKey, function(key, value){
Expand All @@ -223,10 +227,10 @@ MyParcel = {
MyParcel.getDeliveryTime(morningTitel,'morning', MyParcel.data.config.deliveryMorningTitel, value['start'], value['end']);
MyParcel.showMorningDelivery();
}
if(value['price_comment'] == 'standard'){
if(value['price_comment'] == 'standard' && MyParcel.data.config.allowStandardDelivery){
var standardTitel = MyParcel.data.config.deliveryStandardTitel;
MyParcel.getDeliveryTime(standardTitel,'standard', MyParcel.data.config.deliveryStandardTitel, value['start'], value['end']);

MyParcel.showStandardDelivery();
}
if(value['price_comment'] == 'avond' && MyParcel.data.config.allowEveningDelivery){
var eveningTitel = MyParcel.data.config.deliveryEveningTitel;
Expand Down Expand Up @@ -277,6 +281,7 @@ MyParcel = {

/* hide default delivery options and show PostNL options */
mypajQuery('#mypa-pickup-delivery').on('click', function(){
MyParcel.setCurrentLocation();
MyParcel.hideDelivery();
MyParcel.showPickUpLocations();
});
Expand Down Expand Up @@ -619,10 +624,10 @@ MyParcel = {

hideDelivery: function()
{
MyParcel.hideNormalDelivery();
MyParcel.hideSignature();
MyParcel.hideOnlyRecipient();
MyParcel.hideMorningDelivery();
MyParcel.hideStandardDelivery();
MyParcel.hideEveningDelivery();

},
Expand All @@ -636,7 +641,11 @@ MyParcel = {

showDelivery: function()
{
MyParcel.showNormalDelivery();

MyParcel.hideStandardDelivery();
if(this.data.config.allowStandardDelivery){
MyParcel.showStandardDelivery();
}

MyParcel.hideSignature();
if(this.data.config.allowSignature){
Expand All @@ -649,7 +658,7 @@ MyParcel = {
}

if(MyParcel.data.address.cc === 'BE'){
mypajQuery('#mypa-delivery-titel').html(MyParcel.data.config.BelgiumdeliveryTitel);
mypajQuery('#mypa-delivery-title').html(MyParcel.data.config.BelgiumdeliveryTitel);
mypajQuery('#mypa-delivery-date-text,#mypa-delivery-date-select').hide();
}
},
Expand Down Expand Up @@ -682,24 +691,27 @@ MyParcel = {

showMorningDelivery: function()
{
mypajQuery('#method-myparcel-delivery-morning-div').show();
mypajQuery('#method-myparcel-delivery-morning-section').show();
},

hideMorningDelivery: function()
{
mypajQuery('#method-myparcel-delivery-morning-div').hide();
mypajQuery('#method-myparcel-delivery-morning-section').hide();
},

showNormalDelivery: function()

showStandardDelivery: function()
{
mypajQuery('#method-myparcel-delivery-standard-section').show();
mypajQuery('#mypa-pre-selectors-' + this.data.address.cc.toLowerCase()).show();
mypajQuery('#mypa-delivery-selectors-' + this.data.address.cc.toLowerCase()).show();
mypajQuery('#mypa-delivery, #mypa-normal-delivery, #mypa-delivery-date-select').show();
mypajQuery('#mypa-delivery').parent().parent().show();
},

hideNormalDelivery: function()
hideStandardDelivery: function()
{
mypajQuery('#method-myparcel-delivery-standard-section').hide();
mypajQuery('#mypa-delivery-date-select, #mypa-pre-selectors-nl, #mypa-delivery, #mypa-normal-delivery').hide();
mypajQuery('#mypa-delivery').parent().parent().hide();

Expand All @@ -708,12 +720,12 @@ MyParcel = {

showEveningDelivery: function()
{
mypajQuery('#method-myparcel-delivery-evening-div').show();
mypajQuery('#method-myparcel-delivery-evening-section').show();
},

hideEveningDelivery: function()
{
mypajQuery('#method-myparcel-delivery-evening-div').hide();
mypajQuery('#method-myparcel-delivery-evening-section').hide();
},

showSignature: function()
Expand Down Expand Up @@ -1079,6 +1091,11 @@ MyParcel = {
})
.always(function(){
mypajQuery('#mypa-select-delivery, #method-myparcel-normal').click();

if (!MyParcel.data.config.allowMorningDelivery && !MyParcel.data.config.allowStandardDelivery && !MyParcel.data.config.allowEveningDelivery){
mypajQuery('#mypa-pickup-delivery, #mypa-pickup-selector').click();
}

MyParcel.mapExternalWebshopTriggers();

if (typeof window.mypa != 'undefined') {
Expand Down

0 comments on commit f5b4090

Please sign in to comment.