I am trying to create a query that displays products and some information about them.
I am stuck on showing their variable product options (they will all be variable products). After this I have to create an add to cart button that will add to cart, produce a success or error message, and let the user continue shopping. Once there is something in the user's cart I would like to then display a checkout button that will take them to the checkout page.
Here is what I've got so far
<?php
$args = array(
'post_type' => 'product',
'posts_per_page' => 12,
// Indicate the product category - in this case "Jugs"
'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();
?>
Does anyone know the functions I should be using to display this information? I'm having a hard time finding anything about it in the documentation / on google.
Thank you all!!!
Aucun commentaire:
Enregistrer un commentaire