2013-12-04 2 views
0

Я работаю с WooCommerce и имею свою страницу, на которой я показываю один продукт, и это единая цена. Я меняю все, чтобы оценивать его по переменной цене (модель лицензирования).WooCommerce работает с проблемами с переменной ценой

Вот Single Markup продукта:

<?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, чтобы это произошло.

ответ

0

Вам не нужно добавлять две ссылки самостоятельно, вот что делает WooCommerce Product Variations.

После настройки он будет включать выпадающее меню и автоматически корректирует цену для пользователя на основе их выбора.

Смежные вопросы