简体   繁体   English

如何向 WooCommerce 产品属性添加额外信息?

[英]How to add extra information to a WooCommerce product attribute?

On a single product page, I would like to add more information icon (i or?) on a specific pa_attribute.在单个产品页面上,我想在特定的 pa_attribute 上添加更多信息图标(i 或?)。 So if you click on a?所以如果你点击一个? icon you will see a pop up for more information about that specific attribute.图标,您将看到有关该特定属性的更多信息的弹出窗口。 (example: https://laadkompas.nl/offerte-aanvraag-1/?car-type=Universeel%2C+verschillende+elektrische+auto%27s&installatie=Ja&compire=Thuislocatie ) (例如: https://laadkompas.nl/offerte-aanvraag-1/?car-type=Universeel%2C+verschillende+elektrische+auto%27s&installatie=Ja&compire=Thuislocatie

I did some research but I could not compile the code, because I could not get a specific php pa_attribute.我做了一些研究,但无法编译代码,因为我无法获得特定的 php pa_attribute。

Iv found this code: but its not related on an pa=attribute and its a Tooltip.我找到了这段代码:但它与 pa=attribute 及其工具提示无关。

add_action( 'woocommerce_before_variations_form', 'krank_custom_action', 2 );

function krank_custom_action() {
    echo '  <button class="krank-tooltip ttone" type="button" data-toggle="tooltip" data-placement="top" title="this is a text ">?</button>

Can somebody compile this code to get a specific pa attribute with a extra information tooltip or a popup on a single product page (Woocommerce)?有人可以编译此代码以获取具有额外信息工具提示或单个产品页面(Woocommerce)上的弹出窗口的特定 pa 属性吗?

I did some research and found the right code.我做了一些研究并找到了正确的代码。 Its related on a specific pa_attribute but now I need it make the icon (?) clickable and get more information about that specific product attribute.它与特定的 pa_attribute 相关,但现在我需要它使图标 (?) 可单击并获取有关该特定产品属性的更多信息。

add_filter( 'woocommerce_attribute_label', 'custom_attribute_label', 10, 3 );
function custom_attribute_label( $label, $name, $product ) {
    $taxonomy = 'pa_'.$name;

    if( $taxonomy == 'pa_montagewijze' )
        $label .= '<div class = "customization_image_icon"><img class="alignleft wp-image-25335" src="https://laadkompas.nl/wp-content/themes/laadkompass/images/info.png" alt="" width="10" height="10" /></div>';

    return $label;
}

Can somebody make a clickable tooltip on that specific attribute to get more information?有人可以在该特定属性上制作可点击的工具提示以获取更多信息吗?

I was in same situation and your question and answer helped me alot.我处于同样的情况,您的问题和回答对我帮助很大。 I share my final work here maybe helful for someoneelse later:我在这里分享我的最终作品,也许以后对其他人有帮助:

I prefered to use fontawsome icons in my situation rather than loading an image and also based on my template opportunities I used to execute my template shortcode (my theme is flatsome with ux-builder) to achieve what I wanted (and same thing you asked for):我更喜欢在我的情况下使用fontawsome图标而不是加载图像,并且还根据我用来执行template shortcode代码的模板机会(我的主题是 ux-builder 的扁平化)来实现我想要的(和你要求的相同的东西) ):

add_filter( 'woocommerce_attribute_label', 'custom_attribute_label', 10, 3 );
function custom_attribute_label( $label, $name, $product ) {
    $taxonomy = 'pa_'.$name;

    if( $taxonomy == 'pa_mjattr' )
        $label = $label . ' <a href="#guide-mjattr">info<i class="fa fa-question"></i></a> ' . do_shortcode( '[lightbox id="guide-mjattr" width="600px" padding="20px"][block id="guide-mjattr"][/lightbox]' );

    return $label;
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM