Ad
Issue With Output Of WooCommerce Hooks On Cart And Checkout Page
I am trying to add some text below the applied coupon on my cart page, but for some reason, I can only get it to display above the table, as per the screenshot.
I even created a fresh install with the twentytwentyone theme, and no other plugins installed besides woocommerce.
These are the code that I am using:
add_action('woocommerce_cart_totals_before_shipping', 'bb_before_shipping');
function bb_before_shipping() {
echo 'woocommerce_cart_totals_before_shipping';
}
And
add_action('woocommerce_before_cart_totals', 'apply_product_on_coupon');
function apply_product_on_coupon() {
global $woocommerce;
if ( ! empty( $woocommerce->cart->applied_coupons ) ) {
echo 'woocommerce_before_cart_totals';
}
}
Any help will be appreciated!
Ad
Answer
You are using the correct hook for the cart page, but the output is part of a HTML table.
So you get:
// Cart
function action_woocommerce_cart_totals_before_shipping() {
echo '<tr><td>woocommerce_cart_totals_before_shipping</td></tr>';
}
add_action( 'woocommerce_cart_totals_before_shipping', 'action_woocommerce_cart_totals_before_shipping' );
// Checout
function action_woocommerce_review_order_before_shipping() {
echo '<tr><td>woocommerce_review_order_before_shipping</td></tr>';
}
add_action( 'woocommerce_review_order_before_shipping', 'action_woocommerce_review_order_before_shipping' );
Ad
source: stackoverflow.com
Related Questions
- → CORS missmatch because of http
- → Building sitemap for 2 wordpress install under 1 domain
- → How to remove empty elements after class?(jQuery)
- → Get width of an element and apply to another relative to the first one?
- → How to remove caption p class from wordpress?
- → 301 Redirection from no-www to www in wordpress
- → Laravel 5 routing using prefix
- → WordPress - Header position Top, Left &Right
- → how to add rel=nofollow to some specific external links in wordpress
- → octobercms install error: database is not empty?
- → How to edit the index page of wordpress theme?
- → How to select a Post Type (Wordpress) to pass a filter in head?
- → What sort of URL structure should be used to display AMP HTML vs vanilla HTML
Ad