Need to display in a loop. Wordpress, Woocommerce In the image below, the output in the loop is the standard plug-in file content-product.php:

if ( ! defined( 'ABSPATH' ) ) { exit; // Exit if accessed directly } global $product; if ( empty( $product ) || ! $product->is_visible() ) { return; } ?><!-- <li <?php post_class(); ?>> <span class="nxowoo-box"> --> <?php do_action( 'woocommerce_before_shop_loop_item' ); ?> <tr> <td class="product_table"> <a href="<?php the_permalink() ?>" > <img src="<?php echo get_the_post_thumbnail_url(); ?>" alt="" style="max-width: 95px;"> </a> </td> <td class="product_table"><a href="<?php the_permalink() ?>" ><?php the_title(); ?></a></td> <td class="product_table wider-cell2"><?php do_action( 'woocommerce_after_shop_loop_item_title' ); ?></td> <td class="product-table wider-cell"><?php do_action( 'woocommerce_after_shop_loop_item' ); ?></td> </tr> 

enter image description here

  • one
    Formulate the question so that it becomes clear what is needed. And indicate what and how the fact that on the screen - SeVlad
  • The add to cart button in woocommerce is displayed like this: do_action ('woocommerce_after_shop_loop_item'); So I thought that there is a hook on the withdrawal of the amount. - Den
  • As generally formed that on the screen. Theme, plugin? Titles But I saw a ready-made plug-in that will display the goods in this form. I do not remember the names. The plugin is free from repo. - SeVlad
  • I-craft theme, WooCommerce plugin. Basic plugin template. I just changed the layout on the table: - Den
  • one
    In English. versions answered if anyone is interested: stackoverflow.com/questions/42561082/… - Den

1 answer 1

Here's a code ripped from one project. I checked the performance just on the Storefront theme - it works. It may be worth it for your conditions to edit.

  // выбор количества при добавлении простых товаров в корзину с поддержкой AJAX на страницах категорий товаров add_action('woocommerce_before_shop_loop', 'custom_woo_before_shop_link'); function custom_woo_before_shop_link() { add_filter('woocommerce_loop_add_to_cart_link', 'custom_woo_loop_add_to_cart_link', 10, 2); add_action('woocommerce_after_shop_loop', 'custom_woo_after_shop_loop'); } // customise Add to Cart link/button for product loop function custom_woo_loop_add_to_cart_link($button, $product) { // not for variable, grouped or external products if (!in_array($product->product_type, array('variable', 'grouped', 'external'))) { // only if can be purchased if ($product->is_purchasable()) { // show qty +/- with button ob_start(); woocommerce_simple_add_to_cart(); $button = ob_get_clean(); // modify button so that AJAX add-to-cart script finds it $replacement = sprintf('data-product_id="%d" data-quantity="1" $1 ajax_add_to_cart add_to_cart_button product_type_simple ', $product->id); $button = preg_replace('/(class="single_add_to_cart_button)/', $replacement, $button); } } return $button; } // add the required JavaScript function custom_woo_after_shop_loop() { ?> <script> jQuery(function($) { <?php /* when product quantity changes, update quantity attribute on add-to-cart button */ ?> $("form.cart").on("change", "input.qty", function() { $(this.form).find("button[data-quantity]").data("quantity", this.value); }); <?php /* remove old "view cart" text, only need latest one thanks! */ ?> $(document.body).on("adding_to_cart", function() { $("a.added_to_cart").remove(); }); }); </script> <?php }