I've overwritten WooCommerce's review-order.php to change the checkout a little bit. Now everytime I add something to the hook woocommerce_review_order_after_order_total the contents get displayed twice and before the whole block and NOT AFTER the order total:

function output_payment_button() {
    $order_button_text = apply_filters( 'woocommerce_order_button_text', __( 'Place order', 'woocommerce' ) );
echo '<input type="submit" class="button alt" name="woocommerce_checkout_place_order" id="place_order" value="' . esc_attr( $order_button_text ) . '" data-value="' . esc_attr( $order_button_text ) . '" />';
add_action( 'woocommerce_review_order_after_order_total', 'output_payment_button' );

Also adding a simple <?php echo("Hello World"); ?> to the end of review-order.php makes it appear twice. Can someone explain to me what I am doing wrong?

  • Try return instead of echo – Pim Oct 6 '18 at 14:00
  • @Pim - doesn't work with return unfortunately – chevallier Oct 7 '18 at 11:20

Probably if you check again the file review-order.php you will see that you replace the hook woocommerce_review_order_before_order_total with woocommerce_review_order_after_order_total, which probably now is present two times.

If you see twice what you attached to the hook, is just because the hook is used twice.

  • Thank you very much for your answer Antonio. I'm not sure I understand your point, as I'm using woocommerce_review_order_after_order_total only once. Also woocommerce_review_order_before_order_total exists and has not been replaced. I commented out every other do_action() hook except woocommerce_review_order_after_order_total and still it appears two times. Could you be please so kind and elaborate on your answer? – chevallier Oct 7 '18 at 11:37
  • It appears only once when I remove the classes from the surrounding <table class="shop_table woocommerce-checkout-review-order-table"> element in review-order.php which is very strange. – chevallier Oct 7 '18 at 11:41
  • Did you also try to comment out also that specific hook and check if it still happens one time? Also, did you search in the whole theme folder if that hook is used somewhere else? – Antonio Oct 7 '18 at 13:42
  • Yes I did that, it's used only once within the whole theme - it only appears once when removing the class content from the table element (HTML) - so maybe it's related to AJAX. – chevallier Oct 8 '18 at 11:43

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.