如何在 WooCommerce 中移动产品变体描述 [英] How To Move Product Variation Descriptions in WooCommerce
问题描述
我想在 Woocommerce 中将我的产品变体描述移到添加到购物车按钮下方,但我找不到我应该使用的挂钩.这些是在 AJAX 中选择时加载的变体的自定义描述.
I'd like to move my product's variation descriptions in Woocommerce beneath the add to cart button, and I can't find what hook I'm supposed to use. These are the variation's custom descriptions that load on selection in AJAX.
我可以在添加到购物车按钮下方挂钩另一个自定义函数.所以我认为我的问题是不知道钩子的名称和/或它是钩子还是过滤器.我认为要么是woocommerce_before_single_variation
,要么是woocommerce_before_add_to_cart_button
.
I'm able to hook another custom function beneath the add to cart button. So I think my problem is not knowing the name of the hook and/or if it's a hook versus a filter. I think it's either woocommerce_before_single_variation
or woocommerce_before_add_to_cart_button
.
这是我之前在 functions.php
中没有成功的几次尝试:
Here's several attempts I've tried before with no luck in functions.php
:
remove_action( 'woocommerce_after_single_variation','woocommerce_single_product_summary', 20 );
add_action( 'woocommerce_after_single_variation', 'woocommerce_single_product_summary', 9 );
//try #2
remove_action('woocommerce_single_product_summary', 'woocommerce_template_single_excerpt', 20);
add_action('woocommerce_after_add_to_cart_button', 'woocommerce_single_variation', 35);
谢谢!
推荐答案
我正在寻找的功能默认包含在 WooCommerce 2.4 中,但不是在挂钩上完成的.它是通过 jQuery 更新 div 添加的 - 我在 woocommerce/js/assets/frontend/add-to-cart-variation.js
中找到了它.所以我移动了 div 的位置:
The functionality I was looking for is included in WooCommerce 2.4 as a default but is not done on a hook. It's added by jQuery updating a div instead - which I found in woocommerce/js/assets/frontend/add-to-cart-variation.js
. So I moved the div's location instead:
add_action ('woocommerce_after_single_variation', 'move_descriptions', 50);
function move_descriptions() {
?>
<div class="woocommerce-variation-description" style="border: 1px solid transparent; height: auto;"></div>
<?php
}
这篇关于如何在 WooCommerce 中移动产品变体描述的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!