I'm new in wordpress and woocommerce development part. I'm trying to integrate woocommerce for my products, everything was fine. But when i click on product permalink for product details or product single page it's redirect to the same page. Interesting thing is when i click on product, the url changed but not go through to the details page.
Here is the page link- https://dev.shopvitalsleep.com/collections/all/
I'm using loop inside woocommerce.php with my custom designed page.
Here is the code sample-
<div class="row justify-content-center equal-box"> <?php $args = array( 'post_type' => 'product', 'posts_per_page' => 12 ); $loop = new WP_Query( $args ); if ( $loop->have_posts() ) { while ( $loop->have_posts() ) : $loop->the_post(); $product = wc_get_product($loop->post->ID); ?> <div class="col-lg-6 mb-4"> <div class="product-content text-center"> <div class="product-images"> <a href="<?php the_permalink(); ?>" class="product-details-link"> <?php the_post_thumbnail('full'); ?> </a> </div> <div class="product-info"> <h4 class="product-title"><?php echo get_the_title(); ?></h4> <div class="price"> <p> <span class="reg-price"> <del>$<?php echo get_post_meta( get_the_ID(), '_regular_price', true ); ?></del> </span> <span class="sell-price">now $<?php echo get_post_meta( get_the_ID(), '_sale_price', true ); ?> USD</span> </p> </div> </div> </div> <div class="row mt-auto product-content text-center mb-2"> <div class="col-6"> <a class="button style-blue view-detail-button" href="<?php the_permalink(); ?>">View Details</a> </div> <div class="col-6"> <div class="add-to-cart "><?php echo sprintf( '<a href="%s" data-quantity="1" class="%s" %s>%s</a>', esc_url( $product->add_to_cart_url() ), esc_attr( implode( ' ', array_filter( array( 'button', 'product_type_' . $product->get_type(), $product->is_purchasable() && $product->is_in_stock() ? 'add_to_cart_button' : '', $product->supports( 'ajax_add_to_cart' ) ? 'ajax_add_to_cart' : '', ) ) ) ), wc_implode_html_attributes( array( 'data-product_id' => $product->get_id(), 'data-product_sku' => $product->get_sku(), 'aria-label' => $product->add_to_cart_description(), 'rel' => 'nofollow', ) ), esc_html( $product->add_to_cart_text() ) ); ?> </div> </div> </div> </div> <?php endwhile; } else { echo __( 'No products found' ); } wp_reset_postdata(); ?> </div> Folder structure: ../themes/theme-name/woocommerce.php
Please help me to findout where i make mistakes.