admin管理员组文章数量:1435858
I have a custom loop on my website home page of best selling products.
I am using wc_get_template_part('content', 'product');
to pull in the products.
But when I click the buy button, the buy button does not get the tick added to it, so it doesn't look the purchase has worked for users. The item is added to the cart. The buttons work as they should on other pages.
I have checked that "Enable AJAX add to basket buttons on archives" is ticked.
I have tried adding global to my code to see if that makes a difference.
There are no JS errors being logged.
Any ideas why it's not working as expected?
Here is my code:
<?php
global $woocommerce_loop;
global $product;
$args = array(
'post_type' => 'product',
'meta_key' => 'total_sales',
'orderby' => 'meta_value_num',
'posts_per_page' => 12
);
$product = new WP_Query( $args );
if ($product->have_posts()) {
while ($product->have_posts()) {
$product->the_post();
wc_get_template_part('content', 'product');
}
?>
I have a custom loop on my website home page of best selling products.
I am using wc_get_template_part('content', 'product');
to pull in the products.
But when I click the buy button, the buy button does not get the tick added to it, so it doesn't look the purchase has worked for users. The item is added to the cart. The buttons work as they should on other pages.
I have checked that "Enable AJAX add to basket buttons on archives" is ticked.
I have tried adding global to my code to see if that makes a difference.
There are no JS errors being logged.
Any ideas why it's not working as expected?
Here is my code:
<?php
global $woocommerce_loop;
global $product;
$args = array(
'post_type' => 'product',
'meta_key' => 'total_sales',
'orderby' => 'meta_value_num',
'posts_per_page' => 12
);
$product = new WP_Query( $args );
if ($product->have_posts()) {
while ($product->have_posts()) {
$product->the_post();
wc_get_template_part('content', 'product');
}
?>
Share
Improve this question
asked Apr 26, 2019 at 10:29
thetwopctthetwopct
2913 silver badges12 bronze badges
0
1 Answer
Reset to default 0The answer was that I had dequeued the woocommerce style sheets and fonts, adding the CSS back in made the tick marks appear
.added:after {
font-family: WooCommerce;
content: '\e017';
margin-left: .53em;
vertical-align: bottom;
display: inline-block;
}
本文标签: wp queryAjax buttons not working properly in WooCommerce when using wcgettemplatepart
版权声明:本文标题:wp query - Ajax buttons not working properly in WooCommerce when using wc_get_template_part 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1745420003a2657858.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论