Skip to content

Commit

Permalink
Merge pull request #106 from paynl/ISSUE-105
Browse files Browse the repository at this point in the history
Add check to shipping method if object exists or not to prevent this …
  • Loading branch information
woutse authored Nov 19, 2020
2 parents a1477e0 + 463a161 commit de1619b
Show file tree
Hide file tree
Showing 4 changed files with 47 additions and 41 deletions.
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "paynl/magento2-plugin",
"description": "PAY. Magento2 Payment methods",
"type": "magento2-module",
"version": "1.6.7",
"version": "1.6.8",
"require": {
"magento/module-sales": "100 - 103",
"magento/module-payment": "100 - 103",
Expand Down
26 changes: 14 additions & 12 deletions view/frontend/web/js/view/payment/method-renderer/billink.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,13 +36,15 @@ define(
return (this.getDOB() > 0 && this.getKVK() > 0);
},
isVisible:function(){
var currentShippingMethod = quote.shippingMethod().carrier_code+'_'+quote.shippingMethod().method_code;
var disallowedShippingMethods = [];
if(this.getDisallowedShipping()){
disallowedShippingMethods = this.getDisallowedShipping().split(',');
}
if(disallowedShippingMethods.includes(currentShippingMethod)){
return false;
var disallowedShippingMethods = this.getDisallowedShipping();
if (disallowedShippingMethods) {
var carrier_code = typeof quote.shippingMethod().carrier_code !== 'undefined' ? quote.shippingMethod().carrier_code + '_' : '';
var method_code = typeof quote.shippingMethod().method_code !== 'undefined' ? quote.shippingMethod().method_code : '';
var currentShippingMethod = carrier_code + method_code;
var disallowedShippingMethodsSplitted = disallowedShippingMethods.split(',');
if (disallowedShippingMethodsSplitted.includes(currentShippingMethod) && currentShippingMethod.length > 0) {
return false;
}
}
if(this.getforCompany() == 1 && this.getCompany().length != 0){
return false;
Expand All @@ -54,16 +56,16 @@ define(
},
getDisallowedShipping: function () {
return window.checkoutConfig.payment.disallowedshipping[this.item.method];
},
getCompany: function () {
},
getCompany: function () {
if (typeof quote.billingAddress._latestValue.company !== 'undefined') {
return quote.billingAddress._latestValue.company;
}
return '';
},
return '';
},
getforCompany : function () {
return window.checkoutConfig.payment.showforcompany[this.item.method];
},
},
/**
* Get payment method data
*/
Expand Down
30 changes: 16 additions & 14 deletions view/frontend/web/js/view/payment/method-renderer/default.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,15 @@ define(
template: 'Paynl_Payment/payment/default'
},
isVisible:function(){
var currentShippingMethod = quote.shippingMethod().carrier_code+'_'+quote.shippingMethod().method_code;
var disallowedShippingMethods = [];
if(this.getDisallowedShipping()){
disallowedShippingMethods = this.getDisallowedShipping().split(',');
}
if(disallowedShippingMethods.includes(currentShippingMethod)){
return false;
var disallowedShippingMethods = this.getDisallowedShipping();
if (disallowedShippingMethods) {
var carrier_code = typeof quote.shippingMethod().carrier_code !== 'undefined' ? quote.shippingMethod().carrier_code + '_' : '';
var method_code = typeof quote.shippingMethod().method_code !== 'undefined' ? quote.shippingMethod().method_code : '';
var currentShippingMethod = carrier_code + method_code;
var disallowedShippingMethodsSplitted = disallowedShippingMethods.split(',');
if (disallowedShippingMethodsSplitted.includes(currentShippingMethod) && currentShippingMethod.length > 0) {
return false;
}
}
if(this.getforCompany() == 1 && this.getCompany().length != 0){
return false;
Expand All @@ -35,27 +37,27 @@ define(
},
getDisallowedShipping: function () {
return window.checkoutConfig.payment.disallowedshipping[this.item.method];
},
getCompany: function () {
},
getCompany: function () {
if (typeof quote.billingAddress._latestValue.company !== 'undefined') {
return quote.billingAddress._latestValue.company;
}
return '';
},
return '';
},
getforCompany : function () {
return window.checkoutConfig.payment.showforcompany[this.item.method];
},
},
getInstructions: function () {
return window.checkoutConfig.payment.instructions[this.item.method];
},
getPaymentIcon: function () {
return window.checkoutConfig.payment.icon[this.item.method];
},

afterPlaceOrder: function () {
window.location.replace(url.build('/paynl/checkout/redirect?nocache='+ (new Date().getTime())));
},

});
}
);
);
30 changes: 16 additions & 14 deletions view/frontend/web/js/view/payment/method-renderer/ideal.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ define(
[
'jquery',
'Paynl_Payment/js/view/payment/method-renderer/default',
'mage/url',
'mage/url',
'Magento_Checkout/js/model/quote'
],
function ($, Component, url, quote) {
Expand All @@ -22,13 +22,15 @@ define(
return window.checkoutConfig.payment.banks[this.item.method].length > 0;
},
isVisible:function(){
var currentShippingMethod = quote.shippingMethod().carrier_code+'_'+quote.shippingMethod().method_code;
var disallowedShippingMethods = [];
if(this.getDisallowedShipping()){
disallowedShippingMethods = this.getDisallowedShipping().split(',');
}
if(disallowedShippingMethods.includes(currentShippingMethod)){
return false;
var disallowedShippingMethods = this.getDisallowedShipping();
if (disallowedShippingMethods) {
var carrier_code = typeof quote.shippingMethod().carrier_code !== 'undefined' ? quote.shippingMethod().carrier_code + '_' : '';
var method_code = typeof quote.shippingMethod().method_code !== 'undefined' ? quote.shippingMethod().method_code : '';
var currentShippingMethod = carrier_code + method_code;
var disallowedShippingMethodsSplitted = disallowedShippingMethods.split(',');
if (disallowedShippingMethodsSplitted.includes(currentShippingMethod) && currentShippingMethod.length > 0) {
return false;
}
}
if(this.getforCompany() == 1 && this.getCompany().length != 0){
return false;
Expand All @@ -40,16 +42,16 @@ define(
},
getDisallowedShipping: function () {
return window.checkoutConfig.payment.disallowedshipping[this.item.method];
},
getCompany: function () {
},
getCompany: function () {
if (typeof quote.billingAddress._latestValue.company !== 'undefined') {
return quote.billingAddress._latestValue.company;
}
return '';
},
return '';
},
getforCompany : function () {
return window.checkoutConfig.payment.showforcompany[this.item.method];
},
},
/**
* Get payment method data
*/
Expand All @@ -64,4 +66,4 @@ define(
}
});
}
);
);

0 comments on commit de1619b

Please sign in to comment.