• Resolved elmersw

    (@elmersw)


    I’d like to show the redeem coupon area before the payment options. So I tried hooking the woocommerce_review_order_before_submit function to woocommerce_review_order_before_payment instead of woocommerce_review_order_before_submit. I even tried the dirty way way: changing the hook in the original file. Both with the same result: after entering a valid code, the button gets a ‘waiting’ text (forever?). After reloading the page manually the applied card is visible though and a success message appears.

    Is there a simple solution to adjust the location?
    I’d rather not use Javascript for this.

Viewing 7 replies - 1 through 7 (of 7 total)
  • Plugin Author pimwick

    (@pimwick)

    We have an article in our frequently asked questions regarding changing the location of the “Apply Gift Card” field as well as customizing the template:

    https://www.pimwick.com/pw-faq/apply-gift-card-template/

    Thread Starter elmersw

    (@elmersw)

    Thanks for your reply.

    I had already read the FAQ. It seems to me you can either place the gift card section below the coupon or below the payments section at the checkout page. I already placed the gift card section below the payments section. This is important to me as I treat a gift card as payment option.

    Now the gift card section appears just above the place order button. I see no further options to tweak the location. As far as I know adjusting the templates will only give me the opportunity to change the section itself, not the exact location.

    Suppose a customer has a cart amounting to EUR 45 and a gift card amounting to EUR 50. If the customer will redeem the gift cards, there will be left nothing to pay. However, he/she will first face all payment options. This will not contribute to a smooth checkout process. Therefore I’d like to show the gift card section as the first element in the payment section.

    And as said before, using another hook interferes with the checkout process.

    Thread Starter elmersw

    (@elmersw)

    Got it working by changing the code in pw-gift-cards-redeeming.php and pw-gift-cards.js.

    add_action( ‘woocommerce_review_order_before_submit’, array( $this, ‘woocommerce_review_order_before_submit’ ) );

    changed into:
    add_action( ‘woocommerce_review_order_before_payment’, array( $this, ‘woocommerce_review_order_before_submit’ ) );

    and

    // jQuery( document.body ).trigger( ‘wc_update_cart’ );
    jQuery( document.body ).trigger( ‘update_checkout’, { update_shipping_method: false } );
    redeemButton.attr(‘value’, redeemButton.attr(‘data-apply-text’)).prop(‘disabled’, false); // NIEUW
    jQuery (‘#pwgc-redeem-gift-card-number’).val(“”);

    Still have to transfer the code to my child-theme.

    Plugin Author pimwick

    (@pimwick)

    Glad to hear you were able to find a resolution. I’m marking this thread as closed, best of luck with your store!

    Thread Starter elmersw

    (@elmersw)

    I could use a little help to transfer the code to my child theme.

    Removing and adding the function to another hook with the $this variable is not so easy as I thought…

    Plugin Author pimwick

    (@pimwick)

    Try the following code in your child theme:

    function change_pw_gift_card_redeem_hook() {
        global $pw_gift_cards_redeeming;
    
        remove_action( 'woocommerce_review_order_before_submit', array( $pw_gift_cards_redeeming, 'woocommerce_review_order_before_submit') );
        add_action( 'woocommerce_review_order_before_payment', array( $pw_gift_cards_redeeming, 'woocommerce_review_order_before_submit' ) );
    }
    add_action( 'woocommerce_init', 'change_pw_gift_card_redeem_hook', 30 );

    This removes the current hook and applies the new hook.

    Thread Starter elmersw

    (@elmersw)

    Great support again. Thanks.

Viewing 7 replies - 1 through 7 (of 7 total)
  • The topic ‘Move coupon area on checkout page’ is closed to new replies.