WooCommerce添加到购物车不能正常工作

时间:2016-11-16 18:12:58

标签: php wordpress woocommerce

我目前正在自定义content-single-product.php模板,我需要添加simple_add_to_cart。它显示正常,数量框似乎工作,但当我点击添加到购物车按钮没有任何反应。

这是我的完整模板代码:

<?php
	/**
	 * woocommerce_before_single_product hook.
	 *
	 * @hooked wc_print_notices - 10
	 */
	 do_action( 'woocommerce_before_single_product' );

	 if ( post_password_required() ) {
	 	echo get_the_password_form();
	 	return;
	 }
?>
<div class="product_wrap">
	<div class="product_image_wrap">
		<div class="thumbnails navigator-2">
			<?php
	  global $product;
	 $attachment_ids = $product->get_gallery_attachment_ids();
	foreach( $attachment_ids as $attachment_id )
	{
	  //echo Image instead of URL
	  echo '<div class="slider_thumb">' . wp_get_attachment_image($attachment_id, 'thumbnail') . '</div>';
	}
	?>
		</div>
		<div class="main_image">
			<div class="product-slider prod-nav">
				<?php
			global $product;
		 $attachment_ids = $product->get_gallery_attachment_ids();

		foreach( $attachment_ids as $attachment_id )
		{
			//echo Image instead of URL
			echo '<div class="prod_img">' . wp_get_attachment_image($attachment_id, 'full') . '</div>';
		}
		?>
			</div>
		</div>
	</div>
	<div class="product_content_wrap">
		<div itemscope itemtype="<?php echo woocommerce_get_product_schema(); ?>" id="product-<?php the_ID(); ?>" <?php post_class(); ?>>

			<div class="summary entry-summary">
				<h3><?php echo get_post_meta( $post->ID, 'comic_series', true ); ?></h3>
				<h1><?php woocommerce_template_single_title(); ?></h1>
				<h2><?php echo get_post_meta( $post->ID, 'author_info', true ); ?></h2>
				<div class="product_description">
					<?php woocommerce_product_description_tab(); ?>
				</div>
				<div class="add_to_cart">
					<?php woocommerce_simple_add_to_cart(); ?>
				</div>
			</div><!-- .summary -->
		</div>
	</div>
</div>
<div class="product_details_wrap">
	<div class="product_details">
		<div class="details_content">
			<h4>Details</h4>
			<ul>
				<li><p><span>Published:</span> <?php echo get_post_meta( $post->ID, 'published', true ); ?></p></li>
				<li><p><span>Writer:</span> <?php echo get_post_meta( $post->ID, 'writer', true ); ?></p></li>
				<li><p><span>Penciller:</span> <?php echo get_post_meta( $post->ID, 'penciller', true ); ?></p></li>
				<li><p><span>Cover Artist:</span> <?php echo get_post_meta( $post->ID, 'cover_artist', true ); ?></p></li>
			</ul>
			<ul>
				<li><p><span>Format:</span> <?php echo get_post_meta( $post->ID, 'format', true ); ?></p></li>
				<li><p><span>Price:</span> <?php echo $product->get_price(); ?></p></li>
				<li><p><span>UPC:</span> <?php echo $product->get_sku(); ?></p></li>
				<li><p><span>FOC Date:</span> <?php echo get_post_meta( $post->ID, 'foc_date', true ); ?></p></li>
			</ul>
		</div>
	</div>
</div>

显然我正在为产品加载一些自定义字段,但它是一个简单的产品。我正在接受我在这里可能缺少的东西......

1 个答案:

答案 0 :(得分:0)

事实证明它与高级自定义字段存在冲突!我将对此进行更多研究,并可能发布一个新问题。太疯狂了!