Create Woocommerce Page (Archive Page) that list the products under 999

Hello,

Please assist me to Create Woocommerce Page (Archive Page) that list all the products under certain price for example 999. For your kind information I am using Pro theme.

Hoping for the solutions.

Thank you and best regards.

Bibhash Karn

Hey Bibhash Karn,

Thanks for writing in! With WooCommerce, there is no archive page that displays products according to price. What you can do is create a normal page that will serve to display product items, run a Looper, and filter only products that have prices under 999.

Hope this makes sense.

Hello,

Thank you for response and suggestions.

We have done as per suggestion and achieved the page with list of products under 999.

We have achieved a singe page with 36 products with the "'posts_per_page' => 36," in the query. Is there anyway we can achieve all the products under price 999 with the pagination.

Hoping for the solutions.

Thank you and best regards.

Hey Bibhash Karn,

We need to check your setup first before we can recommend you something. To do that, please provide the following information in a Secure Note.

  • WordPress Login URL
  • Admin level username and password
  • Archive page in question

You can find the Secure Note button at the bottom of your posts.

Hope that helps.

Hi,

Thank you for your response.

As suggested please see the details at the secure note for your information.

Hoping for the suggestion for the solution.

Thank you and best regards.

Hello Bibhash,

I would suggest you go to your layout and set the condition where you have enabled the Looper consumer.

{{dc:woocommerce:product_price}}<= 999

Please note you need to set the conditions expression as a number and insert the dynamic content code as shown in the above screenshot.

Thanks

Hi,

Thank you for your response.

I am little bit confused. Should I set this condition in the WooCommerce Archive Layout or in the Page Layout?

Hoping for the solutions.

Thank you and best regards.

Hello Bibhash,

You can set this condition on the archive Layout or page layout where you want to display the products under 999.

Hope it helps
Thanks

Hi,

Thank you for your response.

Actually, we are looking for the particular (custom) page (may be archive or normal page) that lists the products under price 999 (products from any category or tags or brands or any other attributes) with the pagination features.

As per above response from your colleagues there is no WooCommerce Archive page that displays products according to price. So, as per above suggestion we have created a page that displays products under price 999 with the below query string. Now, the issue is that with the below query we didn’t have pagination in the page.

post_type=product&posts_per_page=36&post_status=publish&ignore_sticky_posts=1&meta_key%5B0%5D=_price&meta_key%5B1%5D=_stock_status&orderby%5Bmeta_value%5D=ASC&orderby%5Bdate%5D=DESC&meta_query%5B0%5D%5B0%5D%5Bkey%5D=_price&meta_query%5B0%5D%5B0%5D%5Bvalue%5D=999&meta_query%5B0%5D%5B0%5D%5Bcompare%5D=%3C%3D&meta_query%5B0%5D%5B0%5D%5Btype%5D=NUMERIC

We are expecting the lists of products under price 999 and if the products are more than 36 then expecting pagination at the particular page (not at the shop, category or tags page).

Hoping for the solution.

Thank you and best regards.

Hello Bibhash,

Please note that the pagination will only work on the archive page and there is no default option to enable the pagination on the pages. If you set the condition the archive layout it will always pull the product which is under price 999.

Hope it helps
Thanks

Hello,

Thank you for your response.

Can you please suggest the way for the archive layout via which we can achieve all the products irrespective of attributes such as category, tags, brands etc. under the price 999?

As per your above suggestion how can we achieve products lists with the pagination in the below page.
https://www.hamroshringar.com/under-999-store/

OR, can you suggest if there is any other option to enable the pagination on the pages.

Hoping for the solutions.

Thank you and best regards.

Hi Bibhash,

Since you want a pagination, your only option is to use a category archive. You can do the following:
1.) Create a new category “Under 999”
2.) Select all products that are under 999 and assign it to the category
3.) You will have to modify the query vars for that archive with a custom PHP code. take this article for example:

A sample condition in the query for step #3 could be:

If not Admin AND Main Query 
    If a category archive AND category is "under 99"
          Set post page to 36
          Set meta query
          Set orderby
          Set order
    EndIf
EndIf

Hope this makes sense.

Hi,

Thank you for your response.

As per your suggestion creating category “Under 999” and assigning all products that are under 999 to the category may be tedious task. Also the prices are subjected to change and maintaining price and the category for the same product can be tedious. So we think this can not be great idea.

Instead, we need your help in creating Custom Page Template. In this please guide us which template (files) to copy from Ethos View and Paste it to child theme. So that we have matched designed from the current shop page. We have some custom code like below:

<?php
/* Template Name: Products Below 999 */
get_header(); ?>

<main id="primary" class="site-main">
<?php
// Get the current page number
$paged = ( get_query_var('paged') ) ? get_query_var('paged') : 1;

// Define custom query args with pagination
$args = array(
    'post_type'      => 'product',
    'posts_per_page' => 36,  // Show 36 products per page
    'paged'          => $paged, // Current page
    'meta_query'     => array(
        array(
            'key'     => '_price',
            'value'   => 999,
            'compare' => '<',
            'type'    => 'NUMERIC',
        ),
    ),
);

// Custom query
$query = new WP_Query($args);

// Check if there are products
if ($query->have_posts()) : ?>

    <header class="page-header">
        <h1 class="page-title"><?php _e( 'Products Below â‚ą999', 'x-theme' ); ?></h1>
    </header>

    <div class="products-grid x-container max width offset">
        <?php
        // Start the loop
        while ($query->have_posts()) : $query->the_post(); ?>

            <div class="product x-column x-md-4">
                <a href="<?php the_permalink(); ?>">
                    <?php woocommerce_show_product_sale_flash(); ?>
                    <?php woocommerce_template_loop_product_thumbnail(); ?>
                    <h2 class="woocommerce-loop-product__title"><?php the_title(); ?></h2>
                    <?php woocommerce_template_loop_price(); ?>
                </a>
            </div>

        <?php endwhile; ?>
    </div>

    <div class="pagination x-container max width offset">
        <?php
        // Display pagination links
        echo paginate_links( array(
            'total'   => $query->max_num_pages,
            'current' => $paged,
            'format'  => '?paged=%#%',
            'prev_text' => __('« Previous'),
            'next_text' => __('Next »'),
        ));
        ?>
    </div>

    <?php
    // Reset post data
    wp_reset_postdata();

else : ?>

    <p><?php _e( 'No products found under â‚ą999.', 'x-theme' ); ?></p>

<?php endif; ?>
</main>
 <?php get_footer(); ?>

The above code lists products with the pagination as per our desire but the layout is broken (The HTML are not as per PRO theme in the above code). So we are hoping your guidance on customization of this page in the child theme.

Thank you and best regards.

Hello Bibhash,

Your solution will be a bit more complicated than what I have suggested.

If I will follow my suggestions, I can simply do steps #1, have a custom PHP code for step #3 like this:

add_action( 'pre_get_posts', 'modify_archive_query' );
function modify_archive_query( $query ) {
    if ( !is_admin() && $query->is_main_query() && is_category('Under 999') ) {
        $meta_query = array(
            array(
                'key'     => '_price',
                'value'   => 999,
                'compare' => '<',
                'type'    => 'NUMERIC',
            ),
        );
        $query->set( 'meta_query', $meta_query );
        $query->set( 'posts_per_page', 36 );
    }
}

The given code serves as an example based on the given article and your arguments in your previous reply.

And finally, the step #4, assuming that the Under 999 Store custom layout (without the Looper Provider) has been assigned exclusively for the category “Under 999” layout. No need for any additional template modifications in your child theme.

By the way, you can subscribe to “One Total Care” package if you want us to implement this solution for you.

One more thing, which price should you be using, The regular price or the sale price?

Best Regards.

Hello,

Thank you for your response.

Thank you for your suggestion and sample code but even of this we don’t think this would be great idea. This is so as the managing price and category would be tedious and also the category Under 999 would be visible at the products page and we don’t want this as it would look odd for the customer (Visitors). So we would like to go to the child theme and as per above our above custom code hoping for the guidance for the setting custom page template for the Ethos View.

Thank you for the One Total Care package though we would like to implement with ourselves for the solutions.

We want the sale price to be displayed at the Under 999.

Hoping for the solutions.

Thank you and best regards.

Hey Bibhash,

If you wish to create a custom page template to display a product under 999. You can create this file template using your child theme framework/views/ethos/ and then create your file template. Please note that you also need to customize the pagination with custom coding.

Then in your WordPress page, create a new page then assigned your newly created template.

Hope that helps.

Hi,

Thank you for your response.

Thank you for your guidance about child theme.

In the mean time can you please suggest us any of your template (php) file to start with the ethos from the PRO Main Theme files. Looking for this as this will help us to get layout as similar to current Shop page.

Hoping for the suggestion.

Thank you and best regards.

Hey @bibhashkarn,

You can choose any of these templates then copy and rename it to your custom file.

Hope that helps.

Hello,

Thank you for your response.

Thank you for your suggestion. We will start customization.

Thank you and best regards

Hey @bibhashkarn,

You’re most welcome!

1 Like