Changeset 2903962
- Timestamp:
- 04/25/2023 02:07:27 PM (3 years ago)
- Location:
- sprinque
- Files:
-
- 58 added
- 34 edited
- 1 copied
-
tags/1.3.0 (copied) (copied from sprinque/trunk)
-
tags/1.3.0/assets/css/frontend.css (modified) (14 diffs)
-
tags/1.3.0/assets/css/frontend.css.map (added)
-
tags/1.3.0/assets/css/frontend.scss (modified) (8 diffs)
-
tags/1.3.0/assets/js/frontend.js (modified) (13 diffs)
-
tags/1.3.0/include/payment_method.php (modified) (11 diffs)
-
tags/1.3.0/languages/sprinque-de_DE.mo (modified) (previous)
-
tags/1.3.0/languages/sprinque-de_DE.po (modified) (6 diffs)
-
tags/1.3.0/languages/sprinque-en_US.mo (modified) (previous)
-
tags/1.3.0/languages/sprinque-en_US.po (modified) (2 diffs)
-
tags/1.3.0/languages/sprinque-es_ES.mo (modified) (previous)
-
tags/1.3.0/languages/sprinque-es_ES.po (modified) (6 diffs)
-
tags/1.3.0/languages/sprinque-fr_FR.mo (modified) (previous)
-
tags/1.3.0/languages/sprinque-fr_FR.po (modified) (6 diffs)
-
tags/1.3.0/languages/sprinque-nl_NL.mo (modified) (previous)
-
tags/1.3.0/languages/sprinque-nl_NL.po (modified) (6 diffs)
-
tags/1.3.0/node_modules (added)
-
tags/1.3.0/node_modules/.package-lock.json (added)
-
tags/1.3.0/node_modules/b2b-sprinque-tools (added)
-
tags/1.3.0/node_modules/b2b-sprinque-tools/README.md (added)
-
tags/1.3.0/node_modules/b2b-sprinque-tools/dist (added)
-
tags/1.3.0/node_modules/b2b-sprinque-tools/dist/index.d.ts (added)
-
tags/1.3.0/node_modules/b2b-sprinque-tools/dist/index.es.js (added)
-
tags/1.3.0/node_modules/b2b-sprinque-tools/dist/index.js (added)
-
tags/1.3.0/node_modules/b2b-sprinque-tools/dist/index.umd.min.js (added)
-
tags/1.3.0/node_modules/b2b-sprinque-tools/dist/src (added)
-
tags/1.3.0/node_modules/b2b-sprinque-tools/dist/src/languages (added)
-
tags/1.3.0/node_modules/b2b-sprinque-tools/dist/src/languages/de.json (added)
-
tags/1.3.0/node_modules/b2b-sprinque-tools/dist/src/languages/en.json (added)
-
tags/1.3.0/node_modules/b2b-sprinque-tools/dist/src/languages/es.json (added)
-
tags/1.3.0/node_modules/b2b-sprinque-tools/dist/src/languages/fr.json (added)
-
tags/1.3.0/node_modules/b2b-sprinque-tools/dist/src/languages/index.d.ts (added)
-
tags/1.3.0/node_modules/b2b-sprinque-tools/dist/src/languages/index.js (added)
-
tags/1.3.0/node_modules/b2b-sprinque-tools/dist/src/languages/nl.json (added)
-
tags/1.3.0/node_modules/b2b-sprinque-tools/dist/src/registration-number (added)
-
tags/1.3.0/node_modules/b2b-sprinque-tools/dist/src/registration-number/helpers.d.ts (added)
-
tags/1.3.0/node_modules/b2b-sprinque-tools/dist/src/registration-number/helpers.js (added)
-
tags/1.3.0/node_modules/b2b-sprinque-tools/dist/src/registration-number/index.d.ts (added)
-
tags/1.3.0/node_modules/b2b-sprinque-tools/dist/src/registration-number/index.js (added)
-
tags/1.3.0/node_modules/b2b-sprinque-tools/dist/src/registration-number/index.test.d.ts (added)
-
tags/1.3.0/node_modules/b2b-sprinque-tools/dist/src/registration-number/index.test.js (added)
-
tags/1.3.0/node_modules/b2b-sprinque-tools/package.json (added)
-
tags/1.3.0/package-lock.json (added)
-
tags/1.3.0/package.json (added)
-
tags/1.3.0/readme.txt (modified) (2 diffs)
-
tags/1.3.0/sprinque.php (modified) (8 diffs)
-
tags/1.3.0/templates/frontend/srinque_pay_modal_form.php (modified) (2 diffs)
-
trunk/assets/css/frontend.css (modified) (14 diffs)
-
trunk/assets/css/frontend.css.map (added)
-
trunk/assets/css/frontend.scss (modified) (8 diffs)
-
trunk/assets/js/frontend.js (modified) (13 diffs)
-
trunk/include/payment_method.php (modified) (11 diffs)
-
trunk/languages/sprinque-de_DE.mo (modified) (previous)
-
trunk/languages/sprinque-de_DE.po (modified) (6 diffs)
-
trunk/languages/sprinque-en_US.mo (modified) (previous)
-
trunk/languages/sprinque-en_US.po (modified) (2 diffs)
-
trunk/languages/sprinque-es_ES.mo (modified) (previous)
-
trunk/languages/sprinque-es_ES.po (modified) (6 diffs)
-
trunk/languages/sprinque-fr_FR.mo (modified) (previous)
-
trunk/languages/sprinque-fr_FR.po (modified) (6 diffs)
-
trunk/languages/sprinque-nl_NL.mo (modified) (previous)
-
trunk/languages/sprinque-nl_NL.po (modified) (6 diffs)
-
trunk/node_modules (added)
-
trunk/node_modules/.package-lock.json (added)
-
trunk/node_modules/b2b-sprinque-tools (added)
-
trunk/node_modules/b2b-sprinque-tools/README.md (added)
-
trunk/node_modules/b2b-sprinque-tools/dist (added)
-
trunk/node_modules/b2b-sprinque-tools/dist/index.d.ts (added)
-
trunk/node_modules/b2b-sprinque-tools/dist/index.es.js (added)
-
trunk/node_modules/b2b-sprinque-tools/dist/index.js (added)
-
trunk/node_modules/b2b-sprinque-tools/dist/index.umd.min.js (added)
-
trunk/node_modules/b2b-sprinque-tools/dist/src (added)
-
trunk/node_modules/b2b-sprinque-tools/dist/src/languages (added)
-
trunk/node_modules/b2b-sprinque-tools/dist/src/languages/de.json (added)
-
trunk/node_modules/b2b-sprinque-tools/dist/src/languages/en.json (added)
-
trunk/node_modules/b2b-sprinque-tools/dist/src/languages/es.json (added)
-
trunk/node_modules/b2b-sprinque-tools/dist/src/languages/fr.json (added)
-
trunk/node_modules/b2b-sprinque-tools/dist/src/languages/index.d.ts (added)
-
trunk/node_modules/b2b-sprinque-tools/dist/src/languages/index.js (added)
-
trunk/node_modules/b2b-sprinque-tools/dist/src/languages/nl.json (added)
-
trunk/node_modules/b2b-sprinque-tools/dist/src/registration-number (added)
-
trunk/node_modules/b2b-sprinque-tools/dist/src/registration-number/helpers.d.ts (added)
-
trunk/node_modules/b2b-sprinque-tools/dist/src/registration-number/helpers.js (added)
-
trunk/node_modules/b2b-sprinque-tools/dist/src/registration-number/index.d.ts (added)
-
trunk/node_modules/b2b-sprinque-tools/dist/src/registration-number/index.js (added)
-
trunk/node_modules/b2b-sprinque-tools/dist/src/registration-number/index.test.d.ts (added)
-
trunk/node_modules/b2b-sprinque-tools/dist/src/registration-number/index.test.js (added)
-
trunk/node_modules/b2b-sprinque-tools/package.json (added)
-
trunk/package-lock.json (added)
-
trunk/package.json (added)
-
trunk/readme.txt (modified) (2 diffs)
-
trunk/sprinque.php (modified) (8 diffs)
-
trunk/templates/frontend/srinque_pay_modal_form.php (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
sprinque/tags/1.3.0/assets/css/frontend.css
r2863342 r2903962 8 8 } 9 9 } 10 #register-company-tab , #register-company-tab-2{10 #register-company-tab { 11 11 cursor: pointer; 12 color: rgb(52, 58, 235);12 color: #000339; 13 13 text-decoration: none; 14 14 } … … 29 29 cursor: default !important; 30 30 background: rgb(255, 255, 255); 31 border: 1px solid rgb(52, 58, 235);31 border: 1px solid #000339; 32 32 box-shadow: rgba(217, 219, 242, 0.5) 0px 4px 8px; 33 33 border-radius: 8px; … … 100 100 padding-right: 10px; 101 101 } 102 } 103 104 .wpm-modal-form-tab__terms .wpm-terms-row { 105 display: flex; 106 align-items: center; 107 box-sizing: border-box; 108 border: 1px solid #e2e4f9; 109 border-radius: 3px; 110 padding: 17px 7px; 111 color: #1f2355; 112 margin-top: 16px; 113 } 114 .wpm-modal-form-tab__terms .wpm-terms-row.total { 115 font-weight: bold; 116 border: none; 117 padding-bottom: 0; 118 } 119 .wpm-modal-form-tab__terms .wpm-terms-row.active { 120 border-color: #00023c; 121 } 122 .wpm-modal-form-tab__terms .wpm-terms-row .value { 123 margin-left: auto; 124 } 125 .wpm-modal-form-tab__terms .wpm-terms-row input[type=radio] { 126 display: none; 127 } 128 .wpm-modal-form-tab__terms .wpm-terms-row input[type=radio]:checked + .input-placeholder { 129 background-color: #00023c; 130 border-color: #00023c; 131 background-image: url("../img/checkmark.png"); 132 background-position: center center; 133 background-repeat: no-repeat; 134 } 135 .wpm-modal-form-tab__terms .wpm-terms-row .input-placeholder { 136 width: 20px; 137 height: 20px; 138 border-radius: 20px; 139 border: 2px solid #D9DBF2; 140 margin-right: 9px; 102 141 } 103 142 … … 424 463 .wpm-modal-form-tab__dsc a { 425 464 text-decoration: none !important; 426 color: rgb(52, 58, 235);465 color: #000339; 427 466 } 428 467 .wpm-modal-form-tab__note { … … 488 527 .field-group input:not([type=submit]):focus { 489 528 outline: none !important; 529 } 530 .field-group .field-warning { 531 margin-top: 8px; 532 box-sizing: border-box; 533 color: rgb(40, 43, 93); 534 border-radius: 8px; 535 display: none; 536 font-size: 14px; 490 537 } 491 538 … … 504 551 appearance: none; 505 552 text-decoration: none; 506 font-weight: 500 !important;507 font-size: 1 4px;553 font-weight: 600 !important; 554 font-size: 16px; 508 555 letter-spacing: 0.02857em; 509 556 min-width: 64px; 510 557 transition: background-color 250ms cubic-bezier(0.4, 0, 0.2, 1) 0ms, box-shadow 250ms cubic-bezier(0.4, 0, 0.2, 1) 0ms, border-color 250ms cubic-bezier(0.4, 0, 0.2, 1) 0ms, color 250ms cubic-bezier(0.4, 0, 0.2, 1) 0ms; 511 padding: 3px 16px;558 padding: 12px 16px; 512 559 width: auto; 513 height: 4 0px;560 height: 48px; 514 561 border: 2px solid transparent !important; 515 562 box-shadow: none; 516 color: rgb(52, 58, 235);517 border-radius: 8px;563 color: #000339; 564 border-radius: 4px; 518 565 text-transform: none; 519 566 } … … 526 573 } 527 574 #wpm-modal-form .wpm-btn_primary { 528 background: rgb(52, 58, 235)!important;575 background: #000339 !important; 529 576 color: rgb(255, 255, 255) !important; 530 577 } 531 578 #wpm-modal-form .wpm-btn_primary:hover { 532 background: rgb(52, 58, 235)!important;579 background: #000339 !important; 533 580 box-shadow: rgba(0, 0, 0, 0.2) 0px 2px 4px -1px, rgba(0, 0, 0, 0.14) 0px 4px 5px 0px, rgba(0, 0, 0, 0.12) 0px 1px 10px 0px !important; 534 581 border-color: transparent !important; … … 537 584 font-weight: 600 !important; 538 585 background: transparent !important; 539 color: rgb(52, 58, 235)!important;540 border-color: rgb(52, 58, 235)!important;586 color: #000339 !important; 587 border-color: #000339 !important; 541 588 } 542 589 #wpm-modal-form .wpm-btn_outline-primary:hover { 543 background: rgb(52, 58, 235)!important;590 background: #000339 !important; 544 591 color: #fff !important; 545 592 } 546 593 #wpm-modal-form .wpm-btn:disabled { 547 color: rgba(0, 0, 0, 0.26)!important;594 color: #ffffff !important; 548 595 box-shadow: none !important; 549 background-color: rgba(0, 0, 0, 0.12)!important;596 background-color: #D9DBF2 !important; 550 597 pointer-events: none !important; 551 598 cursor: default !important; … … 687 734 vertical-align: middle; 688 735 animation: spinAround 0.5s infinite linear; 689 border: 3px solid rgb(52, 58, 235);736 border: 3px solid #000339; 690 737 margin-right: 8px; 691 738 border-radius: 290486px; … … 723 770 width: calc(20% - 10px) !important; 724 771 font-size: 38px !important; 725 color: rgb(52, 58, 235);772 color: #000339; 726 773 font-weight: 500 !important; 727 774 text-align: center !important; … … 735 782 border-radius: 50%; 736 783 animation: spinAround 0.5s infinite linear; 737 border: 4px solid rgb(52, 58, 235);784 border: 4px solid #000339; 738 785 border-right-color: transparent; 739 786 border-top-color: transparent; … … 756 803 } 757 804 758 .register-company-tab, .error-confirm-order a , #register-company-tab-2{805 .register-company-tab, .error-confirm-order a { 759 806 color: blue; 760 807 cursor: pointer; … … 762 809 } 763 810 764 .register-company-tab:hover , #register-company-tab-2:hover{811 .register-company-tab:hover { 765 812 text-decoration: none; 766 813 } … … 790 837 padding: 0 5px; 791 838 } 839 840 .purchase_approved .wpm-modal-form-tab__dsc { 841 text-align: center; 842 } 843 .purchase_approved .approved-days { 844 font-size: 20px; 845 font-weight: 600; 846 margin-top: 10px; 847 } 848 849 /*# sourceMappingURL=frontend.css.map */ -
sprinque/tags/1.3.0/assets/css/frontend.scss
r2863342 r2903962 1 1 @keyframes spinAround{from{transform:rotate(0)}to{transform:rotate(359deg)}} 2 $primary_color: rgb(52, 58, 235); 3 4 #register-company-tab, #register-company-tab-2 { 2 //$primary_color: rgb(52, 58, 235); 3 $primary_color: #000339; 4 5 #register-company-tab { 5 6 cursor: pointer; 6 7 color: $primary_color; … … 115 116 &::-moz-placeholder { @content; } 116 117 &:-ms-input-placeholder { @content; } 118 } 119 120 .wpm-modal-form-tab__terms { 121 .wpm-terms-row { 122 display: flex; 123 align-items: center; 124 box-sizing: border-box; 125 border: 1px solid #e2e4f9; 126 border-radius: 3px; 127 padding: 17px 7px; 128 color: #1f2355; 129 margin-top: 16px; 130 131 &.total { 132 font-weight: bold; 133 border: none; 134 padding-bottom: 0; 135 } 136 137 &.active { 138 border-color: #00023c; 139 } 140 141 .value { 142 margin-left: auto; 143 } 144 145 input[type="radio"] { 146 display: none; 147 148 &:checked + .input-placeholder { 149 background-color: #00023c; 150 border-color: #00023c; 151 background-image: url('../img/checkmark.png'); 152 background-position: center center; 153 background-repeat: no-repeat; 154 } 155 } 156 157 .input-placeholder { 158 width: 20px; 159 height: 20px; 160 border-radius: 20px; 161 border: 2px solid #D9DBF2; 162 margin-right: 9px; 163 } 164 } 117 165 } 118 166 … … 534 582 outline: none !important; 535 583 } 584 } 585 586 .field-warning { 587 margin-top: 8px; 588 box-sizing: border-box; 589 color: rgb(40, 43, 93); 590 border-radius: 8px; 591 display: none; 592 font-size: 14px; 536 593 } 537 594 } … … 673 730 appearance: none; 674 731 text-decoration: none; 675 font-weight: 500 !important;676 font-size: 1 4px;732 font-weight: 600 !important; 733 font-size: 16px; 677 734 letter-spacing: 0.02857em; 678 735 min-width: 64px; 679 736 transition: background-color 250ms cubic-bezier(0.4, 0, 0.2, 1) 0ms, box-shadow 250ms cubic-bezier(0.4, 0, 0.2, 1) 0ms, border-color 250ms cubic-bezier(0.4, 0, 0.2, 1) 0ms, color 250ms cubic-bezier(0.4, 0, 0.2, 1) 0ms; 680 padding: 3px 16px;737 padding: 12px 16px; 681 738 width: auto; 682 height: 4 0px;739 height: 48px; 683 740 border: 2px solid transparent !important; 684 741 box-shadow: none; 685 742 color: $primary_color; 686 743 687 border-radius: 8px;744 border-radius: 4px; 688 745 text-transform: none; 689 746 @media screen and (max-width: 575.98px) { … … 712 769 } 713 770 &:disabled { 714 color: rgba(0, 0, 0, 0.26)!important;771 color: #ffffff !important; 715 772 box-shadow: none !important; 716 background-color: rgba(0, 0, 0, 0.12)!important;773 background-color: #D9DBF2 !important; 717 774 pointer-events: none !important; 718 775 cursor: default !important; … … 967 1024 } 968 1025 969 .register-company-tab, .error-confirm-order a , #register-company-tab-2{1026 .register-company-tab, .error-confirm-order a { 970 1027 color: blue; 971 1028 cursor: pointer; … … 973 1030 } 974 1031 975 .register-company-tab:hover , #register-company-tab-2:hover{1032 .register-company-tab:hover { 976 1033 text-decoration: none; 977 1034 } … … 1001 1058 padding: 0 5px; 1002 1059 } 1060 1061 .purchase_approved { 1062 .wpm-modal-form-tab__dsc { 1063 text-align: center; 1064 } 1065 1066 .approved-days { 1067 font-size: 20px; 1068 font-weight: 600; 1069 margin-top: 10px; 1070 } 1071 } -
sprinque/tags/1.3.0/assets/js/frontend.js
r2873134 r2903962 5 5 6 6 var countries = []; 7 8 function PaymentTermSelect() { 9 this.payment_terms = window.admin.payment_terms; 10 this.amount = 0; 11 this.selected_fee = 0; 12 this.selected_term = null; 13 this.eligible_payment_terms = []; 14 15 if (typeof this.payment_terms === "undefined") { 16 this.payment_terms = {}; 17 } 18 } 19 20 PaymentTermSelect.prototype = { 21 setEligiblePaymentTerms(paymentTerms) { 22 this.eligible_payment_terms = paymentTerms; 23 }, 24 setAmount(amount) { 25 this.amount = amount; 26 this.recalculateTotal(); 27 }, 28 setSelected(term) { 29 if (typeof this.payment_terms[term] === "undefined") { 30 return ; 31 } 32 33 this.selected_fee = this.payment_terms[term]; 34 this.selected_term = term.toUpperCase(); 35 36 this.recalculateTotal(); 37 }, 38 getPaymentTerm() { 39 return this.selected_term; 40 }, 41 42 update() { 43 for (let key in this.payment_terms) { 44 const keyUpper = key.toUpperCase(); 45 if (this.eligible_payment_terms.indexOf(keyUpper) > -1) { 46 const availableTermUpperCase = this.eligible_payment_terms[keyUpper]; 47 const fee = this.payment_terms[key]; 48 const days = key.replace('net', ''); 49 50 if (typeof fee === "undefined") { 51 continue; 52 } 53 54 $('.wpm-modal-form-tab__terms').append(` 55 <label class="wpm-terms-row"> 56 <input type="radio" name="wpm_net_term" value="${availableTermUpperCase}" data-fee="${fee}" data-term="${key}" /> 57 <div class="input-placeholder"></div> 58 <div class="label">Net ${days} ${window.admin.days}</div> 59 <div class="value">${this.calculateWithFee(fee)}</div> 60 </label> 61 `); 62 } 63 } 64 }, 65 66 calculateWithFee(fee) { 67 const calculatedFee = ( this.amount * (Number(fee) / 100.0) ); 68 69 if (calculatedFee === 0.0) { 70 return 'Free'; 71 } 72 73 return '€' + calculatedFee.toFixed(2); 74 }, 75 recalculateTotal() { 76 const fee = 1.0 + (Number(this.selected_fee) / 100.0); 77 const totalWithFee = this.amount * fee; 78 79 jQuery('.wpm-terms-row.total .value').text('€' + totalWithFee.toFixed(2)); 80 } 81 }; 82 83 const selectPaymentTerm = new PaymentTermSelect(); 7 84 8 85 if ($('#wpm-modal-form').length) { … … 12 89 var modal = $(this).attr('data-wpm-close'); 13 90 hidePopup(modal); 91 }); 92 93 $('body').on('change', '.wpm-terms-row input[type="radio"]', function () { 94 const terms = jQuery(this).closest('.wpm-modal-form-tab__terms'); 95 jQuery('.active', terms).removeClass('active'); 96 jQuery(this).closest('.wpm-terms-row').addClass('active'); 97 jQuery('.confirm-order-term').removeAttr('disabled'); 98 99 recalculateTotal(); 100 }); 101 102 $('body').on('click', '.confirm-order-term', function () { 103 $(this).attr('disabled', 'disabled'); 104 105 authorize_company_payment(function () { 106 $('.choose_another_payment_method').trigger( "click" ); 107 orderPayed = true; 108 $('#place_order').trigger( "click" ); 109 }, { 110 payment_terms: selectPaymentTerm.getPaymentTerm() 111 }); 14 112 }); 15 113 … … 53 151 } 54 152 153 function recalculateTotal() { 154 if (jQuery('.wpm-terms-row.active').length < 1) { 155 return ; 156 } 157 158 selectPaymentTerm.setSelected(jQuery('.wpm-terms-row.active input:checked').attr('data-term')); 159 } 160 55 161 function checkRegisterFields() 56 162 { … … 74 180 $(elem).removeClass('modal-middle'); 75 181 $('.error-confirm-order').hide(); 182 // showTab('.select_payment_term'); 76 183 } 77 184 … … 143 250 144 251 function showTab(el) { 145 $(el).show(0).siblings().hide(0); 252 $(el).siblings().hide(); 253 $(el).show(); 146 254 } 147 255 … … 289 397 290 398 $("body").on("input", "#reg_number_pay", function(event) { 399 const country_code = $('#select_country_pay').val().toLowerCase(); 400 const reg_number = $(this).val(); 401 let language = document.documentElement.lang; 402 language = language.replace('_', '-'); 403 language = language.split('-'); 404 language = language.shift(); 405 const validation = Sprinque.checkRegNumber(reg_number, country_code, language); 406 407 if (!validation.isValid) { 408 $('#reg_number_warning') 409 .show() 410 .text(validation.message); 411 } else { 412 $('#reg_number_warning').hide(); 413 } 414 291 415 $('.error-confirm-order').hide(); 292 416 }); … … 305 429 $('#reg_number_pay').val(company_reg_code); 306 430 $('#confirm-company-order').prop('disabled', false); 431 432 $('#reg_number_pay').trigger('input'); 307 433 }); 308 434 … … 345 471 }); 346 472 347 $("body").on("click", "#register-company-tab, #register-company-tab-2, .register-company-tab, .js-register-company-tab", function(event) {473 $("body").on("click", "#register-company-tab, .company-item-404, .register-company-tab, .js-register-company-tab", function(event) { 348 474 event.preventDefault(); 349 475 var reg_number = $('#reg_number_pay').val(); … … 736 862 success: function (response) { 737 863 if(response.status === true) { 738 showTab('.placing_your_order'); 739 setTimeout(function() { 740 $('#days-review').html(response.days); 741 showTab('.purchase_approved'); 742 }, 1000); 864 if (response.eligible_payment_terms.length > 1) { 865 selectPaymentTerm.setEligiblePaymentTerms(response.eligible_payment_terms); 866 selectPaymentTerm.setAmount(Number(response.total)); 867 selectPaymentTerm.update(); 868 869 showTab('.select_payment_term'); 870 } else { 871 872 showTab('.placing_your_order'); 873 setTimeout(function() { 874 $('#days-review').html(response.days); 875 const paymentTerm = response.eligible_payment_terms[0]; 876 $('.approve-place-order').attr('data-term', paymentTerm); 877 showTab('.purchase_approved'); 878 }, 1000); 879 } 743 880 } else if(response.status === false) { 744 881 if(response.credit_decision === 'MANUAL_REVIEW' || response.credit_decision === 'PENDING') { … … 773 910 } 774 911 775 function authorize_company_payment(callback )912 function authorize_company_payment(callback, params = {}) 776 913 { 777 914 var address_line1 = $('#billing_address_1').val(); … … 795 932 'country_code': country_code, 796 933 'email': email, 797 'nonce': admin.nonce 934 'nonce': admin.nonce, 935 'payment_terms': typeof params.payment_terms !== "undefined" ? params.payment_terms : null 798 936 }, 799 937 type: 'POST', … … 811 949 var modal_class = 'modal-middle'; 812 950 951 showTab('.verifying_your_account'); 813 952 $('.cant-complete-autorization').show(); 814 953 $('.placing_your_order').hide(); 815 $('.verifying_your_account').show();816 954 $('.verifying_your_account .wpm-loader_my1').hide(); 817 955 $('.verify-error-explanation, .verify-error').hide(); … … 866 1004 $("body").on("click", ".approve-place-order", function(event) { 867 1005 showTab('.placing_your_order'); 868 setTimeout(function() { 1006 const paymentTerm = $(this).attr('data-term'); 1007 setTimeout(function() { 869 1008 authorize_company_payment(function () { 870 1009 $('.choose_another_payment_method').trigger( "click" ); 871 1010 orderPayed = true; 872 1011 $('#place_order').trigger( "click" ); 873 } );1012 }, { payment_terms: paymentTerm }); 874 1013 }, 1000); 875 1014 }); -
sprinque/tags/1.3.0/include/payment_method.php
r2877020 r2903962 246 246 $merchant_buyer_id = time(); 247 247 $email = sanitize_text_field( $_POST['email'] ); 248 $phone = sanitize_text_field( $_POST['phone'] ); 248 $phone_number = sanitize_text_field($_POST['phone']); 249 $phone_number = str_replace(' ', '', $phone_number); 250 $phone = $phone_number; 249 251 $country = sanitize_text_field( $_POST['country_code'] ); 250 252 $business_name = sanitize_text_field( $_POST['business_name'] ); … … 258 260 'business_name' => stripslashes($business_name), 259 261 'registration_number' => sanitize_text_field( $_POST['registration_number'] ), 260 'phone' => sanitize_text_field( $_POST['phone'] ),262 'phone' => $phone_number, 261 263 'address' => [ 262 264 'address_line1' => sanitize_text_field( $_POST['address_line1'] ), … … 278 280 'last_name' => sanitize_text_field( $_POST['last_name'] ), 279 281 'email' => $email, 280 'phone' => sanitize_text_field( $_POST['phone'] ),282 'phone' => $phone_number, 281 283 'role' => 'MEMBER' 282 284 ] … … 394 396 $ip = $this->get_ip_address(); 395 397 396 // Prepare Data to Send397 $data = [398 // Prepare Data to Send 399 $data = [ 398 400 'merchant_order_id' => sanitize_text_field($_SESSION['order_id']), 399 401 'order_amount' => WC()->cart->total, … … 411 413 ]; 412 414 415 if (isset($_POST['payment_terms']) && $_POST['payment_terms'] !== null) { 416 $payment_term = sanitize_text_field($_POST['payment_terms']); 417 $data['payment_terms'] = $payment_term; 418 $payment_term_lower = strtolower($payment_term); 419 420 $payment_terms = wp_cache_get('sprinque_available_payment_terms'); 421 if ( !$payment_terms ) { 422 $payment_terms = []; 423 } 424 $fee = $payment_terms[$payment_term_lower] ?? 0.0; 425 426 if ($fee > 0.0) { 427 $fee /= 100.0; 428 $data['order_amount'] *= 1.0 + $fee; 429 } 430 } 431 413 432 // Get Data from API 414 433 $result = $this->srinque_api( $data, 'POST', "/transactions/authorize/{$buyer_id}" ); … … 431 450 $_SESSION['review_order'] = sanitize_text_field($buyer_id); 432 451 unset( $_SESSION['transaction_id'] ); 452 unset( $_SESSION['net_term'] ); 433 453 434 454 wp_send_json( [ … … 440 460 // Prepare Data to Create Order 441 461 $_SESSION['transaction_id'] = sanitize_text_field($result['transaction_id']); 462 $_SESSION['net_term'] = sanitize_text_field($result['payment_terms']); 442 463 unset( $_SESSION['review_order'] ); 443 464 … … 471 492 $buyer = $this->srinque_api( [], 'GET', "/buyers/{$buyer_id}" ); 472 493 $days = isset($buyer['credit_qualification']['payment_terms']) ? str_replace('NET', '', $buyer['credit_qualification']['payment_terms']) : 30; 494 $eligible_payment_terms = $buyer['credit_qualification']['eligible_payment_terms']; 473 495 474 496 $credit_decision = $buyer['credit_qualification']['credit_decision']; … … 479 501 'days' => $days, 480 502 'credit_decision' => $credit_decision ?? 'MANUAL_REVIEW', 503 'eligible_payment_terms' => $eligible_payment_terms, 504 'total' => WC()->cart->get_total('float'), 481 505 'message' => sprintf(__("You have been approved for a payment term of %s days by Sprinque!", "sprinque"), $days) 482 506 ] ); … … 503 527 $_SESSION['review_order'] = sanitize_text_field($buyer_id); 504 528 unset( $_SESSION['transaction_id'] ); 529 unset( $_SESSION['net_term'] ); 505 530 506 531 wp_send_json([ … … 732 757 update_post_meta( $order_id, 'transaction_id', sanitize_text_field($_SESSION['transaction_id']) ); 733 758 update_post_meta( $order_id, 'merchant_order_id', sanitize_text_field($_SESSION['order_id']) ); 759 734 760 $order->update_status( 'processing', __( 'Pay by Invoice - Business only', 'sprinque' ) ); 735 761 } 762 763 if ( isset( $_SESSION['net_term'] ) ) { 764 update_post_meta( $order_id, 'net_term', sanitize_text_field($_SESSION['net_term']) ); 765 } 766 767 if ( isset( $_SESSION['surcharge_fee'] ) ) { 768 update_post_meta( $order_id, 'buyer_fee_percentage', sanitize_text_field($_SESSION['surcharge_fee']) ); 769 } 770 771 unset($_SESSION['net_term']); 772 unset($_SESSION['surcharge_fee']); 736 773 737 774 // Reduce stock levels -
sprinque/tags/1.3.0/languages/sprinque-de_DE.po
r2877020 r2903962 9 9 10 10 #: templates/frontend/srinque_pay_modal_form.php:102 11 #, fuzzy12 11 msgid "(in :sec seconds)" 13 msgstr "(in :sec sekunden)"12 msgstr "(in :sec Sekunden)" 14 13 15 14 #: sprinque.php:442 templates/ajax/founded_companies.php:22 … … 91 90 #: sprinque.php:440 templates/ajax/founded_companies.php:3 92 91 msgid "Company not found" 93 msgstr "Firma nicht gefunden "92 msgstr "Firma nicht gefunden?" 94 93 95 94 #: templates/frontend/srinque_pay_modal_form.php:29 … … 108 107 msgstr "Stornierung bestätigen" 109 108 109 #: templates/frontend/srinque_pay_modal_form.php:137 110 msgid "Confirm order" 111 msgstr "Bestellung bestätigen" 112 113 #: templates/frontend/srinque_pay_modal_form.php:129 114 msgid "Congratulations!" 115 msgstr "Herzlichen Glückwunsch!" 116 110 117 #: templates/frontend/srinque_pay_modal_form.php:107 111 118 #: templates/frontend/srinque_pay_modal_form.php:114 … … 116 123 msgid "Country" 117 124 msgstr "Land" 125 126 #: sprinque.php:546 127 msgid "days" 128 msgstr "Tage" 118 129 119 130 #: templates/frontend/srinque_pay_modal_form.php:100 … … 255 266 msgstr "um es trotzdem zu benutzen" 256 267 268 #: templates/frontend/srinque_pay_modal_form.php:133 269 msgid "Total amount" 270 msgstr "Gesamtbetrag" 271 257 272 msgid "VAT ID" 258 273 msgstr "USt-IdNr." … … 282 297 msgid "You have been approved for a payment term of %s days by Sprinque!" 283 298 msgstr "Du wurdest von Sprinque für ein Zahlungsziel von %s Tagen zugelassen!" 299 300 #: templates/frontend/srinque_pay_modal_form.php:130 301 msgid "You've been approved to pay with net terms. Select the payment term that best suits your company" 302 msgstr "Sie wurden für die Zahlung auf Rechnung zugelassen. Wählen Sie das Zahlungsziel, das am besten zu Ihrem Unternehmen passt" -
sprinque/tags/1.3.0/languages/sprinque-en_US.po
r2873134 r2903962 105 105 #: sprinque.php:440 templates/ajax/founded_companies.php:3 106 106 msgid "Company not found" 107 msgstr "Company not found "107 msgstr "Company not found?" 108 108 109 109 #: templates/frontend/srinque_pay_modal_form.php:31 … … 304 304 msgstr "Title" 305 305 306 #: templates/frontend/srinque_pay_modal_form.php:129 307 msgid "Congratulations!" 308 msgstr "Congratulations!" 309 310 #: templates/frontend/srinque_pay_modal_form.php:130 311 msgid "You've been approved to pay with net terms. Select the payment term that best suits your company" 312 msgstr "You've been approved to pay with net terms. Select the payment term that best suits your company" 313 314 #: templates/frontend/srinque_pay_modal_form.php:133 315 msgid "Total amount" 316 msgstr "Total amount" 317 318 #: templates/frontend/srinque_pay_modal_form.php:137 319 msgid "Confirm order" 320 msgstr "Confirm order" 321 322 #: sprinque.php:546 323 msgid "days" 324 msgstr "days" 325 326 #: sprinque.php:259 327 #: sprinque.php:451 328 msgid "Net terms fee" 329 msgstr "Net terms fee" -
sprinque/tags/1.3.0/languages/sprinque-es_ES.po
r2877020 r2903962 9 9 10 10 #: templates/frontend/srinque_pay_modal_form.php:102 11 #, fuzzy12 11 msgid "(in :sec seconds)" 13 12 msgstr "(en :sec segundos)" … … 91 90 #: sprinque.php:440 templates/ajax/founded_companies.php:3 92 91 msgid "Company not found" 93 msgstr "Empresa no encontrada "92 msgstr "Empresa no encontrada?" 94 93 95 94 #: templates/frontend/srinque_pay_modal_form.php:29 … … 108 107 msgstr "Confirmar anulación" 109 108 109 #: templates/frontend/srinque_pay_modal_form.php:137 110 msgid "Confirm order" 111 msgstr "Confirmar pedido" 112 113 #: templates/frontend/srinque_pay_modal_form.php:129 114 msgid "Congratulations!" 115 msgstr "¡Felicidades!" 116 110 117 #: templates/frontend/srinque_pay_modal_form.php:107 111 118 #: templates/frontend/srinque_pay_modal_form.php:114 … … 117 124 msgstr "País" 118 125 126 #: sprinque.php:546 127 msgid "days" 128 msgstr "días" 129 119 130 #: templates/frontend/srinque_pay_modal_form.php:100 120 131 msgid "days by Sprinque!" … … 253 264 msgstr "usarlo de todos modos" 254 265 266 #: templates/frontend/srinque_pay_modal_form.php:133 267 msgid "Total amount" 268 msgstr "La cantidad total" 269 255 270 msgid "VAT ID" 256 271 msgstr "VAT ID" … … 280 295 msgid "You have been approved for a payment term of %s days by Sprinque!" 281 296 msgstr "Sprinque le ha aprobado un plazo de pago de %s días." 297 298 #: templates/frontend/srinque_pay_modal_form.php:130 299 msgid "You've been approved to pay with net terms. Select the payment term that best suits your company" 300 msgstr "Has sido aprobado para pagar con factura. Selecciona el plazo de pago que mejor se adapte a su empresa" -
sprinque/tags/1.3.0/languages/sprinque-fr_FR.po
r2877020 r2903962 9 9 10 10 #: templates/frontend/srinque_pay_modal_form.php:102 11 #, fuzzy 11 12 12 13 msgid "(in :sec seconds)" 13 14 msgstr "(en :sec secondes)" … … 91 92 #: sprinque.php:440 templates/ajax/founded_companies.php:3 92 93 msgid "Company not found" 93 msgstr "Société introuvable "94 msgstr "Société introuvable?" 94 95 95 96 #: templates/frontend/srinque_pay_modal_form.php:29 … … 108 109 msgstr "Confirmer l'annulation" 109 110 111 #: templates/frontend/srinque_pay_modal_form.php:137 112 113 114 msgid "Confirm order" 115 msgstr "Confirmer la commande" 116 117 #: templates/frontend/srinque_pay_modal_form.php:129 118 119 120 msgid "Congratulations!" 121 msgstr "Félicitations !" 122 110 123 #: templates/frontend/srinque_pay_modal_form.php:107 111 124 #: templates/frontend/srinque_pay_modal_form.php:114 … … 117 130 msgstr "Pays" 118 131 132 #: sprinque.php:546 133 134 135 msgid "days" 136 msgstr "jours" 137 119 138 #: templates/frontend/srinque_pay_modal_form.php:100 120 139 msgid "days by Sprinque!" … … 253 272 msgstr "de l'utiliser quand même" 254 273 274 #: templates/frontend/srinque_pay_modal_form.php:133 275 276 277 msgid "Total amount" 278 msgstr "Montant total" 279 255 280 msgid "VAT ID" 256 281 msgstr "NUMÉRO DE TVA" … … 280 305 msgid "You have been approved for a payment term of %s days by Sprinque!" 281 306 msgstr "Vous avez été approuvé pour un délai de paiement de %s jours par Sprinque !" 307 308 #: templates/frontend/srinque_pay_modal_form.php:130 309 310 311 msgid "You've been approved to pay with net terms. Select the payment term that best suits your company" 312 msgstr "Vous avez été autorisé à payer avec des conditions nettes. Sélectionnez le délai de paiement qui convient le mieux à votre entreprise" -
sprinque/tags/1.3.0/languages/sprinque-nl_NL.po
r2877020 r2903962 9 9 10 10 #: templates/frontend/srinque_pay_modal_form.php:102 11 #, fuzzy12 11 msgid "(in :sec seconds)" 13 12 msgstr "(in :sec seconden)" … … 91 90 #: sprinque.php:440 templates/ajax/founded_companies.php:3 92 91 msgid "Company not found" 93 msgstr "Bedrijf niet gevonden "92 msgstr "Bedrijf niet gevonden?" 94 93 95 94 #: templates/frontend/srinque_pay_modal_form.php:29 … … 108 107 msgstr "Annuleren bevestigen" 109 108 109 #: templates/frontend/srinque_pay_modal_form.php:137 110 msgid "Confirm order" 111 msgstr "Bevestig bestelling" 112 113 #: templates/frontend/srinque_pay_modal_form.php:129 114 msgid "Congratulations!" 115 msgstr "Gefeliciteerd!" 116 110 117 #: templates/frontend/srinque_pay_modal_form.php:107 111 118 #: templates/frontend/srinque_pay_modal_form.php:114 … … 117 124 msgstr "Land" 118 125 126 #: sprinque.php:546 127 #, fuzzy 128 msgid "days" 129 msgstr "dagen" 130 119 131 #: templates/frontend/srinque_pay_modal_form.php:100 120 132 msgid "days by Sprinque!" … … 253 265 msgstr "om alsnog te gebruiken" 254 266 267 #: templates/frontend/srinque_pay_modal_form.php:133 268 msgid "Total amount" 269 msgstr "Totaal bedrag" 270 255 271 msgid "VAT ID" 256 272 msgstr "BTW-NUMMER" … … 280 296 msgid "You have been approved for a payment term of %s days by Sprinque!" 281 297 msgstr "Je bent goedgekeurd voor een betalingstermijn van %s dagen door Sprinque!" 298 299 #: templates/frontend/srinque_pay_modal_form.php:130 300 msgid "You've been approved to pay with net terms. Select the payment term that best suits your company" 301 msgstr "Je bent goedgekeurd om met netto termijnen te betalen. Selecteer de betalingstermijn die het beste bij jouw bedrijf past" -
sprinque/tags/1.3.0/readme.txt
r2877020 r2903962 6 6 Tested up to: 6.0 7 7 Requires PHP: 5.3 8 Stable tag: 1. 2.78 Stable tag: 1.3.0 9 9 License: GPLv2 or later 10 10 License URI: https://www.gnu.org/licenses/gpl-2.0.html … … 50 50 51 51 == Changelog == 52 53 = 1.3.0 - April 25, 2023 = 54 * Passing Sprinque fee to buyers; 55 * Registration number warnings; 56 * Remove spaces in buyer phone; 57 * Updated "Company not found" styles and made it clickable; 52 58 53 59 = 1.2.7 - March 8, 2023 = -
sprinque/tags/1.3.0/sprinque.php
r2877020 r2903962 5 5 Description: Sprinque for WordPress is a plugin that allows you to offer your business buyers net payment terms (15, 30, 60, 90 days) and thereby grow conversion and retention. 6 6 Author: Sprinque 7 Version: 1. 2.77 Version: 1.3.0 8 8 Text Domain: sprinque 9 9 Domain Path: /languages 10 10 */ 11 11 12 define( 'PLUGIN_SRINQUE_VERSION', '1. 2.7' );12 define( 'PLUGIN_SRINQUE_VERSION', '1.3.0' ); 13 13 define( 'PLUGIN_SRINQUE_DIR', __DIR__ ); 14 14 define( 'PLUGIN_SRINQUE_PATH', plugins_url( '', __FILE__ ) ); … … 69 69 70 70 public function __construct() { 71 $this->get_payment_terms(); 72 71 73 // Include Styles and Scripts 72 74 add_action( 'wp_enqueue_scripts', [ $this, 'include_scripts_and_styles' ], 99 ); … … 86 88 add_action( 'woocommerce_order_refunded', [ $this, 'send_refund_captured_order' ], 10, 1 ); 87 89 add_action( 'woocommerce_update_order', [ $this, 'send_refund_voided_order' ], 10, 1 ); 90 add_action( 'woocommerce_cart_calculate_fees', [ $this, 'calculate_fees' ] ); 88 91 89 92 // Initialize RestAPI … … 227 230 $response = $this->srinque_api( $data, 'POST', "/transactions/void/{$transaction_id}" ); 228 231 } 232 } 233 234 public function calculate_fees() 235 { 236 global $woocommerce; 237 238 if ( is_admin() && ! defined( 'DOING_AJAX' ) ) 239 return; 240 241 if ( ! session_id() ) { 242 session_cache_limiter('public'); 243 session_start(); 244 } 245 246 if ( !isset( $_SESSION['net_term'] ) ) { 247 return; 248 } 249 250 $net_term = $_SESSION['net_term']; 251 $net_term = strtolower($net_term); 252 $payment_terms = $this->get_payment_terms(); 253 $percentage = $payment_terms[$net_term] ?? 0.0; 254 $_SESSION['surcharge_fee'] = $percentage; 255 $percentage /= 100; 256 257 if ($percentage > 0) { 258 $surcharge = ( $woocommerce->cart->cart_contents_total + $woocommerce->cart->shipping_total ) * $percentage; 259 $woocommerce->cart->add_fee( __('Net terms fee', 'sprinque'), $surcharge, true, '' ); 260 } 229 261 } 230 262 … … 362 394 $ip_address = get_post_meta( $order->get_id(), 'ip_address', true ); 363 395 396 // Calculate order total 397 $payment_term = sanitize_text_field( $webhook['credit_qualification']['payment_terms'] ); 398 $payment_terms = $this->get_payment_terms(); 399 $total = $order->get_total(); 400 $fee = $payment_terms[ strtolower($payment_term) ]; 401 $fee_percents = floatval($fee) / 100; 402 $calculated_fee = $total * $fee_percents; 403 $total += $calculated_fee; 404 364 405 // Prepare Data to Send 365 406 $data = [ 366 407 'merchant_order_id' => ( $order_id_from_sequential_plugin ?: $order->get_id() ) . '_wh', 367 'order_amount' => $order->get_total(), 408 'order_amount' => $total, 409 'payment_terms' => $payment_term, 368 410 'shipping_address' => [ 369 411 'address_line1' => $order->get_billing_address_1(), … … 394 436 395 437 if (isset($result['transaction_id'])) { 438 396 439 update_post_meta( $order->ID, 'transaction_id', $result['transaction_id'] ); 397 440 update_post_meta( $order->ID, 'merchant_order_id', $order->ID ); 441 442 update_post_meta( $order->ID, 'net_term', $payment_term ); 443 update_post_meta( $order->ID, 'buyer_fee_percentage', $fee ); 444 398 445 $order = new WC_Order( $order->ID ); 399 446 $order->update_status($status); 447 448 // Add fee if needed 449 if ($fee_percents > 0.0) { 450 $fee = new stdClass(); 451 $fee->name = __('Net terms fee', 'sprinque'); 452 $fee->amount = $calculated_fee; 453 $fee->tax_status = 'taxable'; 454 $fee->total = $calculated_fee; 455 456 $order->add_fee($fee); 457 $order->calculate_totals(); 458 } 459 460 // Save the order 400 461 $order->save(); 401 462 } … … 500 561 // Register scripts 501 562 $settings = get_option( 'woocommerce_wpm_srinque_pay_settings', true ); 502 wp_enqueue_script( 'wpm_srinque_pay', PLUGIN_SRINQUE_PATH . '/assets/js/frontend.js', array( 'jquery' ), PLUGIN_SRINQUE_VERSION, 'all' ); 563 wp_enqueue_script( 'wpm_srinque_tools', 'https://unpkg.com/b2b-sprinque-tools@1.0.0/dist/index.umd.min.js', array( ), PLUGIN_SRINQUE_VERSION, 'all' ); 564 wp_enqueue_script( 'wpm_srinque_pay', PLUGIN_SRINQUE_PATH . '/assets/js/frontend.js', array( 'jquery', 'wpm_srinque_tools' ), PLUGIN_SRINQUE_VERSION, 'all' ); 503 565 504 566 wp_localize_script( 'wpm_srinque_pay', 'admin', array( … … 515 577 'loading' => __( "Loading...", 'sprinque' ), 516 578 'place_order' => __( "Place order", 'sprinque' ), 579 'days' => __('days', 'sprinque'), 580 'payment_terms' => $this->get_payment_terms() 517 581 ) ); 518 582 } 583 } 584 585 public function get_payment_terms() 586 { 587 $payment_terms = wp_cache_get('sprinque_available_payment_terms'); 588 if ( !$payment_terms ) { 589 $payment_terms = $this->srinque_api([], 'GET', "/seller/pricing"); 590 $payment_terms = $payment_terms['buyer_pricing_fee_percent']; 591 if (!is_array($payment_terms)) { 592 return []; 593 } 594 595 wp_cache_add('sprinque_available_payment_terms', $payment_terms, '', 300); 596 } 597 598 return $payment_terms; 519 599 } 520 600 -
sprinque/tags/1.3.0/templates/frontend/srinque_pay_modal_form.php
r2863342 r2903962 44 44 <label><?php _e( "Registration number", 'sprinque' ); ?>*</label> 45 45 <input type="text" id="reg_number_pay" placeholder="<?php _e( "Registration number", 'sprinque' ); ?>"> 46 <div class="field-warning" id="reg_number_warning"> 47 Some text here 48 </div> 46 49 </div> 47 50 … … 126 129 </div> 127 130 131 <div class="select_payment_term" style="display: none;"> 132 <div class="wpm-modal-form-tab__title"><?php _e( "Congratulations!", 'sprinque' ); ?></div> 133 <div class="wpm-modal-form-tab__dsc"><?php _e( "You've been approved to pay with net terms. Select the payment term that best suits your company", 'sprinque' ); ?></div> 134 <div class="wpm-modal-form-tab__terms"> 135 <div class="wpm-terms-row total"> 136 <div class="label"><?php _e("Total amount", 'sprinque'); ?></div> 137 <div class="value">€00.00</div> 138 </div> 139 </div> 140 <button class="wpm-btn wpm-btn_primary wpm-btn_mt wpm-btn_block confirm-order-term" disabled><?php _e( "Confirm order", 'sprinque' ); ?></button> 141 </div> 142 128 143 <div class="purchase_approved" style="display: none;"> 129 144 <div class="wpm-modal-form-tab__title"><?php _e( "Purchase approved", 'sprinque' ); ?></div> 130 <div class="wpm-modal-form-tab__dsc"><?php _e( "You have been approved for a payment term of", 'sprinque' ); ?> <span id="days-review"></span> <?php _e( "days by Sprinque!", 'sprinque' ); ?></div> 131 <a class="wpm-btn wpm-btn_primary wpm-btn_mt-2 wpm-btn_block approve-place-order"><?php _e( "Place order", 'sprinque' ); ?></a> 145 <div class="wpm-modal-form-tab__dsc"> 146 <div> 147 <?php _e( "Your account has been created and you’ve been approved for a payment term of:", 'sprinque' ); ?> 148 </div> 149 <div class="approved-days"> 150 <span id="days-review"></span> <?php _e( "days", 'sprinque' ); ?> 151 </div> 152 </div> 153 <a class="wpm-btn wpm-btn_primary wpm-btn_mt-2 wpm-btn_block approve-place-order"><?php _e( "Confirm order", 'sprinque' ); ?></a> 132 154 </div> 133 155 -
sprinque/trunk/assets/css/frontend.css
r2863342 r2903962 8 8 } 9 9 } 10 #register-company-tab , #register-company-tab-2{10 #register-company-tab { 11 11 cursor: pointer; 12 color: rgb(52, 58, 235);12 color: #000339; 13 13 text-decoration: none; 14 14 } … … 29 29 cursor: default !important; 30 30 background: rgb(255, 255, 255); 31 border: 1px solid rgb(52, 58, 235);31 border: 1px solid #000339; 32 32 box-shadow: rgba(217, 219, 242, 0.5) 0px 4px 8px; 33 33 border-radius: 8px; … … 100 100 padding-right: 10px; 101 101 } 102 } 103 104 .wpm-modal-form-tab__terms .wpm-terms-row { 105 display: flex; 106 align-items: center; 107 box-sizing: border-box; 108 border: 1px solid #e2e4f9; 109 border-radius: 3px; 110 padding: 17px 7px; 111 color: #1f2355; 112 margin-top: 16px; 113 } 114 .wpm-modal-form-tab__terms .wpm-terms-row.total { 115 font-weight: bold; 116 border: none; 117 padding-bottom: 0; 118 } 119 .wpm-modal-form-tab__terms .wpm-terms-row.active { 120 border-color: #00023c; 121 } 122 .wpm-modal-form-tab__terms .wpm-terms-row .value { 123 margin-left: auto; 124 } 125 .wpm-modal-form-tab__terms .wpm-terms-row input[type=radio] { 126 display: none; 127 } 128 .wpm-modal-form-tab__terms .wpm-terms-row input[type=radio]:checked + .input-placeholder { 129 background-color: #00023c; 130 border-color: #00023c; 131 background-image: url("../img/checkmark.png"); 132 background-position: center center; 133 background-repeat: no-repeat; 134 } 135 .wpm-modal-form-tab__terms .wpm-terms-row .input-placeholder { 136 width: 20px; 137 height: 20px; 138 border-radius: 20px; 139 border: 2px solid #D9DBF2; 140 margin-right: 9px; 102 141 } 103 142 … … 424 463 .wpm-modal-form-tab__dsc a { 425 464 text-decoration: none !important; 426 color: rgb(52, 58, 235);465 color: #000339; 427 466 } 428 467 .wpm-modal-form-tab__note { … … 488 527 .field-group input:not([type=submit]):focus { 489 528 outline: none !important; 529 } 530 .field-group .field-warning { 531 margin-top: 8px; 532 box-sizing: border-box; 533 color: rgb(40, 43, 93); 534 border-radius: 8px; 535 display: none; 536 font-size: 14px; 490 537 } 491 538 … … 504 551 appearance: none; 505 552 text-decoration: none; 506 font-weight: 500 !important;507 font-size: 1 4px;553 font-weight: 600 !important; 554 font-size: 16px; 508 555 letter-spacing: 0.02857em; 509 556 min-width: 64px; 510 557 transition: background-color 250ms cubic-bezier(0.4, 0, 0.2, 1) 0ms, box-shadow 250ms cubic-bezier(0.4, 0, 0.2, 1) 0ms, border-color 250ms cubic-bezier(0.4, 0, 0.2, 1) 0ms, color 250ms cubic-bezier(0.4, 0, 0.2, 1) 0ms; 511 padding: 3px 16px;558 padding: 12px 16px; 512 559 width: auto; 513 height: 4 0px;560 height: 48px; 514 561 border: 2px solid transparent !important; 515 562 box-shadow: none; 516 color: rgb(52, 58, 235);517 border-radius: 8px;563 color: #000339; 564 border-radius: 4px; 518 565 text-transform: none; 519 566 } … … 526 573 } 527 574 #wpm-modal-form .wpm-btn_primary { 528 background: rgb(52, 58, 235)!important;575 background: #000339 !important; 529 576 color: rgb(255, 255, 255) !important; 530 577 } 531 578 #wpm-modal-form .wpm-btn_primary:hover { 532 background: rgb(52, 58, 235)!important;579 background: #000339 !important; 533 580 box-shadow: rgba(0, 0, 0, 0.2) 0px 2px 4px -1px, rgba(0, 0, 0, 0.14) 0px 4px 5px 0px, rgba(0, 0, 0, 0.12) 0px 1px 10px 0px !important; 534 581 border-color: transparent !important; … … 537 584 font-weight: 600 !important; 538 585 background: transparent !important; 539 color: rgb(52, 58, 235)!important;540 border-color: rgb(52, 58, 235)!important;586 color: #000339 !important; 587 border-color: #000339 !important; 541 588 } 542 589 #wpm-modal-form .wpm-btn_outline-primary:hover { 543 background: rgb(52, 58, 235)!important;590 background: #000339 !important; 544 591 color: #fff !important; 545 592 } 546 593 #wpm-modal-form .wpm-btn:disabled { 547 color: rgba(0, 0, 0, 0.26)!important;594 color: #ffffff !important; 548 595 box-shadow: none !important; 549 background-color: rgba(0, 0, 0, 0.12)!important;596 background-color: #D9DBF2 !important; 550 597 pointer-events: none !important; 551 598 cursor: default !important; … … 687 734 vertical-align: middle; 688 735 animation: spinAround 0.5s infinite linear; 689 border: 3px solid rgb(52, 58, 235);736 border: 3px solid #000339; 690 737 margin-right: 8px; 691 738 border-radius: 290486px; … … 723 770 width: calc(20% - 10px) !important; 724 771 font-size: 38px !important; 725 color: rgb(52, 58, 235);772 color: #000339; 726 773 font-weight: 500 !important; 727 774 text-align: center !important; … … 735 782 border-radius: 50%; 736 783 animation: spinAround 0.5s infinite linear; 737 border: 4px solid rgb(52, 58, 235);784 border: 4px solid #000339; 738 785 border-right-color: transparent; 739 786 border-top-color: transparent; … … 756 803 } 757 804 758 .register-company-tab, .error-confirm-order a , #register-company-tab-2{805 .register-company-tab, .error-confirm-order a { 759 806 color: blue; 760 807 cursor: pointer; … … 762 809 } 763 810 764 .register-company-tab:hover , #register-company-tab-2:hover{811 .register-company-tab:hover { 765 812 text-decoration: none; 766 813 } … … 790 837 padding: 0 5px; 791 838 } 839 840 .purchase_approved .wpm-modal-form-tab__dsc { 841 text-align: center; 842 } 843 .purchase_approved .approved-days { 844 font-size: 20px; 845 font-weight: 600; 846 margin-top: 10px; 847 } 848 849 /*# sourceMappingURL=frontend.css.map */ -
sprinque/trunk/assets/css/frontend.scss
r2863342 r2903962 1 1 @keyframes spinAround{from{transform:rotate(0)}to{transform:rotate(359deg)}} 2 $primary_color: rgb(52, 58, 235); 3 4 #register-company-tab, #register-company-tab-2 { 2 //$primary_color: rgb(52, 58, 235); 3 $primary_color: #000339; 4 5 #register-company-tab { 5 6 cursor: pointer; 6 7 color: $primary_color; … … 115 116 &::-moz-placeholder { @content; } 116 117 &:-ms-input-placeholder { @content; } 118 } 119 120 .wpm-modal-form-tab__terms { 121 .wpm-terms-row { 122 display: flex; 123 align-items: center; 124 box-sizing: border-box; 125 border: 1px solid #e2e4f9; 126 border-radius: 3px; 127 padding: 17px 7px; 128 color: #1f2355; 129 margin-top: 16px; 130 131 &.total { 132 font-weight: bold; 133 border: none; 134 padding-bottom: 0; 135 } 136 137 &.active { 138 border-color: #00023c; 139 } 140 141 .value { 142 margin-left: auto; 143 } 144 145 input[type="radio"] { 146 display: none; 147 148 &:checked + .input-placeholder { 149 background-color: #00023c; 150 border-color: #00023c; 151 background-image: url('../img/checkmark.png'); 152 background-position: center center; 153 background-repeat: no-repeat; 154 } 155 } 156 157 .input-placeholder { 158 width: 20px; 159 height: 20px; 160 border-radius: 20px; 161 border: 2px solid #D9DBF2; 162 margin-right: 9px; 163 } 164 } 117 165 } 118 166 … … 534 582 outline: none !important; 535 583 } 584 } 585 586 .field-warning { 587 margin-top: 8px; 588 box-sizing: border-box; 589 color: rgb(40, 43, 93); 590 border-radius: 8px; 591 display: none; 592 font-size: 14px; 536 593 } 537 594 } … … 673 730 appearance: none; 674 731 text-decoration: none; 675 font-weight: 500 !important;676 font-size: 1 4px;732 font-weight: 600 !important; 733 font-size: 16px; 677 734 letter-spacing: 0.02857em; 678 735 min-width: 64px; 679 736 transition: background-color 250ms cubic-bezier(0.4, 0, 0.2, 1) 0ms, box-shadow 250ms cubic-bezier(0.4, 0, 0.2, 1) 0ms, border-color 250ms cubic-bezier(0.4, 0, 0.2, 1) 0ms, color 250ms cubic-bezier(0.4, 0, 0.2, 1) 0ms; 680 padding: 3px 16px;737 padding: 12px 16px; 681 738 width: auto; 682 height: 4 0px;739 height: 48px; 683 740 border: 2px solid transparent !important; 684 741 box-shadow: none; 685 742 color: $primary_color; 686 743 687 border-radius: 8px;744 border-radius: 4px; 688 745 text-transform: none; 689 746 @media screen and (max-width: 575.98px) { … … 712 769 } 713 770 &:disabled { 714 color: rgba(0, 0, 0, 0.26)!important;771 color: #ffffff !important; 715 772 box-shadow: none !important; 716 background-color: rgba(0, 0, 0, 0.12)!important;773 background-color: #D9DBF2 !important; 717 774 pointer-events: none !important; 718 775 cursor: default !important; … … 967 1024 } 968 1025 969 .register-company-tab, .error-confirm-order a , #register-company-tab-2{1026 .register-company-tab, .error-confirm-order a { 970 1027 color: blue; 971 1028 cursor: pointer; … … 973 1030 } 974 1031 975 .register-company-tab:hover , #register-company-tab-2:hover{1032 .register-company-tab:hover { 976 1033 text-decoration: none; 977 1034 } … … 1001 1058 padding: 0 5px; 1002 1059 } 1060 1061 .purchase_approved { 1062 .wpm-modal-form-tab__dsc { 1063 text-align: center; 1064 } 1065 1066 .approved-days { 1067 font-size: 20px; 1068 font-weight: 600; 1069 margin-top: 10px; 1070 } 1071 } -
sprinque/trunk/assets/js/frontend.js
r2873134 r2903962 5 5 6 6 var countries = []; 7 8 function PaymentTermSelect() { 9 this.payment_terms = window.admin.payment_terms; 10 this.amount = 0; 11 this.selected_fee = 0; 12 this.selected_term = null; 13 this.eligible_payment_terms = []; 14 15 if (typeof this.payment_terms === "undefined") { 16 this.payment_terms = {}; 17 } 18 } 19 20 PaymentTermSelect.prototype = { 21 setEligiblePaymentTerms(paymentTerms) { 22 this.eligible_payment_terms = paymentTerms; 23 }, 24 setAmount(amount) { 25 this.amount = amount; 26 this.recalculateTotal(); 27 }, 28 setSelected(term) { 29 if (typeof this.payment_terms[term] === "undefined") { 30 return ; 31 } 32 33 this.selected_fee = this.payment_terms[term]; 34 this.selected_term = term.toUpperCase(); 35 36 this.recalculateTotal(); 37 }, 38 getPaymentTerm() { 39 return this.selected_term; 40 }, 41 42 update() { 43 for (let key in this.payment_terms) { 44 const keyUpper = key.toUpperCase(); 45 if (this.eligible_payment_terms.indexOf(keyUpper) > -1) { 46 const availableTermUpperCase = this.eligible_payment_terms[keyUpper]; 47 const fee = this.payment_terms[key]; 48 const days = key.replace('net', ''); 49 50 if (typeof fee === "undefined") { 51 continue; 52 } 53 54 $('.wpm-modal-form-tab__terms').append(` 55 <label class="wpm-terms-row"> 56 <input type="radio" name="wpm_net_term" value="${availableTermUpperCase}" data-fee="${fee}" data-term="${key}" /> 57 <div class="input-placeholder"></div> 58 <div class="label">Net ${days} ${window.admin.days}</div> 59 <div class="value">${this.calculateWithFee(fee)}</div> 60 </label> 61 `); 62 } 63 } 64 }, 65 66 calculateWithFee(fee) { 67 const calculatedFee = ( this.amount * (Number(fee) / 100.0) ); 68 69 if (calculatedFee === 0.0) { 70 return 'Free'; 71 } 72 73 return '€' + calculatedFee.toFixed(2); 74 }, 75 recalculateTotal() { 76 const fee = 1.0 + (Number(this.selected_fee) / 100.0); 77 const totalWithFee = this.amount * fee; 78 79 jQuery('.wpm-terms-row.total .value').text('€' + totalWithFee.toFixed(2)); 80 } 81 }; 82 83 const selectPaymentTerm = new PaymentTermSelect(); 7 84 8 85 if ($('#wpm-modal-form').length) { … … 12 89 var modal = $(this).attr('data-wpm-close'); 13 90 hidePopup(modal); 91 }); 92 93 $('body').on('change', '.wpm-terms-row input[type="radio"]', function () { 94 const terms = jQuery(this).closest('.wpm-modal-form-tab__terms'); 95 jQuery('.active', terms).removeClass('active'); 96 jQuery(this).closest('.wpm-terms-row').addClass('active'); 97 jQuery('.confirm-order-term').removeAttr('disabled'); 98 99 recalculateTotal(); 100 }); 101 102 $('body').on('click', '.confirm-order-term', function () { 103 $(this).attr('disabled', 'disabled'); 104 105 authorize_company_payment(function () { 106 $('.choose_another_payment_method').trigger( "click" ); 107 orderPayed = true; 108 $('#place_order').trigger( "click" ); 109 }, { 110 payment_terms: selectPaymentTerm.getPaymentTerm() 111 }); 14 112 }); 15 113 … … 53 151 } 54 152 153 function recalculateTotal() { 154 if (jQuery('.wpm-terms-row.active').length < 1) { 155 return ; 156 } 157 158 selectPaymentTerm.setSelected(jQuery('.wpm-terms-row.active input:checked').attr('data-term')); 159 } 160 55 161 function checkRegisterFields() 56 162 { … … 74 180 $(elem).removeClass('modal-middle'); 75 181 $('.error-confirm-order').hide(); 182 // showTab('.select_payment_term'); 76 183 } 77 184 … … 143 250 144 251 function showTab(el) { 145 $(el).show(0).siblings().hide(0); 252 $(el).siblings().hide(); 253 $(el).show(); 146 254 } 147 255 … … 289 397 290 398 $("body").on("input", "#reg_number_pay", function(event) { 399 const country_code = $('#select_country_pay').val().toLowerCase(); 400 const reg_number = $(this).val(); 401 let language = document.documentElement.lang; 402 language = language.replace('_', '-'); 403 language = language.split('-'); 404 language = language.shift(); 405 const validation = Sprinque.checkRegNumber(reg_number, country_code, language); 406 407 if (!validation.isValid) { 408 $('#reg_number_warning') 409 .show() 410 .text(validation.message); 411 } else { 412 $('#reg_number_warning').hide(); 413 } 414 291 415 $('.error-confirm-order').hide(); 292 416 }); … … 305 429 $('#reg_number_pay').val(company_reg_code); 306 430 $('#confirm-company-order').prop('disabled', false); 431 432 $('#reg_number_pay').trigger('input'); 307 433 }); 308 434 … … 345 471 }); 346 472 347 $("body").on("click", "#register-company-tab, #register-company-tab-2, .register-company-tab, .js-register-company-tab", function(event) {473 $("body").on("click", "#register-company-tab, .company-item-404, .register-company-tab, .js-register-company-tab", function(event) { 348 474 event.preventDefault(); 349 475 var reg_number = $('#reg_number_pay').val(); … … 736 862 success: function (response) { 737 863 if(response.status === true) { 738 showTab('.placing_your_order'); 739 setTimeout(function() { 740 $('#days-review').html(response.days); 741 showTab('.purchase_approved'); 742 }, 1000); 864 if (response.eligible_payment_terms.length > 1) { 865 selectPaymentTerm.setEligiblePaymentTerms(response.eligible_payment_terms); 866 selectPaymentTerm.setAmount(Number(response.total)); 867 selectPaymentTerm.update(); 868 869 showTab('.select_payment_term'); 870 } else { 871 872 showTab('.placing_your_order'); 873 setTimeout(function() { 874 $('#days-review').html(response.days); 875 const paymentTerm = response.eligible_payment_terms[0]; 876 $('.approve-place-order').attr('data-term', paymentTerm); 877 showTab('.purchase_approved'); 878 }, 1000); 879 } 743 880 } else if(response.status === false) { 744 881 if(response.credit_decision === 'MANUAL_REVIEW' || response.credit_decision === 'PENDING') { … … 773 910 } 774 911 775 function authorize_company_payment(callback )912 function authorize_company_payment(callback, params = {}) 776 913 { 777 914 var address_line1 = $('#billing_address_1').val(); … … 795 932 'country_code': country_code, 796 933 'email': email, 797 'nonce': admin.nonce 934 'nonce': admin.nonce, 935 'payment_terms': typeof params.payment_terms !== "undefined" ? params.payment_terms : null 798 936 }, 799 937 type: 'POST', … … 811 949 var modal_class = 'modal-middle'; 812 950 951 showTab('.verifying_your_account'); 813 952 $('.cant-complete-autorization').show(); 814 953 $('.placing_your_order').hide(); 815 $('.verifying_your_account').show();816 954 $('.verifying_your_account .wpm-loader_my1').hide(); 817 955 $('.verify-error-explanation, .verify-error').hide(); … … 866 1004 $("body").on("click", ".approve-place-order", function(event) { 867 1005 showTab('.placing_your_order'); 868 setTimeout(function() { 1006 const paymentTerm = $(this).attr('data-term'); 1007 setTimeout(function() { 869 1008 authorize_company_payment(function () { 870 1009 $('.choose_another_payment_method').trigger( "click" ); 871 1010 orderPayed = true; 872 1011 $('#place_order').trigger( "click" ); 873 } );1012 }, { payment_terms: paymentTerm }); 874 1013 }, 1000); 875 1014 }); -
sprinque/trunk/include/payment_method.php
r2877020 r2903962 246 246 $merchant_buyer_id = time(); 247 247 $email = sanitize_text_field( $_POST['email'] ); 248 $phone = sanitize_text_field( $_POST['phone'] ); 248 $phone_number = sanitize_text_field($_POST['phone']); 249 $phone_number = str_replace(' ', '', $phone_number); 250 $phone = $phone_number; 249 251 $country = sanitize_text_field( $_POST['country_code'] ); 250 252 $business_name = sanitize_text_field( $_POST['business_name'] ); … … 258 260 'business_name' => stripslashes($business_name), 259 261 'registration_number' => sanitize_text_field( $_POST['registration_number'] ), 260 'phone' => sanitize_text_field( $_POST['phone'] ),262 'phone' => $phone_number, 261 263 'address' => [ 262 264 'address_line1' => sanitize_text_field( $_POST['address_line1'] ), … … 278 280 'last_name' => sanitize_text_field( $_POST['last_name'] ), 279 281 'email' => $email, 280 'phone' => sanitize_text_field( $_POST['phone'] ),282 'phone' => $phone_number, 281 283 'role' => 'MEMBER' 282 284 ] … … 394 396 $ip = $this->get_ip_address(); 395 397 396 // Prepare Data to Send397 $data = [398 // Prepare Data to Send 399 $data = [ 398 400 'merchant_order_id' => sanitize_text_field($_SESSION['order_id']), 399 401 'order_amount' => WC()->cart->total, … … 411 413 ]; 412 414 415 if (isset($_POST['payment_terms']) && $_POST['payment_terms'] !== null) { 416 $payment_term = sanitize_text_field($_POST['payment_terms']); 417 $data['payment_terms'] = $payment_term; 418 $payment_term_lower = strtolower($payment_term); 419 420 $payment_terms = wp_cache_get('sprinque_available_payment_terms'); 421 if ( !$payment_terms ) { 422 $payment_terms = []; 423 } 424 $fee = $payment_terms[$payment_term_lower] ?? 0.0; 425 426 if ($fee > 0.0) { 427 $fee /= 100.0; 428 $data['order_amount'] *= 1.0 + $fee; 429 } 430 } 431 413 432 // Get Data from API 414 433 $result = $this->srinque_api( $data, 'POST', "/transactions/authorize/{$buyer_id}" ); … … 431 450 $_SESSION['review_order'] = sanitize_text_field($buyer_id); 432 451 unset( $_SESSION['transaction_id'] ); 452 unset( $_SESSION['net_term'] ); 433 453 434 454 wp_send_json( [ … … 440 460 // Prepare Data to Create Order 441 461 $_SESSION['transaction_id'] = sanitize_text_field($result['transaction_id']); 462 $_SESSION['net_term'] = sanitize_text_field($result['payment_terms']); 442 463 unset( $_SESSION['review_order'] ); 443 464 … … 471 492 $buyer = $this->srinque_api( [], 'GET', "/buyers/{$buyer_id}" ); 472 493 $days = isset($buyer['credit_qualification']['payment_terms']) ? str_replace('NET', '', $buyer['credit_qualification']['payment_terms']) : 30; 494 $eligible_payment_terms = $buyer['credit_qualification']['eligible_payment_terms']; 473 495 474 496 $credit_decision = $buyer['credit_qualification']['credit_decision']; … … 479 501 'days' => $days, 480 502 'credit_decision' => $credit_decision ?? 'MANUAL_REVIEW', 503 'eligible_payment_terms' => $eligible_payment_terms, 504 'total' => WC()->cart->get_total('float'), 481 505 'message' => sprintf(__("You have been approved for a payment term of %s days by Sprinque!", "sprinque"), $days) 482 506 ] ); … … 503 527 $_SESSION['review_order'] = sanitize_text_field($buyer_id); 504 528 unset( $_SESSION['transaction_id'] ); 529 unset( $_SESSION['net_term'] ); 505 530 506 531 wp_send_json([ … … 732 757 update_post_meta( $order_id, 'transaction_id', sanitize_text_field($_SESSION['transaction_id']) ); 733 758 update_post_meta( $order_id, 'merchant_order_id', sanitize_text_field($_SESSION['order_id']) ); 759 734 760 $order->update_status( 'processing', __( 'Pay by Invoice - Business only', 'sprinque' ) ); 735 761 } 762 763 if ( isset( $_SESSION['net_term'] ) ) { 764 update_post_meta( $order_id, 'net_term', sanitize_text_field($_SESSION['net_term']) ); 765 } 766 767 if ( isset( $_SESSION['surcharge_fee'] ) ) { 768 update_post_meta( $order_id, 'buyer_fee_percentage', sanitize_text_field($_SESSION['surcharge_fee']) ); 769 } 770 771 unset($_SESSION['net_term']); 772 unset($_SESSION['surcharge_fee']); 736 773 737 774 // Reduce stock levels -
sprinque/trunk/languages/sprinque-de_DE.po
r2877020 r2903962 9 9 10 10 #: templates/frontend/srinque_pay_modal_form.php:102 11 #, fuzzy12 11 msgid "(in :sec seconds)" 13 msgstr "(in :sec sekunden)"12 msgstr "(in :sec Sekunden)" 14 13 15 14 #: sprinque.php:442 templates/ajax/founded_companies.php:22 … … 91 90 #: sprinque.php:440 templates/ajax/founded_companies.php:3 92 91 msgid "Company not found" 93 msgstr "Firma nicht gefunden "92 msgstr "Firma nicht gefunden?" 94 93 95 94 #: templates/frontend/srinque_pay_modal_form.php:29 … … 108 107 msgstr "Stornierung bestätigen" 109 108 109 #: templates/frontend/srinque_pay_modal_form.php:137 110 msgid "Confirm order" 111 msgstr "Bestellung bestätigen" 112 113 #: templates/frontend/srinque_pay_modal_form.php:129 114 msgid "Congratulations!" 115 msgstr "Herzlichen Glückwunsch!" 116 110 117 #: templates/frontend/srinque_pay_modal_form.php:107 111 118 #: templates/frontend/srinque_pay_modal_form.php:114 … … 116 123 msgid "Country" 117 124 msgstr "Land" 125 126 #: sprinque.php:546 127 msgid "days" 128 msgstr "Tage" 118 129 119 130 #: templates/frontend/srinque_pay_modal_form.php:100 … … 255 266 msgstr "um es trotzdem zu benutzen" 256 267 268 #: templates/frontend/srinque_pay_modal_form.php:133 269 msgid "Total amount" 270 msgstr "Gesamtbetrag" 271 257 272 msgid "VAT ID" 258 273 msgstr "USt-IdNr." … … 282 297 msgid "You have been approved for a payment term of %s days by Sprinque!" 283 298 msgstr "Du wurdest von Sprinque für ein Zahlungsziel von %s Tagen zugelassen!" 299 300 #: templates/frontend/srinque_pay_modal_form.php:130 301 msgid "You've been approved to pay with net terms. Select the payment term that best suits your company" 302 msgstr "Sie wurden für die Zahlung auf Rechnung zugelassen. Wählen Sie das Zahlungsziel, das am besten zu Ihrem Unternehmen passt" -
sprinque/trunk/languages/sprinque-en_US.po
r2873134 r2903962 105 105 #: sprinque.php:440 templates/ajax/founded_companies.php:3 106 106 msgid "Company not found" 107 msgstr "Company not found "107 msgstr "Company not found?" 108 108 109 109 #: templates/frontend/srinque_pay_modal_form.php:31 … … 304 304 msgstr "Title" 305 305 306 #: templates/frontend/srinque_pay_modal_form.php:129 307 msgid "Congratulations!" 308 msgstr "Congratulations!" 309 310 #: templates/frontend/srinque_pay_modal_form.php:130 311 msgid "You've been approved to pay with net terms. Select the payment term that best suits your company" 312 msgstr "You've been approved to pay with net terms. Select the payment term that best suits your company" 313 314 #: templates/frontend/srinque_pay_modal_form.php:133 315 msgid "Total amount" 316 msgstr "Total amount" 317 318 #: templates/frontend/srinque_pay_modal_form.php:137 319 msgid "Confirm order" 320 msgstr "Confirm order" 321 322 #: sprinque.php:546 323 msgid "days" 324 msgstr "days" 325 326 #: sprinque.php:259 327 #: sprinque.php:451 328 msgid "Net terms fee" 329 msgstr "Net terms fee" -
sprinque/trunk/languages/sprinque-es_ES.po
r2877020 r2903962 9 9 10 10 #: templates/frontend/srinque_pay_modal_form.php:102 11 #, fuzzy12 11 msgid "(in :sec seconds)" 13 12 msgstr "(en :sec segundos)" … … 91 90 #: sprinque.php:440 templates/ajax/founded_companies.php:3 92 91 msgid "Company not found" 93 msgstr "Empresa no encontrada "92 msgstr "Empresa no encontrada?" 94 93 95 94 #: templates/frontend/srinque_pay_modal_form.php:29 … … 108 107 msgstr "Confirmar anulación" 109 108 109 #: templates/frontend/srinque_pay_modal_form.php:137 110 msgid "Confirm order" 111 msgstr "Confirmar pedido" 112 113 #: templates/frontend/srinque_pay_modal_form.php:129 114 msgid "Congratulations!" 115 msgstr "¡Felicidades!" 116 110 117 #: templates/frontend/srinque_pay_modal_form.php:107 111 118 #: templates/frontend/srinque_pay_modal_form.php:114 … … 117 124 msgstr "País" 118 125 126 #: sprinque.php:546 127 msgid "days" 128 msgstr "días" 129 119 130 #: templates/frontend/srinque_pay_modal_form.php:100 120 131 msgid "days by Sprinque!" … … 253 264 msgstr "usarlo de todos modos" 254 265 266 #: templates/frontend/srinque_pay_modal_form.php:133 267 msgid "Total amount" 268 msgstr "La cantidad total" 269 255 270 msgid "VAT ID" 256 271 msgstr "VAT ID" … … 280 295 msgid "You have been approved for a payment term of %s days by Sprinque!" 281 296 msgstr "Sprinque le ha aprobado un plazo de pago de %s días." 297 298 #: templates/frontend/srinque_pay_modal_form.php:130 299 msgid "You've been approved to pay with net terms. Select the payment term that best suits your company" 300 msgstr "Has sido aprobado para pagar con factura. Selecciona el plazo de pago que mejor se adapte a su empresa" -
sprinque/trunk/languages/sprinque-fr_FR.po
r2877020 r2903962 9 9 10 10 #: templates/frontend/srinque_pay_modal_form.php:102 11 #, fuzzy 11 12 12 13 msgid "(in :sec seconds)" 13 14 msgstr "(en :sec secondes)" … … 91 92 #: sprinque.php:440 templates/ajax/founded_companies.php:3 92 93 msgid "Company not found" 93 msgstr "Société introuvable "94 msgstr "Société introuvable?" 94 95 95 96 #: templates/frontend/srinque_pay_modal_form.php:29 … … 108 109 msgstr "Confirmer l'annulation" 109 110 111 #: templates/frontend/srinque_pay_modal_form.php:137 112 113 114 msgid "Confirm order" 115 msgstr "Confirmer la commande" 116 117 #: templates/frontend/srinque_pay_modal_form.php:129 118 119 120 msgid "Congratulations!" 121 msgstr "Félicitations !" 122 110 123 #: templates/frontend/srinque_pay_modal_form.php:107 111 124 #: templates/frontend/srinque_pay_modal_form.php:114 … … 117 130 msgstr "Pays" 118 131 132 #: sprinque.php:546 133 134 135 msgid "days" 136 msgstr "jours" 137 119 138 #: templates/frontend/srinque_pay_modal_form.php:100 120 139 msgid "days by Sprinque!" … … 253 272 msgstr "de l'utiliser quand même" 254 273 274 #: templates/frontend/srinque_pay_modal_form.php:133 275 276 277 msgid "Total amount" 278 msgstr "Montant total" 279 255 280 msgid "VAT ID" 256 281 msgstr "NUMÉRO DE TVA" … … 280 305 msgid "You have been approved for a payment term of %s days by Sprinque!" 281 306 msgstr "Vous avez été approuvé pour un délai de paiement de %s jours par Sprinque !" 307 308 #: templates/frontend/srinque_pay_modal_form.php:130 309 310 311 msgid "You've been approved to pay with net terms. Select the payment term that best suits your company" 312 msgstr "Vous avez été autorisé à payer avec des conditions nettes. Sélectionnez le délai de paiement qui convient le mieux à votre entreprise" -
sprinque/trunk/languages/sprinque-nl_NL.po
r2877020 r2903962 9 9 10 10 #: templates/frontend/srinque_pay_modal_form.php:102 11 #, fuzzy12 11 msgid "(in :sec seconds)" 13 12 msgstr "(in :sec seconden)" … … 91 90 #: sprinque.php:440 templates/ajax/founded_companies.php:3 92 91 msgid "Company not found" 93 msgstr "Bedrijf niet gevonden "92 msgstr "Bedrijf niet gevonden?" 94 93 95 94 #: templates/frontend/srinque_pay_modal_form.php:29 … … 108 107 msgstr "Annuleren bevestigen" 109 108 109 #: templates/frontend/srinque_pay_modal_form.php:137 110 msgid "Confirm order" 111 msgstr "Bevestig bestelling" 112 113 #: templates/frontend/srinque_pay_modal_form.php:129 114 msgid "Congratulations!" 115 msgstr "Gefeliciteerd!" 116 110 117 #: templates/frontend/srinque_pay_modal_form.php:107 111 118 #: templates/frontend/srinque_pay_modal_form.php:114 … … 117 124 msgstr "Land" 118 125 126 #: sprinque.php:546 127 #, fuzzy 128 msgid "days" 129 msgstr "dagen" 130 119 131 #: templates/frontend/srinque_pay_modal_form.php:100 120 132 msgid "days by Sprinque!" … … 253 265 msgstr "om alsnog te gebruiken" 254 266 267 #: templates/frontend/srinque_pay_modal_form.php:133 268 msgid "Total amount" 269 msgstr "Totaal bedrag" 270 255 271 msgid "VAT ID" 256 272 msgstr "BTW-NUMMER" … … 280 296 msgid "You have been approved for a payment term of %s days by Sprinque!" 281 297 msgstr "Je bent goedgekeurd voor een betalingstermijn van %s dagen door Sprinque!" 298 299 #: templates/frontend/srinque_pay_modal_form.php:130 300 msgid "You've been approved to pay with net terms. Select the payment term that best suits your company" 301 msgstr "Je bent goedgekeurd om met netto termijnen te betalen. Selecteer de betalingstermijn die het beste bij jouw bedrijf past" -
sprinque/trunk/readme.txt
r2877020 r2903962 6 6 Tested up to: 6.0 7 7 Requires PHP: 5.3 8 Stable tag: 1. 2.78 Stable tag: 1.3.0 9 9 License: GPLv2 or later 10 10 License URI: https://www.gnu.org/licenses/gpl-2.0.html … … 50 50 51 51 == Changelog == 52 53 = 1.3.0 - April 25, 2023 = 54 * Passing Sprinque fee to buyers; 55 * Registration number warnings; 56 * Remove spaces in buyer phone; 57 * Updated "Company not found" styles and made it clickable; 52 58 53 59 = 1.2.7 - March 8, 2023 = -
sprinque/trunk/sprinque.php
r2877020 r2903962 5 5 Description: Sprinque for WordPress is a plugin that allows you to offer your business buyers net payment terms (15, 30, 60, 90 days) and thereby grow conversion and retention. 6 6 Author: Sprinque 7 Version: 1. 2.77 Version: 1.3.0 8 8 Text Domain: sprinque 9 9 Domain Path: /languages 10 10 */ 11 11 12 define( 'PLUGIN_SRINQUE_VERSION', '1. 2.7' );12 define( 'PLUGIN_SRINQUE_VERSION', '1.3.0' ); 13 13 define( 'PLUGIN_SRINQUE_DIR', __DIR__ ); 14 14 define( 'PLUGIN_SRINQUE_PATH', plugins_url( '', __FILE__ ) ); … … 69 69 70 70 public function __construct() { 71 $this->get_payment_terms(); 72 71 73 // Include Styles and Scripts 72 74 add_action( 'wp_enqueue_scripts', [ $this, 'include_scripts_and_styles' ], 99 ); … … 86 88 add_action( 'woocommerce_order_refunded', [ $this, 'send_refund_captured_order' ], 10, 1 ); 87 89 add_action( 'woocommerce_update_order', [ $this, 'send_refund_voided_order' ], 10, 1 ); 90 add_action( 'woocommerce_cart_calculate_fees', [ $this, 'calculate_fees' ] ); 88 91 89 92 // Initialize RestAPI … … 227 230 $response = $this->srinque_api( $data, 'POST', "/transactions/void/{$transaction_id}" ); 228 231 } 232 } 233 234 public function calculate_fees() 235 { 236 global $woocommerce; 237 238 if ( is_admin() && ! defined( 'DOING_AJAX' ) ) 239 return; 240 241 if ( ! session_id() ) { 242 session_cache_limiter('public'); 243 session_start(); 244 } 245 246 if ( !isset( $_SESSION['net_term'] ) ) { 247 return; 248 } 249 250 $net_term = $_SESSION['net_term']; 251 $net_term = strtolower($net_term); 252 $payment_terms = $this->get_payment_terms(); 253 $percentage = $payment_terms[$net_term] ?? 0.0; 254 $_SESSION['surcharge_fee'] = $percentage; 255 $percentage /= 100; 256 257 if ($percentage > 0) { 258 $surcharge = ( $woocommerce->cart->cart_contents_total + $woocommerce->cart->shipping_total ) * $percentage; 259 $woocommerce->cart->add_fee( __('Net terms fee', 'sprinque'), $surcharge, true, '' ); 260 } 229 261 } 230 262 … … 362 394 $ip_address = get_post_meta( $order->get_id(), 'ip_address', true ); 363 395 396 // Calculate order total 397 $payment_term = sanitize_text_field( $webhook['credit_qualification']['payment_terms'] ); 398 $payment_terms = $this->get_payment_terms(); 399 $total = $order->get_total(); 400 $fee = $payment_terms[ strtolower($payment_term) ]; 401 $fee_percents = floatval($fee) / 100; 402 $calculated_fee = $total * $fee_percents; 403 $total += $calculated_fee; 404 364 405 // Prepare Data to Send 365 406 $data = [ 366 407 'merchant_order_id' => ( $order_id_from_sequential_plugin ?: $order->get_id() ) . '_wh', 367 'order_amount' => $order->get_total(), 408 'order_amount' => $total, 409 'payment_terms' => $payment_term, 368 410 'shipping_address' => [ 369 411 'address_line1' => $order->get_billing_address_1(), … … 394 436 395 437 if (isset($result['transaction_id'])) { 438 396 439 update_post_meta( $order->ID, 'transaction_id', $result['transaction_id'] ); 397 440 update_post_meta( $order->ID, 'merchant_order_id', $order->ID ); 441 442 update_post_meta( $order->ID, 'net_term', $payment_term ); 443 update_post_meta( $order->ID, 'buyer_fee_percentage', $fee ); 444 398 445 $order = new WC_Order( $order->ID ); 399 446 $order->update_status($status); 447 448 // Add fee if needed 449 if ($fee_percents > 0.0) { 450 $fee = new stdClass(); 451 $fee->name = __('Net terms fee', 'sprinque'); 452 $fee->amount = $calculated_fee; 453 $fee->tax_status = 'taxable'; 454 $fee->total = $calculated_fee; 455 456 $order->add_fee($fee); 457 $order->calculate_totals(); 458 } 459 460 // Save the order 400 461 $order->save(); 401 462 } … … 500 561 // Register scripts 501 562 $settings = get_option( 'woocommerce_wpm_srinque_pay_settings', true ); 502 wp_enqueue_script( 'wpm_srinque_pay', PLUGIN_SRINQUE_PATH . '/assets/js/frontend.js', array( 'jquery' ), PLUGIN_SRINQUE_VERSION, 'all' ); 563 wp_enqueue_script( 'wpm_srinque_tools', 'https://unpkg.com/b2b-sprinque-tools@1.0.0/dist/index.umd.min.js', array( ), PLUGIN_SRINQUE_VERSION, 'all' ); 564 wp_enqueue_script( 'wpm_srinque_pay', PLUGIN_SRINQUE_PATH . '/assets/js/frontend.js', array( 'jquery', 'wpm_srinque_tools' ), PLUGIN_SRINQUE_VERSION, 'all' ); 503 565 504 566 wp_localize_script( 'wpm_srinque_pay', 'admin', array( … … 515 577 'loading' => __( "Loading...", 'sprinque' ), 516 578 'place_order' => __( "Place order", 'sprinque' ), 579 'days' => __('days', 'sprinque'), 580 'payment_terms' => $this->get_payment_terms() 517 581 ) ); 518 582 } 583 } 584 585 public function get_payment_terms() 586 { 587 $payment_terms = wp_cache_get('sprinque_available_payment_terms'); 588 if ( !$payment_terms ) { 589 $payment_terms = $this->srinque_api([], 'GET', "/seller/pricing"); 590 $payment_terms = $payment_terms['buyer_pricing_fee_percent']; 591 if (!is_array($payment_terms)) { 592 return []; 593 } 594 595 wp_cache_add('sprinque_available_payment_terms', $payment_terms, '', 300); 596 } 597 598 return $payment_terms; 519 599 } 520 600 -
sprinque/trunk/templates/frontend/srinque_pay_modal_form.php
r2863342 r2903962 44 44 <label><?php _e( "Registration number", 'sprinque' ); ?>*</label> 45 45 <input type="text" id="reg_number_pay" placeholder="<?php _e( "Registration number", 'sprinque' ); ?>"> 46 <div class="field-warning" id="reg_number_warning"> 47 Some text here 48 </div> 46 49 </div> 47 50 … … 126 129 </div> 127 130 131 <div class="select_payment_term" style="display: none;"> 132 <div class="wpm-modal-form-tab__title"><?php _e( "Congratulations!", 'sprinque' ); ?></div> 133 <div class="wpm-modal-form-tab__dsc"><?php _e( "You've been approved to pay with net terms. Select the payment term that best suits your company", 'sprinque' ); ?></div> 134 <div class="wpm-modal-form-tab__terms"> 135 <div class="wpm-terms-row total"> 136 <div class="label"><?php _e("Total amount", 'sprinque'); ?></div> 137 <div class="value">€00.00</div> 138 </div> 139 </div> 140 <button class="wpm-btn wpm-btn_primary wpm-btn_mt wpm-btn_block confirm-order-term" disabled><?php _e( "Confirm order", 'sprinque' ); ?></button> 141 </div> 142 128 143 <div class="purchase_approved" style="display: none;"> 129 144 <div class="wpm-modal-form-tab__title"><?php _e( "Purchase approved", 'sprinque' ); ?></div> 130 <div class="wpm-modal-form-tab__dsc"><?php _e( "You have been approved for a payment term of", 'sprinque' ); ?> <span id="days-review"></span> <?php _e( "days by Sprinque!", 'sprinque' ); ?></div> 131 <a class="wpm-btn wpm-btn_primary wpm-btn_mt-2 wpm-btn_block approve-place-order"><?php _e( "Place order", 'sprinque' ); ?></a> 145 <div class="wpm-modal-form-tab__dsc"> 146 <div> 147 <?php _e( "Your account has been created and you’ve been approved for a payment term of:", 'sprinque' ); ?> 148 </div> 149 <div class="approved-days"> 150 <span id="days-review"></span> <?php _e( "days", 'sprinque' ); ?> 151 </div> 152 </div> 153 <a class="wpm-btn wpm-btn_primary wpm-btn_mt-2 wpm-btn_block approve-place-order"><?php _e( "Confirm order", 'sprinque' ); ?></a> 132 154 </div> 133 155
Note: See TracChangeset
for help on using the changeset viewer.