将Woocommerce添加到购物车Button到相关产品和产品列表 [英] Adding Woocommerce Add to Cart Button to related products and product listing

查看:114
本文介绍了将Woocommerce添加到购物车Button到相关产品和产品列表的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在向WooCommerce添加其他内容时遇到了一些困难,因为我仍然很陌生。我正在尝试向相关产品和产品列表添加添加到购物车按钮。

I'm having some difficulty in adding additional stuffs to WooCommerce as I'm still new to it. I'm trying to add an 'add to cart' button to related products and product listing.

正在遍历代码并陷于下面。

Was running through the codes and got stuck at the below.

<a href="<?php the_permalink(); ?>">

        <?php
            /**
             * woocommerce_before_shop_loop_item_title hook
             *
             * @hooked woocommerce_show_product_loop_sale_flash - 10
             * @hooked woocommerce_template_loop_product_thumbnail - 10
             */
            do_action( 'woocommerce_before_shop_loop_item_title' );
        ?>

        <h3><?php the_title(); ?></h3>

        <?php
            /**
             * woocommerce_after_shop_loop_item_title hook
             *
             * @hooked woocommerce_template_loop_price - 10
             */
            do_action( 'woocommerce_after_shop_loop_item_title' );
        ?>

    </a>

    <?php do_action( 'woocommerce_after_shop_loop_item' ); ?>  

希望有人可以指导我如何添加按钮。

Hope someone can guide me on how to add the button. Thanks in advance.

推荐答案

要解释每个do_action都在woocommerce-hooks.php内部,并指向woocommerce-内部的Function- template.php

To explain each do_action is inside the woocommerce-hooks.php and points to a Function inside of woocommerce-template.php

创建缩略图:

Function Name: woocommerce_template_loop_product_thumbnail()

do_action( 'woocommerce_before_shop_loop_item_title' );

提供价格:

Function Name: woocommerce_template_loop_price()

do_action( 'woocommerce_after_shop_loop_item_title' );

添加到购物车按钮:

Function Name: woocommerce_template_loop_add_to_cart()

do_action( 'woocommerce_after_shop_loop_item' );

这篇关于将Woocommerce添加到购物车Button到相关产品和产品列表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆