admin管理员组文章数量:1425176
Trying to add the reviews on a site below the add to cart button in woocommerce. Both these snippets of code do it:
add_action('woocommerce_after_add_to_cart_button', create_function( '$args', 'call_user_func(\'comments_template\');'), 14);
function woocommerce_template_product_reviews() {
woocommerce_get_template( 'single-product-reviews.php' );
}
add_action( 'woocommerce_after_add_to_cart_button', 'comments_template', 50 );
The add to cart will now not work unless you complete a review.
Is there a way to do this with hooks?
Or will I need to use jQuery to clone and move the review code to where I want it.
Trying to add the reviews on a site below the add to cart button in woocommerce. Both these snippets of code do it:
add_action('woocommerce_after_add_to_cart_button', create_function( '$args', 'call_user_func(\'comments_template\');'), 14);
function woocommerce_template_product_reviews() {
woocommerce_get_template( 'single-product-reviews.php' );
}
add_action( 'woocommerce_after_add_to_cart_button', 'comments_template', 50 );
The add to cart will now not work unless you complete a review.
Is there a way to do this with hooks?
Or will I need to use jQuery to clone and move the review code to where I want it.
Share Improve this question asked Jun 25, 2019 at 9:14 Owen RichardsOwen Richards 132 bronze badges1 Answer
Reset to default 0woocommerce_after_add_to_cart_button
is inside the <form>
element for adding items to the cart, but the reviews form is its own form, and you can't have one form inside another form.
You need to pick a hook that's not inside a <form>
element. woocommerce_after_add_to_cart_form
seems to be the closest that's still outside a form.
本文标签: jqueryWoocommerce Moving Review Below add to cart breaks button
版权声明:本文标题:jquery - Woocommerce Moving Review Below add to cart breaks button 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1745372180a2655778.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论