dtoqemais553654797 2016-02-09 10:47
浏览 51
已采纳

Wordpress - Woocommerce:添加此链接的位置?

scenario: I'm trying to add a query string to the add-to-cart-wrapper in my search at the bottom of every product page.

So far I've successfully done it for the button, but not for all the other links present into the add-to-cart-wrapper div.

you can see what I mean at the very bottom of this page: Demo page to see the problem

There are two links that I cannot find in the code: one added under

<div class="product-header">

and one under

<div class="add-to-cart-wrapper">

I don't know where they are added and wheter it is by php or JS. Anyone can help pointing me in the right direction?

Thanks a lot in advance!!

Here for reference the last part of content-product.php with my little modification.

<li <?php post_class( $classes ); ?>>

<?php do_action( 'woocommerce_before_shop_loop_item' ); ?>
<?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' );
?>
    <div class="product-header">
        <?php



            echo '<div class="add-to-cart-wrapper">';
            echo apply_filters( 'woocommerce_loop_add_to_cart_link',
                sprintf( '<a href="%s?%s" rel="nofollow" data-product_id="%s" data-product_sku="%s" class="btn btn-md %s product_type_%s">%s</a>',
                    esc_url( $product->add_to_cart_url() ),
                    esc_html($myargs["query"]),
                    esc_attr( $product->id ),
                    esc_attr( $product->get_sku() ),
                    $product->is_purchasable() && $product->is_in_stock() ? 'add_to_cart_button' : '',
                    esc_attr( $product->product_type ),
                    esc_html( $product->add_to_cart_text() )
                ),
            $product );
            echo '</div>';
        ?>
    </div>

    <a href="<?php the_permalink(); echo ("?".$myargs["query"]); ?>"><h3><?php the_title(); ?></h3></a>

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



<?php

    /**
     * woocommerce_after_shop_loop_item hook
     *
     * @hooked woocommerce_template_loop_add_to_cart - 10
     */
    do_action( 'woocommerce_after_shop_loop_item' );

    ?>

  • 写回答

1条回答 默认 最新

  • donglv5269 2016-02-10 14:12
    关注

    I see that you're having issues with links inside other links, the problem like your theme says:

    <?php do_action( 'woocommerce_before_shop_loop_item' ); ?>
    <?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' );
    

    In this section it will do those actions which any other plugin or the theme itself calls and injects custom code, in this case, your links. Search for those hooks and remove them to avoid any link injection.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 基于卷积神经网络的声纹识别
  • ¥15 Python中的request,如何使用ssr节点,通过代理requests网页。本人在泰国,需要用大陆ip才能玩网页游戏,合法合规。
  • ¥100 为什么这个恒流源电路不能恒流?
  • ¥15 有偿求跨组件数据流路径图
  • ¥15 写一个方法checkPerson,入参实体类Person,出参布尔值
  • ¥15 我想咨询一下路面纹理三维点云数据处理的一些问题,上传的坐标文件里是怎么对无序点进行编号的,以及xy坐标在处理的时候是进行整体模型分片处理的吗
  • ¥15 CSAPPattacklab
  • ¥15 一直显示正在等待HID—ISP
  • ¥15 Python turtle 画图
  • ¥15 stm32开发clion时遇到的编译问题