Woocommerce产品缩略图的自定义字段URL选项 [英] Custom Field URL Option for Woocommerce Product Thumbnail

查看:182
本文介绍了Woocommerce产品缩略图的自定义字段URL选项的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

目前,我正在为联盟产品使用Woocommerce插件。我希望能够单击主页上的缩略图,例如直接转到亚马逊。目前已进行设置,因此一旦单击它便转到我网站上的产品详细信息页面。从那里您可以进入亚马逊页面。但是,点击次数越少越好。

Currently I'm using the Woocommerce plugin for affiliate products. I would like to be able to click on the thumbnail on the main page and go directly to amazon, for example. Currently it's setup so that once clicked it goes to the product detail page on my site. From there you can get to the amazon page. However, fewer clicks the better.

所以我在content-product.php页面中找到了这个钩子。我所做的是将整个内容包装在URL中,并使用自定义字段添加URL。无法正常工作。发生的情况是,仅当使用其中一种销售Flash选项时,URL才会转到亚马逊。关闭后,URL不会转到亚马逊,而是转到我网站上的产品页面。我不知道将URL包装器放在哪里。

So I found the hook in the content-product.php page. What I did was wrap the whole thing in a URL and used a custom field to add in the URL. Doesn't work as intended. What happens is that the URL goes to amazon only when using one of the sale flash options. When turned off, the URL does not go to amazon, but to the product page on my site. I don't know where else to place the URL wrapper.

所以我尝试寻找< a href =<?php the_permalink();?>> 当前控制缩略图的位置。我将功能跟踪到woocommerce-template.php文件。那是我死胡同的地方。我不确定当前缩略图的位置。

So i tried looking for the <a href="<?php the_permalink(); ?>"> that is currently controlling where the thumbnail goes. I traced the function to the woocommerce-template.php file. That's where I hit a dead end. I'm not sure where it is for the thumbnail currently.

这是我修改后的代码,部分在content-product.php页面中起作用:

Here is my modified code that works partially in the content-product.php page:

<div class="thumbnail-wrapper">
        <a href="<?php echo get_post_meta( $post->ID, 'URLThumb', true ); ?>">
        <?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' );
        ?>  
        </a>
</div>

这里是缩略图功能,我似乎无法进一步追溯找到现有的< a href =<?php the_permalink();?>> 进行更改。这在woocommerce-template.php页面上。

Here is the thumbnail function that I can't seem to drill down further to find the existing <a href="<?php the_permalink(); ?>"> to change. This is on the woocommerce-template.php page.

if ( ! function_exists( 'woocommerce_template_loop_product_thumbnail' ) ) {

/**
 * Get the product thumbnail for the loop.
 *
 * @access public
 * @subpackage  Loop
 * @return void
 */
function woocommerce_template_loop_product_thumbnail() {
    echo woocommerce_get_product_thumbnail();
}
}


推荐答案

解决问题。由于SalesFlash图像是被触发的图像,因此我只使用了一个空白的PNG图像来覆盖产品图像的顶部。将我所有的产品都变成了销售产品,并且可以正常工作。并不完美,但我还是不需要销售图标。

Figured out a work around. Since the SalesFlash image was the one being triggered, I just used a blank PNG image to overlay ontop of the product image. Turned all my products into sale items and it works. Not perfect, but I don't need the sale icon anyway.

但是,如果有人知道合适的编程解决方案,我将对其进行更改。谢谢。

But if anyone does know of a proper programming solution, I would change it. Thanks.

这篇关于Woocommerce产品缩略图的自定义字段URL选项的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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