点击category button
如下:
$id = $_GET['ServiceId'];
?>
<ul class="products">
<?php
$args = array( 'post_type' => 'product', 'posts_per_page' => 10, 'product_cat' => $id, 'orderby' => 'rand' );
$loop = new WP_Query( $args );
while ( $loop->have_posts() ) : $loop->the_post(); global $product; ?>
<div>
<li class="food_menu">
<a href="<?php echo get_permalink( $loop->post->ID ) ?>" title="<?php echo esc_attr($loop->post->post_title ? $loop->post->post_title : $loop->post->ID); ?>">
<?php woocommerce_show_product_sale_flash( $post, $product ); ?>
<?php if (has_post_thumbnail( $loop->post->ID )) echo get_the_post_thumbnail($loop->post->ID, 'shop_catalog'); else echo '<img src="'.woocommerce_placeholder_img_src().'" alt="Placeholder" />'; ?>
<div class="heading_food">
<h3 class="food_head"><?php the_title(); ?></h3>
<p class="food_head1">Description 1</p>
<p class="food_head1">Description 2</p>
</div>
<div class="price"><?php echo $product->get_price_html(); ?></div>
<div class="qty1" style="width:100%;margin-top:60px">
<?php woocommerce_template_loop_add_to_cart( $loop->post, $product ); ?>
</div>
</li>
</div>
<?php endwhile; ?>
<?php wp_reset_query(); ?>
它显示了该类别的产品列表,它显示了一个Add to cart
按钮,我想要的是,如果有人点击此按钮,那么它应该转到added to cart
和add to cart
按钮应该被禁用。我怎么能这样做?
答案 0 :(得分:-1)
试试这个代码。我希望,它会帮助你......
<强> HTML:强>
<input type="submit" value="Add to cart" class="add_cart">
<强>脚本:强>
jQuery('.add_cart').on('click', function () {
jQuery(this).prop('disabled', true); // for disabled button
jQuery(this).val('Added to cart'); // for change button as Added to cart
}
谢谢!!