WooCommerce处理可变定价问题

时间:2013-12-04 04:43:32

标签: wordpress-plugin woocommerce

我正在与WooCommerce合作,并在我的页面上显示单个产品,并且是单一定价。我正在改变一切,以可变价格(许可模式)进行评级。

以下是单品标记:

<?php
/**
 * Template Name: Featured Tracks
 */
get_header(); ?>

<div id="content">
<?php while ( have_posts() ) : the_post(); ?>
    <div id="post-<?php the_ID(); ?>" <?php post_class('page'); ?>>
    <h1><?php the_title(); ?></h1>

        <?php echo do_shortcode( '[audio file="'.get_post_meta( get_the_ID(), '_track_preview_file', true ).'" desc="'. get_the_title() .'"]' ); ?>

        <table width="100%" border="0" cellspacing="0" cellpadding="0" class="table table-border table-hover">
      <tr>
            <th scope="row">Price:</th>
            <td><a href="<?php global $product; echo $product->add_to_cart_url( get_the_ID() ); ?>" class="price-button"><span class="middle"><?php global $product, $woocommerce; $product = get_product( get_the_ID() ); echo $product->get_price_html(); ?></span></a>
</td>
      </tr>
          <tr>
            <th scope="row">Buy Now:</th>
            <td><a href="<?php global $product; echo $product->add_to_cart_url( get_the_ID() ); ?>" class="add-to-cart-button"><span class="middle">Add To Cart</span></a></td>
          </tr>
      <tr>
        <th scope="row">Try It Out:</th>
            <td><a href="<?php global $product; echo get_post_meta( get_the_ID(), '_track_preview_file', true ); ?>" class="add-to-cart-button"><span class="middle">Download Preview</span></a></td>
          </tr>
            <th scope="row">Description:</th>
            <td><?php the_excerpt(); ?></td>
          </tr>
          <tr>
            <th scope="row">Catalog:</th>
            <td><?php the_terms( get_the_ID(), 'product_catalog', '', ', ', '' ); ?></td>
          </tr>
          <tr>
            <th scope="row">Composer:</th>
            <td><?php echo get_post_meta( get_the_ID(), '_track_composer', true ); ?></td>
          </tr>
          <tr>
            <th scope="row">Publisher:</th>
            <td><?php echo get_post_meta( get_the_ID(), '_track_publisher', true ); ?></td>
          </tr>
          <tr>
            <th scope="row">Keywords:</th>
            <td><?php echo $product->get_tags( ', ', '<span class="tagged_as">', '</span>' ); ?></td>
          </tr>
          <tr>
            <th scope="row">Tempo:</th>
            <td><?php echo get_post_meta( get_the_ID(), '_track_temp', true ); ?></td>
          </tr>
          <tr>
            <th scope="row">BPM:</th>
            <td><?php echo get_post_meta( get_the_ID(), '_track_bpm', true ); ?></td>
          </tr>
          <tr>
            <th scope="row">Length:</th>
            <td><?php echo get_post_meta( get_the_ID(), '_track_length', true ); ?></td>
          </tr>
        </table>
        </div><!-- .catalog-item -->
<?php endwhile; wp_reset_query(); ?>
</div><!--#content-->
<?php get_footer(); ?>

打印单个价格的行是我要包含两个不同的链接,根据您想要的许可证将项目添加到购物车。我对WooCommerce不太熟悉,足以实现这一目标

1 个答案:

答案 0 :(得分:0)

您不需要自己添加这两个链接,这就是WooCommerce Product Variations的目的。

配置完成后,它会包含一个下拉菜单,并根据用户的选择自动调整价格。