【发布时间】:2015-06-26 00:49:28
【问题描述】:
我正在尝试创建一个显示产品及其相关信息的查询。
我坚持展示他们的可变产品选项(它们都将是可变产品)。在此之后,我必须创建一个添加到购物车的按钮,该按钮将添加到购物车,产生成功或错误消息,并让用户继续购物。一旦用户的购物车中有东西,我想显示一个结帐按钮,将他们带到结帐页面。
这是我到目前为止所得到的
<?php
$args = array(
'post_type' => 'product',
'posts_per_page' => 12,
// Indicate the product category - in this case "training"
'product_cat' => 'training'
);
$loop = new WP_Query( $args );
if ( $loop->have_posts() ) {
while ( $loop->have_posts() ) : $loop->the_post();
// Show the product Featured Image and gallery images
woocommerce_show_product_images();
// Show the product Title
echo the_title();
// Show the product Custom Fields
echo get_post_meta($post->ID, 'Description', true);
echo get_post_meta($post->ID, 'Specifications', true);
echo get_post_meta($post->ID, 'Video', true);
// Show the Product Price
echo $product->get_price_html();
// Show the Variable Product options, for example: Color, Size etc
// stuck here!
// Show the Add to cart button
// stuck here!
// Show the Checkout button if there is an item in the users cart
// stuck here!
endwhile;
}
wp_reset_postdata();
?>
有谁知道我应该使用哪些功能来显示这些信息? 我很难在文档/谷歌上找到任何关于它的信息。
谢谢大家!!!
【问题讨论】:
标签: php jquery ajax wordpress woocommerce