• Resolved David Borrink

    (@davidborrink)


    I want to add a message after the checkout list of items and before the payment section. I wrote a function but it isn’t showing up in my cart test. If I coded it right, it should show up after the review of items and just before the payment area.

    Here is my function… what am I missing here?

    add_action('woocommerce_order_details_after_order_table', 'subscription_notice');
    
    function subscription_notice() {
    print 'You will be automatically added to my newsletter mailing list once you place your order. You may unsubscribe at any time.';
    }

    https://wordpress.org/plugins/woocommerce/

Viewing 7 replies - 1 through 7 (of 7 total)
  • Plugin Author Mike Jolley (a11n)

    (@mikejolley)

    woocommerce_order_details_after_order_table is for completed orders, not the checkout. Try woocommerce_review_order_after_order_total

    Thread Starter David Borrink

    (@davidborrink)

    Thanks for the tip, Mike. I changed my code and added a div so I could style it. It shows up after “Your Order” but it displays before the listing of items, not after the table with the total.

    And I’m getting two instances of the message. I have no idea why it would do a double-display. One instance shows up and then another appears after the table with the totals appears.

    Here’s my code…

    add_action('woocommerce_review_order_after_order_total', 'subscription_notice');
    
    function subscription_notice() {
        ?><div class="subscription_notice"><?php
    print 'Please Note: You will be automatically added to my newsletter mailing list once you place your order. You may unsubscribe at any time.'; ?> </subscription_notice><?php
    }

    and if you want to see it in action, here’s the link to the checkout on the site. Obviously you’ll want to place an item in the cart to see it.

    Plugin Author Mike Jolley (a11n)

    (@mikejolley)

    Thread Starter David Borrink

    (@davidborrink)

    Well, my code is placed where I want it to be, so I know the action is correct. I’m getting a double placement of the message. Here’s the HTML Why would I be getting two copies of the subscription_notice class? My action does not say to display it twice.

    <div id="order_review" class="woocommerce-checkout-review-order">
         <div class="subscription_notice">Please Note: You will be automatically added to my newsletter mailing list once you place your order. You may unsubscribe at any time. </div>
         <div class="subscription_notice">Please Note: You will be automatically added to my newsletter mailing list once you place your order. You may unsubscribe at any time. </div>
         <table class="shop_table woocommerce-checkout-review-order-table">
         <div id="payment" class="woocommerce-checkout-payment">
    </div>
    Thread Starter David Borrink

    (@davidborrink)

    After a server move, which automatically solved another issue just by being in a new server setup, this issue remains.

    A javascript is running which updates the order table and unfortunately runs the hook a second time. Turn off Javascript to prove.

    I was able to get this to work with a different hook which runs a fraction later in the process:

    add_action('woocommerce_review_order_before_payment', 'subscription_notice');
    function subscription_notice() {
      echo '<div class="subscription_notice ......';
    }

    Thread Starter David Borrink

    (@davidborrink)

    That did it. Thank you, once again, Lorro for helping me. And thank you for the explanation. I figured there had to be something else causing that double display.

    This solution worked perfectly.

Viewing 7 replies - 1 through 7 (of 7 total)
  • The topic ‘Want to add message after products in checkout before payment button’ is closed to new replies.