PHPFixing
  • Privacy Policy
  • TOS
  • Ask Question
  • Contact Us
  • Home
  • PHP
  • Programming
  • SQL Injection
  • Web3.0

Tuesday, January 18, 2022

[FIXED] How to add a custom shortcode below the product table on woocommerce checkout page

 January 18, 2022     hook-woocommerce, php, shortcode, woocommerce, wordpress     No comments   

Issue

Problem:
I need to add a shortcode [wc_sc_available_coupons] below the product table on the checkout page.
I added the following code in functions.php
The problem is the shortcode displays at the very bottom of the checkout form.
I changed the number 10 to 120 but still the same.
Would you please let me know how to add the shortcode below the product table (=above the payment)?

Code I tried:

add_action( 'woocommerce_after_checkout_form', 'wnd_checkout_code', 10 );

function wnd_checkout_code( ) {
  echo do_shortcode('[wc_sc_available_coupons]');
}

Thank you.


Solution

Would woocommerce_checkout_after_customer_details hook work for you? So your code would be something like this:

add_action( 'woocommerce_checkout_after_customer_details', 'wnd_checkout_code' );

function wnd_checkout_code( )
{
  echo do_shortcode('[wc_sc_available_coupons]');
}

If not then you could try other hooks such as woocommerce_checkout_before_order_review or you could try this woocommerce_before_order_notes as well.

This one is right before the payment:

add_action( 'woocommerce_review_order_before_payment', 'wnd_checkout_code' );

function wnd_checkout_code( ) 
{
  echo do_shortcode('[wc_sc_available_coupons]');
}


Answered By - Ruvee
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg
Newer Post Older Post Home

0 Comments:

Post a Comment

Note: Only a member of this blog may post a comment.

Total Pageviews

Featured Post

Why Learn PHP Programming

Why Learn PHP Programming A widely-used open source scripting language PHP is one of the most popular programming languages in the world. It...

Subscribe To

Posts
Atom
Posts
Comments
Atom
Comments

Copyright © PHPFixing