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.

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

报告相同问题?

悬赏问题

  • ¥50 易语言把MYSQL数据库中的数据添加至组合框
  • ¥20 求数据集和代码#有偿答复
  • ¥15 关于下拉菜单选项关联的问题
  • ¥20 java-OJ-健康体检
  • ¥15 rs485的上拉下拉,不会对a-b<-200mv有影响吗,就是接受时,对判断逻辑0有影响吗
  • ¥15 使用phpstudy在云服务器上搭建个人网站
  • ¥15 应该如何判断含间隙的曲柄摇杆机构,轴与轴承是否发生了碰撞?
  • ¥15 vue3+express部署到nginx
  • ¥20 搭建pt1000三线制高精度测温电路
  • ¥15 使用Jdk8自带的算法,和Jdk11自带的加密结果会一样吗,不一样的话有什么解决方案,Jdk不能升级的情况