我的问题是,我正在使用我自己的自定义单产品. own页面,它的工作方式是我想要的,因为我使用循环来根据我的需要显示单个产品的内容.但是没有,我唯一面临的问题是,我不能得到“加到车”按钮代码在哪里?现在我的add to cart按钮丢失了,这使我完全无法将产品添加到购物车.这里是我的完整代码<div class="shop-info"> <?php query_posts( array( 'post_type' => product, 'posts_per_page' => 1) ); ?> <?php if ( have_posts() ) : while ( have_posts() ) : the_post(); ?> <h2> <?php the_title(); ?> </h2> <span class="check"></span> <span class="stock">IN STOCK</span> <span class="right-code"> <span class="code">CODE: </span> <span class="number"><?php echo $product->get_sku(); ?></span> </span> <img src="<?php bloginfo('template_url'); ?>/images/shop-line.png" alt=""/> <span class="price">$<?php $product = new WC_Product( get_the_ID() ); echo $price = $product->price; ?></span> <span class="total">QUANTITY: </span> <span class="select"> <a href="">00</a> <span class="arrow"></span> </span> <img src="<?php bloginfo('template_url'); ?>/images/shop-line.png" alt=""/> <div class="product-single-content"> <p class="product-detail"> <?php the_content(); ?> </p> </div> <div class="add-buttons"> <a class="add-to-cart" href="<?php echo $product->single_add_to_cart_text(); ?>">ADD TO BASKET/ BORROW</a> <a class="add-to-cart pink" href="">ADD TO WISH LIST</a> </div> <div class="social-links"> <ul class="social-networks"> <li><a href="#">facebook</a></li> <li><a class="twitter" href="#">twitter</a></li> <li><a class="play" href="#">play</a></li> </ul> </div> <?php endwhile; endif; ?> </div>,在上面的代码和div类按钮的部分,我自己的按钮被命名为“添加到篮子/借入”放置,我希望一旦单击锚,这个项目应该添加到购物车.有谁能帮我摆脱这件事吗?
发布于 2015-05-07 11:11:21
替换
<a class="add-to-cart" href="<?php echo $product->single_add_to_cart_text(); ?>">ADD TO BASKET/ BORROW</a>
使用
<?php do_action('woocommerce_simple_add_to_cart'); ?>
如果您想更改add to cart文本,那么将下面的代码添加到主题的functions.php中:
add_filter( 'woocommerce_product_single_add_to_cart_text', 'your_custom_cart_button_text' );
function your_custom_cart_button_text(){
return __( 'ADD TO BASKET/ BORROW', 'woocommerce' );
}注意:不会为变量产品添加。
https://stackoverflow.com/questions/30099186
复制相似问题