-
Notifications
You must be signed in to change notification settings - Fork 27
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #375 from omise/release-v5.1.0
Preparing release v5.1.0
- Loading branch information
Showing
18 changed files
with
512 additions
and
25 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
(function ($) { | ||
const $form = $('form.checkout, form#order_review'); | ||
|
||
function hideError() { | ||
$(".woocommerce-error").remove(); | ||
} | ||
|
||
function showError(message) { | ||
if (!message) { | ||
return; | ||
} | ||
|
||
let $ulError = $("<ul>").addClass("woocommerce-error"); | ||
$ulError.html("<li>" + message + "</li>"); | ||
$form.prepend($ulError); | ||
$("html, body").animate({ scrollTop:0 },"slow"); | ||
} | ||
|
||
function omiseHandleError(message) { | ||
$form.block({ | ||
message: null, | ||
overlayCSS: { | ||
background: '#fff url(' + wc_checkout_params.ajax_loader_url + ') no-repeat center', | ||
backgroundSize: '16px 16px', | ||
opacity: 0.6 | ||
} | ||
}); | ||
showError(message); | ||
$form.unblock(); | ||
return false; | ||
} | ||
|
||
function omiseFormHandler() { | ||
hideError(); | ||
if ($('#payment_method_omise_atome').is(':checked')) { | ||
if ($("#omise_atome_phone_default").is(":checked")) { | ||
return true; | ||
} | ||
|
||
const phoneNumber = $('#omise_atome_phone_number').val(); | ||
|
||
if (!phoneNumber) { | ||
return omiseHandleError('Phone number is required in Atome'); | ||
} | ||
|
||
const phonePattern = /(\+)?([0-9]{10,13})/; | ||
|
||
if (!phonePattern.test(phoneNumber)) { | ||
return omiseHandleError('Phone number should be a number in Atome'); | ||
} | ||
|
||
$form.unblock(); | ||
$form.submit(); | ||
} | ||
} | ||
|
||
$(function () { | ||
$('form.checkout').on('checkout_place_order', function (e) { | ||
return omiseFormHandler(); | ||
}); | ||
}) | ||
})(jQuery) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.