Sunday, July 12, 2020
Wordpress Tricks

Woocommerce custom shop page wordpress template

How to add download pdf link in woocommerce single product page?

Woocommerce custom shop page wordpress template


Hello to all, welcome to In this post, I am sharing the code to make Woocommerce custom shop page wordpress template.  Woocommerce is the most popular e-commerce plugin for WordPress.

It is very easy to use and integrate and there are also so many hooks in Woocommerce, which makes woocommerce customization very easy.

Here is the working and tested code to make Woocommerce custom shop page wordpress template and you can add this into any wordpress theme’s template file:

/* Template Name: Custom Shop */


  <section class="clearfix">
    <div class="container">
        <div class="product-gallery">
          <div class="row">

              // WP_Query arguments

              $args = array(

              'post_type' => 'product',

              'post_status' => 'publish',

              'posts_per_page' => -1,
              'tax_query'=>array(      // The taxonomy query
              'taxonomy'  => 'product_cat',

              'terms'     => array(18,19),
              'operator' => 'NOT IN',
              // The Query

              $query = new WP_Query( $args );
              // The Loop

              if ( $query->have_posts() ) {

              while ( $query->have_posts() ) {


              global $product;

              $product = get_product( get_the_ID() ); 


              <div class="col-md-3 col-sm-4">

                <div class="product-img">

                   <div class="product-thumb">

                    <a href="<?php echo get_the_permalink(); ?>" class="product-detail">

                      <?php echo get_the_post_thumbnail(); ?>


                  <div class="product-price">

                    <strong>$<?php echo get_post_meta( get_the_ID(), '_regular_price', true); ?></strong>


                    $products_ids_array = array();

                    foreach( WC()->cart->get_cart() as $cart_item ){

                      $products_ids_array[] = $cart_item['product_id'];


                    if(in_array(get_the_ID(), $products_ids_array)) {

                      echo '<a href="'.site_url().'/cart/">View Cart</a>';

                    } else {

                      echo '<a href="'.$product->add_to_cart_url().'">Add to Cart</a>';




                  <h6><?php echo get_the_title(); ?></h6>





              } else {

              // no posts found


              // Restore original Post Data

<?php get_footer(); ?>

 If you have query related to this post or any thing related to wordpress and woocommerce then please comment below or you can also email me.

Ajay Malhotra
the authorAjay Malhotra
Hello to all. Welcome to Myself Ajay Malhotra and I am freelance full stack developer. I love coding. I know Wordpress, Core php, Angularjs, Angular 2, Angular 6, Angular 7, Angular 8, Angular 9, Angular 10 Nodejs, laravel, Codeigniter, Shopify, Squarespace, Jquery, Google Map Api, Vuejs, Reactjs, Bigcommerce etc.


  • //Stock Movement Summary

    // SELECT rip.product_name, rip.barcode, rips.stock_increase as Stock, rips.stock_decrease as deducted,
    // case
    // when rips.stock_decrease = ‘0’ then REPLACE(rish.qunatity_adjusted, ‘+’, ”)
    // else ‘0’
    // end
    // as received,
    // rips.stock_increase*rip.retail_price as end_value
    // FROM `rv_inventory_product_stock` as rips
    // INNER JOIN rv_inventory_products as rip on = rips.product_id
    // INNER JOIN rv_inventory_stock_history as rish on rish.product_id = rips.product_id
    // GROUP By rips.product_id

    //Stock on hand

    // SELECT rip.product_name, e.firstname as location, rips.stock_increase as stock_on_hand, rip.retail_price as Average_cost, rips.stock_increase * rip.retail_price as total_cost FROM `rv_inventory_product_stock` as rips
    // INNER JOIN rv_inventory_products as rip on = rips.product_id
    // INNER JOIN employee as e on e.objectId = rip.owner_id

    //stock movement log

    // SELECT ri.invoice_date, ri.ref_no, rsp.product_price, ri.status, rip.product_name, rsp.staff, e.firstname,, rips.stock_increase, rsp.quantity FROM `rv_invoices` as ri
    // INNER JOIN rv_sale_product as rsp on rsp.`ref_no` = ri.`ref_no`
    // INNER JOIN rv_inventory_products as rip on rip.`id` = rsp.`product_id`
    // INNER JOIN employee as e on e.staff_id = rsp.staff
    // INNER JOIN place as p on p.objectId = ri.location_id
    // INNER JOIN rv_inventory_product_stock as rips on rips.product_id = rsp.product_id
    // where ri.status IN(‘Paid’, ‘Unpaid’) and rsp.staff != 0

  • Great post.
    I’d like to say that I’m using free templates for my blog from affiliate-website-templates. I just wanna know your opinion about this site as I don’t have any experience with this.
    Please don’t forget to share your feedback or suggest me any other platform.

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.