写一个woocommerce产品页
时间: 2023-03-20 16:03:46 浏览: 169
好的,下面是一个简单的 WooCommerce 产品页的例子,包括产品标题、描述、价格、图像和购买选项:
```
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>WooCommerce 产品页</title>
</head>
<body>
<div>
<h1><?php the_title(); ?></h1>
<p><?php the_content(); ?></p>
<p>价格:<?php echo get_post_meta(get_the_ID(), '_regular_price', true); ?></p>
<?php if (has_post_thumbnail()): ?>
<img src="<?php the_post_thumbnail_url(); ?>" alt="<?php the_title(); ?>">
<?php endif; ?>
<form class="woocommerce-cart-form" action="<?php echo esc_url(apply_filters('woocommerce_add_to_cart_form_action', $product->get_permalink())); ?>" method="post" enctype="multipart/form-data">
<?php do_action('woocommerce_before_add_to_cart_button'); ?>
<div class="woocommerce-variation-add-to-cart variations_button woocommerce-variation-add-to-cart-enabled">
<div class="woocommerce-variation-add-to-cart variations_button woocommerce-variation-add-to-cart-enabled">
<div class="quantity">
<input type="number" class="input-text qty text" name="quantity" value="1" title="数量" inputmode="numeric">
</div>
<button type="submit" class="single_add_to_cart_button button alt"><?php echo esc_html($product->single_add_to_cart_text()); ?></button>
<input type="hidden" name="add-to-cart" value="<?php echo absint($product->get_id()); ?>">
</div>
</div>
<?php do_action('woocommerce_after_add_to_cart_button'); ?>
</form>
</div>
</body>
</html>
```
请注意,这只是一个基本的模板,您可能需要根据您的特定需求进行修改和定制。此外,还需要确保正确配置 WooCommerce 设置和产品选项,以便使产品页面正常工作。
阅读全文