Skip to content

Commit

Permalink
Merge pull request #56 from upsellpl/feature/pub-967-moving-discount-…
Browse files Browse the repository at this point in the history
…code-field

poprawka selektora js dla koszyka podzielonego
  • Loading branch information
mtworoz authored Oct 24, 2024
2 parents 9a1718e + 8fa2e62 commit 61757a9
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 9 deletions.
15 changes: 7 additions & 8 deletions assets/js/edd-checkout-global.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,14 @@ window.EDD_Checkout = (function($) {
$form,
$edd_cart_amount,
before_discount,
$checkout_form_wrap;
$content_wrap;

function init() {
$body = $(document.body);
$form = $("#edd_purchase_form");
$edd_cart_amount = $('.edd_cart_amount');
before_discount = $edd_cart_amount.text();
$checkout_form_wrap = $('#edd_checkout_form_wrap');
$content_wrap = $("#content");

// Update state/province field on checkout page
$body.on('change', '#edd_cc_address input.card_state, #edd_cc_address select', update_state_field);
Expand All @@ -37,19 +37,19 @@ window.EDD_Checkout = (function($) {
});

// Validate and apply a discount
$checkout_form_wrap.on('click', '.edd-apply-discount', apply_discount);
$content_wrap.on('click', '.edd-apply-discount', apply_discount);

// Prevent the checkout form from submitting when hitting Enter in the discount field
$checkout_form_wrap.on('keypress', '#edd-discount', function (event) {
$content_wrap.on('keypress', '#edd-discount', function (event) {
if (event.keyCode == '13') {
return false;
}
});

// Apply the discount when hitting Enter in the discount field instead
$checkout_form_wrap.on('keyup', '#edd-discount', function (event) {
$content_wrap.on('keyup', '#edd-discount', function (event) {
if (event.keyCode == '13') {
$checkout_form_wrap.find('.edd-apply-discount').trigger('click');
$content_wrap.find('.edd-apply-discount').trigger('click');
}
});

Expand Down Expand Up @@ -187,7 +187,6 @@ window.EDD_Checkout = (function($) {
}

function apply_discount(event) {

event.preventDefault();

var $this = $(this),
Expand Down Expand Up @@ -223,7 +222,7 @@ window.EDD_Checkout = (function($) {
$('.edd_cart_amount').each(function() {
$(this).text(discount_response.total);
});
$('#edd-discount', $checkout_form_wrap ).val('');
$('#edd-discount', $content_wrap ).val('');

recalculate_taxes();

Expand Down
2 changes: 1 addition & 1 deletion assets/js/edd-checkout-global.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 61757a9

Please sign in to comment.