0

enter image description here

I wanted to know how to display a table under each product like this in Wordpress WooCommerce. Does anyone know any plugins or scripts for this? I'm using XStore theme

Edit: I have a plugin caled tier pricing table. It only display the pricing table in product page, not in the loop. I want to know how to make it display on product loop:

if ( $product ) {

        if ( $product->is_type( 'simple' ) ) {
            $this->renderPricingTable( $product->get_id() );
        } elseif ( $product->is_type( 'variable' ) ) {
            echo  '<div data-variation-price-rules-table></div>' ;
        }

    }

1 Answer 1

1

The shop archive or in general any product-loop that passes through:

woocommerce/templates/archive-product.php

...or utilizes similar logic found in that template, by calling:

wc_get_template_part( 'content', 'product' );

which retrieves the following template:

woocommerce/templates/content-product.php

...will then make available the following actions:

Excerpt from: woocommerce/templates/content-product.php (version 3.6.0 at the time of this answer)

    /**
     * Hook: woocommerce_before_shop_loop_item.
     *
     * @hooked woocommerce_template_loop_product_link_open - 10
     */
    do_action( 'woocommerce_before_shop_loop_item' );

    /**
     * Hook: woocommerce_before_shop_loop_item_title.
     *
     * @hooked woocommerce_show_product_loop_sale_flash - 10
     * @hooked woocommerce_template_loop_product_thumbnail - 10
     */
    do_action( 'woocommerce_before_shop_loop_item_title' );

    /**
     * Hook: woocommerce_shop_loop_item_title.
     *
     * @hooked woocommerce_template_loop_product_title - 10
     */
    do_action( 'woocommerce_shop_loop_item_title' );

    /**
     * Hook: woocommerce_after_shop_loop_item_title.
     *
     * @hooked woocommerce_template_loop_rating - 5
     * @hooked woocommerce_template_loop_price - 10
     */
    do_action( 'woocommerce_after_shop_loop_item_title' );

    /**
     * Hook: woocommerce_after_shop_loop_item.
     *
     * @hooked woocommerce_template_loop_product_link_close - 5
     * @hooked woocommerce_template_loop_add_to_cart - 10
     */
    do_action( 'woocommerce_after_shop_loop_item' );

The hook you probably want is:

do_action( 'woocommerce_after_shop_loop_item' );

Therefore add the following to your theme functions.php file or wherever your business logic is:

function wpse_360157_after_shop_loop_item() {

  // add your logic here to print after the add-to-cart button, example:

  // echo '<table>...</table>';

  // OR...

  // include_once( 'path/to/product-loop-table.php' );

  // OR...

  // get_template_part( 'product-loop-table.php' );

  // Etc..

}

add_action( 'woocommerce_after_shop_loop_item' 'wpse_360157_after_shop_loop_item' );

Useful reading:

1
  • Hi! Thanks alot!Your answer was helpful, I've edited my question to clarify my problem. Could you check it out? Commented Mar 10, 2020 at 3:31

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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