skip to Main Content

I am using a Woocommerce website with Astra theme. I am displaying Products with the help of shop module in Astra theme. Currently Astra shop module doesn’t display the ‘add to cart button’.
If I leave the price field blank, the add to cart, quantity field and price don’t show up.
I will like the ‘add to cart button’ to show irrespective of the price.

2

Answers


  1. Chosen as BEST ANSWER

    I simply added the price to 0.00001, which will set the price to 0.00 and the 'add to cart button' will be added automatically. This is a good workaround for people who aren't good with code editing.


  2. To achive this you need to customize code inside your child theme. for shop page find the template file

    wp-content/themes/astra/template-parts/woocommerce/archive-product.php
    

    edit this file and add below code to check if the price of the product exists and then displays it with the ‘price’ class.

    if ( $price_html = $product->get_price_html() ) {
        echo '<span class="price">' . $price_html . '</span>';
    }
    

    add below hook to insert add to cart button in theme’s function.php

    add_action( 'woocommerce_after_shop_loop_item', 'woocommerce_template_loop_add_to_cart', 10 );
    

    After this "Add to cart" will be displayed on the shop page regardless of either the price is filled in or not.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search