initial docker setup

This commit is contained in:
GotPPay
2018-06-14 16:49:28 +02:00
parent bc80b7342e
commit b5f87f27f8
3023 changed files with 985078 additions and 1 deletions

View File

@@ -0,0 +1,162 @@
@font-face {
font-family: Klarna;
src: url("../fonts/KlarnaSans-Regular.otf") format("opentype");
}
@font-face {
font-family: KlarnaHeadline;
font-weight: bold;
src: url("../fonts/KlarnaHeadline-Bold.otf") format("opentype");
}
/* Banner */
#klarna-banner {
background-image: url("../img/admin-banner.jpg");
background-position: center center;
background-size: 100% auto;
padding: 30px;
margin: 0 20px 20px 0;
color: #fff;
position: relative;
}
#kb-spacer {
height: 20px;
}
#klarna-banner > div {
text-align: center;
padding: 0 60px;
-webkit-box-sizing: border-box;
-moz-box-sizing: border-box;
box-sizing: border-box;
font-family: Klarna, sans-serif;
}
#klarna-banner h1 {
font-size: 32px;
line-height: 1.2;
font-weight: bold;
color: #fff;
font-family: KlarnaHeadline, sans-serif;
margin-top: 0;
}
#klarna-banner p {
margin-bottom: 1em;
font-size: 14px;
letter-spacing: -0.2px;
}
#kb-image {
position: absolute;
right: 20px;
bottom: 20px;
z-index: 1;
}
a.kb-button {
display: inline-block;
background: #eb6f93;
color: #fff;
text-decoration: none;
padding: 0.75em 2em;
-webkit-border-radius: 0.5em;
-moz-border-radius: 0.5em;
border-radius: 0.5em;
-webkit-box-shadow: 0 0 10px rgba(0, 0, 0, 0.1);
-moz-box-shadow: 0 0 10px rgba(0, 0, 0, 0.1);
box-shadow: 0 0 10px rgba(0, 0, 0, 0.1);
}
.kb-dismiss {
position: absolute;
top: 5px;
right: 5px;
}
.kb-dismiss:hover {
color: #eb6f93;
cursor: pointer;
}
@media (min-width: 800px) {
#klarna-banner {
overflow: hidden;
}
#klarna-banner > div {
float: left;
width: 50%;
}
#klarna-banner > div > * {
margin-left: auto;
margin-right: auto;
max-width: 500px;
}
}
@media (max-width: 799px) {
#klarna-banner > div {
margin-bottom: 40px;
}
}
/* Sidebar */
@media (min-width: 880px) {
#klarna-wrapper:after {
content: '';
display: block;
clear: both;
}
#klarna-main {
width: 70%;
float: left;
padding: 0 2% 0 0;
border-right: 1px solid #ccc;
box-sizing: border-box;
}
#klarna-sidebar {
width: 28%;
max-width: 350px;
margin-left: 2%;
float: left;
box-sizing: border-box;
text-align: center;
font-family: Klarna, sans-serif;
}
}
#klarna-settings-logo {
display: block;
margin: 20px 0;
}
#klarna-sidebar h3 {
font-family: KlarnaHeadline, sans-serif;
font-size: 24px;
line-height: 1.2;
}
#klarna-sidebar p {
margin-bottom: 1.5em;
}
#klarna-sidebar img {
display: inline-block;
margin: 0 5px;
}
.kb-sidebar-section {
margin-bottom: 40px;
}
.wc-settings-sub-title a, .wc-settings-sub-title a:hover, .wc-settings-sub-title a:click, .wc-settings-sub-title a:visited, .wc-settings-sub-title a:focus {
border:none;
outline:none;
text-decoration:none;
color:black;
}

View File

@@ -0,0 +1,33 @@
#kco-wrapper {
overflow: hidden;
padding: 20px 0;
}
#kco-order-review {
margin-bottom: 50px;
}
.product-name .quantity {
display: inline-block;
}
#kco-order-review table.woocommerce-checkout-review-order-table .product-name {
width: auto;
}
@media only screen and (min-width : 769px) {
#kco-order-review {
float: left;
width: 40%;
padding-right: 20px;
font-size: 0.9em;
box-sizing: border-box;
}
#kco-iframe {
float: right;
width: 60%;
padding-left: 20px;
box-sizing: border-box;
}
}

View File

@@ -0,0 +1 @@
#kco-wrapper{overflow:hidden;padding:20px 0}#kco-order-review{margin-bottom:50px}.product-name .quantity{display:inline-block}#kco-order-review table.woocommerce-checkout-review-order-table .product-name{width:auto}@media only screen and (min-width :769px){#kco-order-review{float:left;width:40%;padding-right:20px;font-size:.9em;box-sizing:border-box}#kco-iframe{float:right;width:60%;padding-left:20px;box-sizing:border-box}}

Binary file not shown.

After

Width:  |  Height:  |  Size: 313 KiB

View File

@@ -0,0 +1,28 @@
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" height="480" width="640" viewBox="0 0 640 480">
<defs>
<g id="d">
<g id="b">
<path d="M0-1l-.31.95.477.156z" id="a"/>
<use transform="scale(-1 1)" xlink:href="#a"/>
</g>
<g id="c">
<use transform="rotate(72)" xlink:href="#b"/>
<use transform="rotate(144)" xlink:href="#b"/>
</g>
<use transform="scale(-1 1)" xlink:href="#c"/>
</g>
</defs>
<path fill="#039" d="M0 0h640v480H0z"/>
<g transform="translate(320 242.263) scale(23.7037)" fill="#fc0">
<use height="100%" width="100%" xlink:href="#d" y="-6"/>
<use height="100%" width="100%" xlink:href="#d" y="6"/>
<g id="e">
<use height="100%" width="100%" xlink:href="#d" x="-6"/>
<use height="100%" width="100%" xlink:href="#d" transform="rotate(-144 -2.344 -2.11)"/>
<use height="100%" width="100%" xlink:href="#d" transform="rotate(144 -2.11 -2.344)"/>
<use height="100%" width="100%" xlink:href="#d" transform="rotate(72 -4.663 -2.076)"/>
<use height="100%" width="100%" xlink:href="#d" transform="rotate(72 -5.076 .534)"/>
</g>
<use height="100%" width="100%" xlink:href="#e" transform="scale(-1 1)"/>
</g>
</svg>

After

Width:  |  Height:  |  Size: 1.2 KiB

View File

@@ -0,0 +1,18 @@
<svg xmlns="http://www.w3.org/2000/svg" height="480" width="640" viewBox="0 0 640 480">
<g fill-rule="evenodd" transform="scale(.9375)">
<g stroke-width="1pt">
<path d="M0 0h972.81v39.385H0zm0 78.77h972.81v39.385H0zm0 78.77h972.81v39.385H0zm0 78.77h972.81v39.385H0zm0 78.77h972.81v39.385H0zm0 78.77h972.81v39.385H0zm0 78.77h972.81v39.385H0z" fill="#bd3d44"/>
<path d="M0 39.385h972.81V78.77H0zm0 78.77h972.81v39.385H0zm0 78.77h972.81v39.385H0zm0 78.77h972.81v39.385H0zm0 78.77h972.81v39.385H0zm0 78.77h972.81v39.385H0z" fill="#fff"/>
</g>
<path fill="#192f5d" d="M0 0h389.12v275.69H0z"/>
<g fill="#fff">
<path d="M32.427 11.8l3.54 10.896h11.458l-9.27 6.735 3.541 10.896-9.27-6.734-9.268 6.734 3.54-10.896-9.269-6.735h11.457zm64.853 0l3.541 10.896h11.458l-9.27 6.735 3.541 10.896-9.27-6.734-9.268 6.734 3.54-10.896-9.269-6.735H93.74zm64.856 0l3.54 10.896h11.458l-9.27 6.735 3.541 10.896-9.269-6.734-9.269 6.734 3.54-10.896-9.269-6.735h11.458zm64.852 0l3.54 10.896h11.457l-9.269 6.735 3.54 10.896-9.268-6.734-9.27 6.734 3.541-10.896-9.27-6.735h11.458zm64.855 0l3.54 10.896h11.458l-9.27 6.735 3.541 10.896-9.27-6.734-9.268 6.734 3.54-10.896-9.269-6.735h11.457zm64.855 0l3.54 10.896h11.458l-9.27 6.735 3.541 10.896-9.269-6.734-9.27 6.734 3.542-10.896-9.27-6.735h11.458zM64.855 39.37l3.54 10.896h11.458L70.583 57l3.542 10.897-9.27-6.734-9.269 6.734L59.126 57l-9.269-6.734h11.458zm64.852 0l3.54 10.896h11.457L135.435 57l3.54 10.897-9.268-6.734-9.27 6.734L123.978 57l-9.27-6.734h11.458zm64.855 0l3.54 10.896h11.458L200.29 57l3.541 10.897-9.27-6.734-9.268 6.734L188.833 57l-9.269-6.734h11.457zm64.855 0l3.54 10.896h11.458L265.145 57l3.541 10.897-9.269-6.734-9.27 6.734L253.69 57l-9.27-6.734h11.458zm64.852 0l3.54 10.896h11.457L329.997 57l3.54 10.897-9.268-6.734-9.27 6.734L318.54 57l-9.27-6.734h11.458zM32.427 66.939l3.54 10.896h11.458l-9.27 6.735 3.541 10.896-9.27-6.734-9.268 6.734 3.54-10.896-9.269-6.735h11.457zm64.853 0l3.541 10.896h11.458l-9.27 6.735 3.541 10.896-9.27-6.734-9.268 6.734 3.54-10.896-9.269-6.735H93.74zm64.856 0l3.54 10.896h11.458l-9.27 6.735 3.541 10.896-9.269-6.734-9.269 6.734 3.54-10.896-9.269-6.735h11.458zm64.852 0l3.54 10.896h11.457l-9.269 6.735 3.54 10.896-9.268-6.734-9.27 6.734 3.541-10.896-9.27-6.735h11.458zm64.855 0l3.54 10.896h11.458l-9.27 6.735 3.541 10.896-9.27-6.734-9.268 6.734 3.54-10.896-9.269-6.735h11.457zm64.855 0l3.54 10.896h11.458l-9.27 6.735 3.541 10.896-9.269-6.734-9.27 6.734 3.542-10.896-9.27-6.735h11.458zM64.855 94.508l3.54 10.897h11.458l-9.27 6.734 3.542 10.897-9.27-6.734-9.269 6.734 3.54-10.897-9.269-6.734h11.458zm64.852 0l3.54 10.897h11.457l-9.269 6.734 3.54 10.897-9.268-6.734-9.27 6.734 3.541-10.897-9.27-6.734h11.458zm64.855 0l3.54 10.897h11.458l-9.27 6.734 3.541 10.897-9.27-6.734-9.268 6.734 3.54-10.897-9.269-6.734h11.457zm64.855 0l3.54 10.897h11.458l-9.27 6.734 3.541 10.897-9.269-6.734-9.27 6.734 3.542-10.897-9.27-6.734h11.458zm64.852 0l3.54 10.897h11.457l-9.269 6.734 3.54 10.897-9.268-6.734-9.27 6.734 3.541-10.897-9.27-6.734h11.458zM32.427 122.078l3.54 10.896h11.458l-9.27 6.735 3.541 10.896-9.27-6.734-9.268 6.734 3.54-10.896-9.269-6.735h11.457zm64.853 0l3.541 10.896h11.458l-9.27 6.735 3.541 10.896-9.27-6.734-9.268 6.734 3.54-10.896-9.269-6.735H93.74zm64.856 0l3.54 10.896h11.458l-9.27 6.735 3.541 10.896-9.269-6.734-9.269 6.734 3.54-10.896-9.269-6.735h11.458zm64.852 0l3.54 10.896h11.457l-9.269 6.735 3.54 10.896-9.268-6.734-9.27 6.734 3.541-10.896-9.27-6.735h11.458zm64.855 0l3.54 10.896h11.458l-9.27 6.735 3.541 10.896-9.27-6.734-9.268 6.734 3.54-10.896-9.269-6.735h11.457zm64.855 0l3.54 10.896h11.458l-9.27 6.735 3.541 10.896-9.269-6.734-9.27 6.734 3.542-10.896-9.27-6.735h11.458zM64.855 149.647l3.54 10.897h11.458l-9.27 6.734 3.542 10.897-9.27-6.734-9.269 6.734 3.54-10.897-9.269-6.734h11.458zm64.852 0l3.54 10.897h11.457l-9.269 6.734 3.54 10.897-9.268-6.734-9.27 6.734 3.541-10.897-9.27-6.734h11.458zm64.855 0l3.54 10.897h11.458l-9.27 6.734 3.541 10.897-9.27-6.734-9.268 6.734 3.54-10.897-9.269-6.734h11.457zm64.855 0l3.54 10.897h11.458l-9.27 6.734 3.541 10.897-9.269-6.734-9.27 6.734 3.542-10.897-9.27-6.734h11.458zm64.852 0l3.54 10.897h11.457l-9.269 6.734 3.54 10.897-9.268-6.734-9.27 6.734 3.541-10.897-9.27-6.734h11.458z"/>
<g>
<path d="M32.427 177.217l3.54 10.896h11.458l-9.27 6.735 3.541 10.896-9.27-6.734-9.268 6.734 3.54-10.896-9.269-6.735h11.457zm64.853 0l3.541 10.896h11.458l-9.27 6.735 3.541 10.896-9.27-6.734-9.268 6.734 3.54-10.896-9.269-6.735H93.74zm64.856 0l3.54 10.896h11.458l-9.27 6.735 3.541 10.896-9.269-6.734-9.269 6.734 3.54-10.896-9.269-6.735h11.458zm64.852 0l3.54 10.896h11.457l-9.269 6.735 3.54 10.896-9.268-6.734-9.27 6.734 3.541-10.896-9.27-6.735h11.458zm64.855 0l3.54 10.896h11.458l-9.27 6.735 3.541 10.896-9.27-6.734-9.268 6.734 3.54-10.896-9.269-6.735h11.457zm64.855 0l3.54 10.896h11.458l-9.27 6.735 3.541 10.896-9.269-6.734-9.27 6.734 3.542-10.896-9.27-6.735h11.458zM64.855 204.786l3.54 10.897h11.458l-9.27 6.734 3.542 10.897-9.27-6.734-9.269 6.734 3.54-10.897-9.269-6.734h11.458zm64.852 0l3.54 10.897h11.457l-9.269 6.734 3.54 10.897-9.268-6.734-9.27 6.734 3.541-10.897-9.27-6.734h11.458zm64.855 0l3.54 10.897h11.458l-9.27 6.734 3.541 10.897-9.27-6.734-9.268 6.734 3.54-10.897-9.269-6.734h11.457zm64.855 0l3.54 10.897h11.458l-9.27 6.734 3.541 10.897-9.269-6.734-9.27 6.734 3.542-10.897-9.27-6.734h11.458zm64.852 0l3.54 10.897h11.457l-9.269 6.734 3.54 10.897-9.268-6.734-9.27 6.734 3.541-10.897-9.27-6.734h11.458z"/>
</g>
<g>
<path d="M32.427 232.356l3.54 10.896h11.458l-9.27 6.735 3.541 10.896-9.27-6.734-9.268 6.734 3.54-10.896-9.269-6.735h11.457zm64.853 0l3.541 10.896h11.458l-9.27 6.735 3.541 10.896-9.27-6.734-9.268 6.734 3.54-10.896-9.269-6.735H93.74zm64.856 0l3.54 10.896h11.458l-9.27 6.735 3.541 10.896-9.269-6.734-9.269 6.734 3.54-10.896-9.269-6.735h11.458zm64.852 0l3.54 10.896h11.457l-9.269 6.735 3.54 10.896-9.268-6.734-9.27 6.734 3.541-10.896-9.27-6.735h11.458zm64.855 0l3.54 10.896h11.458l-9.27 6.735 3.541 10.896-9.27-6.734-9.268 6.734 3.54-10.896-9.269-6.735h11.457zm64.855 0l3.54 10.896h11.458l-9.27 6.735 3.541 10.896-9.269-6.734-9.27 6.734 3.542-10.896-9.27-6.735h11.458z"/>
</g>
</g>
</g>
</svg>

After

Width:  |  Height:  |  Size: 6.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 12 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 36 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 87 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 90 KiB

View File

@@ -0,0 +1,42 @@
jQuery( function($) {
'use strict';
var location = kco_admin_params.location;
var titles = $('h3.wc-settings-sub-title');
var tables = $('h3.wc-settings-sub-title + table.form-table');
var submit = $('.wrap.woocommerce p.submit');
titles.append(' <a href="#" style="font-size:12px; font-weight: normal; text-decoration: none"><span class="dashicons dashicons-arrow-down-alt2"></span></a>');
tables.css('marginLeft', '20px').hide();
if(location === 'EU') {
var title = $('#woocommerce_kco_credentials_eu');
$('#woocommerce_kco_credentials_us').find('a').addClass('collapsed');
title.find('a').html('<span class="dashicons dashicons-arrow-up-alt2">');
title.next().show();
} else if( location === 'US') {
var title = $('#woocommerce_kco_credentials_us');
$('#woocommerce_kco_credentials_eu').find('a').addClass('collapsed');
title.find('a').html('<span class="dashicons dashicons-arrow-up-alt2">');
title.next().show();
} else {
var title = titles;
}
$('#woocommerce_kco_color_settings_title').find('a').addClass('collapsed');
titles.find('a').click(function(e) {
e.preventDefault();
if ($(this).hasClass('collapsed')) {
$(this).parent().next().show();
$(this).removeClass('collapsed');
$(this).html('<span class="dashicons dashicons-arrow-up-alt2"></span>');
} else {
$(this).parent().next().hide();
$(this).addClass('collapsed');
$(this).html('<span class="dashicons dashicons-arrow-down-alt2"></span>');
}
});
titles.before('<hr style="margin-top:2em;margin-bottom:2em" />');
submit.before('<hr style="margin-top:2em;margin-bottom:2em" />');
});

View File

@@ -0,0 +1 @@
jQuery(function(e){"use strict";var t=e("h3.wc-settings-sub-title"),s=e("h3.wc-settings-sub-title + table.form-table"),a=e(".wrap.woocommerce p.submit");t.append(' <a href="#" style="font-size:12px; font-weight: normal; text-decoration: none">[expand]</a>'),s.css("marginLeft","20px").hide(),t.find("a").addClass("collapsed"),t.find("a").click(function(t){t.preventDefault(),e(this).hasClass("collapsed")?(e(this).parent().next().show(),e(this).removeClass("collapsed"),e(this).text("[collapse]")):(e(this).parent().next().hide(),e(this).addClass("collapsed"),e(this).text("[expand]"))}),t.before('<hr style="margin-top:2em;margin-bottom:2em" />'),a.before('<hr style="margin-top:2em;margin-bottom:2em" />')});

View File

@@ -0,0 +1,395 @@
/* global kco_params */
jQuery(function($) {
// Check if we have params.
if ( typeof kco_params === 'undefined' ) {
return false;
}
var kco_wc = {
bodyEl: $('body'),
checkoutFormSelector: 'form.checkout',
// Order notes
orderNotesValue: '',
orderNotesSelector: 'textarea#order_comments',
orderNotesEl: $('textarea#order_comments'),
// Order notes
extraFieldsValues: {},
extraFieldsSelectorText: 'div#kco-extra-fields input[type="text"], div#kco-extra-fields input[type="password"], div#kco-extra-fields textarea',
extraFieldsSelectorNonText: 'div#kco-extra-fields select, div#kco-extra-fields input[type="radio"], div#kco-extra-fields input[type="checkbox"], div#kco-extra-fields input.checkout-date-picker, input#terms input[type="checkbox"]',
// Payment method
paymentMethodEl: $('input[name="payment_method"]'),
paymentMethod: '',
selectAnotherSelector: '#klarna-checkout-select-other',
// Form fields
formFields: [],
documentReady: function() {
kco_wc.log(kco_params);
kco_wc.setFormData();
if (kco_wc.paymentMethodEl.length > 0) {
kco_wc.paymentMethod = kco_wc.paymentMethodEl.filter(':checked').val();
} else {
kco_wc.paymentMethod = 'kco';
}
kco_wc.confirmLoading();
},
kcoSuspend: function () {
if (window._klarnaCheckout) {
window._klarnaCheckout(function (api) {
api.suspend();
});
}
},
kcoResume: function () {
if (window._klarnaCheckout) {
window._klarnaCheckout(function (api) {
api.resume();
});
}
},
confirmLoading: function () {
$('#kco-confirm-loading')
.css('minHeight', '300px')
.block({
message: null,
overlayCSS: {
background: '#fff',
opacity: 0.6
}
});
},
updateCart: function () {
kco_wc.kcoSuspend();
$.ajax({
type: 'POST',
url: kco_params.update_cart_url,
data: {
checkout: $('form.checkout').serialize(),
nonce: kco_params.update_cart_nonce
},
dataType: 'json',
success: function(data) {
},
error: function(data) {
},
complete: function(data) {
$('body').trigger('update_checkout');
kco_wc.kcoResume();
}
});
},
updateExtraFields: function() {
var elementName = $(this).attr('name');
if( elementName === 'terms' ) {
var updatedValue = ( $("input#terms:checked").length === 1 ) ? 1 : '';
} else {
var updatedValue = $(this).val();
}
kco_wc.log('value');
kco_wc.log(updatedValue);
kco_wc.log('name');
kco_wc.log(elementName);
kco_wc.log(typeof kco_wc.extraFieldsValues);
kco_wc.log(kco_wc.extraFieldsValues);
if (null === kco_wc.extraFieldsValues && '' === updatedValue) {
return;
}
if (null !== kco_wc.extraFieldsValues && elementName in kco_wc.extraFieldsValues && updatedValue === kco_wc.extraFieldsValues) {
return;
}
if (null === kco_wc.extraFieldsValues) {
kco_wc.extraFieldsValues = {};
}
kco_wc.log('update');
kco_wc.extraFieldsValues[elementName] = updatedValue;
$.ajax({
type: 'POST',
url: kco_params.update_extra_fields_url,
data: {
extra_fields_values: kco_wc.extraFieldsValues,
nonce: kco_params.update_extra_fields_nonce
},
success: function (data) {},
error: function (data) {},
complete: function (data) {
kco_wc.log('complete', data);
}
});
},
updateOrderNotes: function() {
if (kco_wc.orderNotesEl.val() !== kco_wc.orderNotesValue) {
kco_wc.orderNotesValue = kco_wc.orderNotesEl.val();
$.ajax({
type: 'POST',
url: kco_params.update_order_notes_url,
data: {
order_notes: kco_wc.orderNotesValue,
nonce: kco_params.update_order_notes_nonce
},
success: function (data) {},
error: function (data) {},
complete: function (data) {
kco_wc.log('complete', data);
}
});
}
},
updateKlarnaOrder: function() {
if ('kco' === kco_wc.paymentMethod) {
$.ajax({
type: 'POST',
url: kco_params.update_klarna_order_url,
data: {
nonce: kco_params.update_klarna_order_nonce
},
dataType: 'json',
success: function(data) {
},
error: function(data) {
},
complete: function(data) {
kco_wc.kcoResume();
}
});
}
},
// When "Change to another payment method" is clicked.
changeFromKco: function(e) {
e.preventDefault();
$(kco_wc.checkoutFormSelector).block({
message: null,
overlayCSS: {
background: '#fff',
opacity: 0.6
}
});
$.ajax({
type: 'POST',
dataType: 'json',
data: {
kco: false,
nonce: kco_params.change_payment_method_nonce
},
url: kco_params.change_payment_method_url,
success: function (data) {},
error: function (data) {},
complete: function (data) {
kco_wc.log(data.responseJSON);
window.location.href = data.responseJSON.data.redirect;
}
});
},
// When payment method is changed to KCO in regular WC Checkout page.
maybeChangeToKco: function() {
kco_wc.log($(this).val());
if ( 'kco' === $(this).val() ) {
$('.woocommerce-info').remove();
$(kco_wc.checkoutFormSelector).block({
message: null,
overlayCSS: {
background: '#fff',
opacity: 0.6
}
});
$.ajax({
type: 'POST',
data: {
kco: true,
nonce: kco_params.change_payment_method_nonce
},
dataType: 'json',
url: kco_params.change_payment_method_url,
success: function (data) {},
error: function (data) {},
complete: function (data) {
kco_wc.log(data.responseJSON);
window.location.href = data.responseJSON.data.redirect;
}
});
}
},
checkoutError: function() {
if ('kco' === kco_wc.paymentMethod) {
var error_message = $( ".woocommerce-NoticeGroup-checkout" ).text();
$.ajax({
type: 'POST',
dataType: 'json',
data: {
kco: false,
error_message: error_message,
nonce: kco_params.checkout_error_nonce
},
url: kco_params.checkout_error_url,
success: function (data) {
},
error: function (data) {
},
complete: function (data) {
kco_wc.log(data.responseJSON);
window.location.href = data.responseJSON.data.redirect;
}
});
}
},
log: function(message) {
if (kco_params.logging) {
console.log(message);
}
},
setFormData: function() {
var form = $('form[name="checkout"] input');
var i;
var newForm = [];
for ( i = 0; i < form.length; i++ ) {
if ( form[i]['name'] !== '' ) {
var name = form[i]['name'];
var field = $('*[name="' + name + '"]');
var id = field.attr('id');
var label = $('label[for="' + id + '"]');
var check = ( label.has( "abbr" ).length ? true : ( id === 'terms' ) ? true : false );
if ( check === true ) {
var value = ( ! field.is(':checkbox') ) ? form[i].value : ( field.is(":checked") ) ? form[i].value : '';
if( form[i].name === 'terms' ) {
value = ( $("input#terms:checked").length === 1 ) ? 1 : '';
}
newForm.push({
name: form[i].name,
value: value,
required: true
});
}
}
}
kco_wc.formFields = newForm;
kco_wc.saveFormData();
},
saveFormData: function() {
$.ajax({
type: 'POST',
url: kco_params.save_form_data,
data: {
form: kco_wc.formFields,
nonce: kco_params.save_form_data_nonce
},
dataType: 'json',
success: function(data) {
},
error: function(data) {
},
complete: function(data) {
}
});
},
init: function () {
$(document).ready(kco_wc.documentReady);
kco_wc.bodyEl.on('update_checkout', kco_wc.kcoSuspend);
kco_wc.bodyEl.on('updated_checkout', kco_wc.updateKlarnaOrder);
kco_wc.bodyEl.on('checkout_error', kco_wc.checkoutError);
kco_wc.bodyEl.on('change', 'input.qty', kco_wc.updateCart);
kco_wc.bodyEl.on('blur', kco_wc.extraFieldsSelectorText, kco_wc.setFormData);
kco_wc.bodyEl.on('change', kco_wc.extraFieldsSelectorNonText, kco_wc.setFormData);
kco_wc.bodyEl.on('blur', kco_wc.extraFieldsSelectorText, kco_wc.updateExtraFields);
kco_wc.bodyEl.on('change', kco_wc.extraFieldsSelectorNonText, kco_wc.updateExtraFields);
kco_wc.bodyEl.on('change', 'input[name="payment_method"]', kco_wc.maybeChangeToKco);
kco_wc.bodyEl.on('click', kco_wc.selectAnotherSelector, kco_wc.changeFromKco);
kco_wc.bodyEl.on('click', 'input#terms', kco_wc.setFormData)
kco_wc.bodyEl.on('click', 'input#terms', kco_wc.updateExtraFields)
if (typeof window._klarnaCheckout === 'function') {
window._klarnaCheckout(function (api) {
api.on({
'shipping_address_change': function(data) {
kco_wc.log('shipping_address_change');
kco_wc.log(data);
$('.woocommerce-checkout-review-order-table').block({
message: null,
overlayCSS: {
background: '#fff',
opacity: 0.6
}
});
kco_wc.kcoSuspend();
$.ajax(
{
url: kco_params.iframe_shipping_address_change_url,
type: 'POST',
dataType: 'json',
data: {
data: data,
nonce: kco_params.iframe_shipping_address_change_nonce
},
success: function (response) {
kco_wc.log(response);
$('.woocommerce-checkout-review-order-table').replaceWith(response.data.html);
},
error: function (response) {
kco_wc.log(response);
},
complete: function() {
$('.woocommerce-checkout-review-order-table').unblock();
kco_wc.kcoResume();
}
}
);
},
'change': function(data) {
kco_wc.log('change', data);
},
'order_total_change': function(data) {
kco_wc.log('order_total_change', data);
},
'shipping_option_change': function(data) {
kco_wc.log('shipping_option_change', data);
},
'can_not_complete_order': function(data) {
kco_wc.log('can_not_complete_order', data);
}
});
});
}
}
};
kco_wc.init();
$('body').on('blur', kco_wc.setFormData );
$(document).on("keypress", "#kco-order-review", function(event) {
if (event.keyCode == 13) {
event.preventDefault();
}
});
});

File diff suppressed because one or more lines are too long