• Hi…I am new to WordPress. I want to add weight of my product below the price in shop page. I am not able to find any plugin which add the weight in my shop page. Can anyone please help me finding a plugin or is there is any tutorial which will guide me.
    https://www.gujjukhakhra.com – is my site. you can see the products page. I just want to display Weight: 200 grams below price on all products.

    TIA…

Viewing 9 replies - 1 through 9 (of 9 total)
  • Hey,

    Just add the attribute to the product. It will appear in the “additional information” tab.

    If you add the weight in the Product Data section, Shipping tab, you can show it below the price using this snippet:

    <?php
      add_action ('woocommerce_single_product_summary', 'show_weight', 25);
      function show_weight() {
        global $product;
        $attributes = $product->get_attributes();
        if ( $product->has_weight() ) {
          print '<p>Weight: '.$product->get_weight().'</p>'.PHP_EOL;
        }
      }
    

    The code goes in functions.php for your child theme or you can use the “My Custom Functions” plugin.

    If its not showing in the required position, it could be because your theme has its own product template. Try different values in place of the 25 to move the weight up or down in position.

    Thread Starter dmayur

    (@dmayur)

    Thank you friends for your reply. Sorry but none work.
    bp.karpinski – Attributes is working but its not showing in shop page below the price and above add to cart. I want it specifically on that place. I just want Weight : 200 gms on that place.
    Lorro – i also tried your code but its not working.

    Can some one please help me???

    It looks like you have a commercial theme and www.ads-software.com forum members don’t have access to the code in commercial themes. Access to other members sites for debugging or code development is not permitted by the forum guidelines due to security issues. You may need to hire a developer:
    https://jobs.wordpress.net/
    Prices are competitive and you are not obliged to accept any quotation.

    Rynald0s

    (@rynald0s)

    Automattic Happiness Engineer

    Hi there!

    If I’m understanding your request correctly, you are looking for a way to add that to the archive/shop page (between price and cart)? If so, then Lorro’s code will work — all you need to do is change woocommerce_single_product_summary filter to woocommerce_after_shop_loop_item so that it looks like this:

    add_action ('woocommerce_after_shop_loop_item', 'show_weight', 25);
      function show_weight() {
        global $product;
        $attributes = $product->get_attributes();
        if ( $product->has_weight() ) {
          print '<p>Weight: '.$product->get_weight().'</p>'.PHP_EOL;
        }
      }

    See: https://businessbloomer.com/woocommerce-visual-hook-guide-archiveshopcat-page/

    This custom code should be added to your child theme’s functions.php file or via a plugin that allows custom functions to be added – such as My Custom Functions or Code Snippets plugin. Please don’t add custom code directly to your parent theme’s functions.php file as this will be wiped entirely when you update.

    Cheers!

    Thread Starter dmayur

    (@dmayur)

    Hi lorro…yes i have bought this theme…is there any other way???

    My code works with my theme on single product page. If you had used a free theme from www.ads-software.com or even elsewhere, I could have downloaded it and tried the code to make sure it works with your theme. This forum is aimed at software available on www.ads-software.com. But with a commercial theme that’s not possible without buying the theme – that’s too much for me to spend on a forum answer! Anyway, I was aiming at the single product page but, re-reading, you are aiming at the shop page, so try @rynald0s’ answer.

    Thread Starter dmayur

    (@dmayur)

    Hey RynaldOs…thanks man..it worked…thank you once again…now out of 10 products its showing in only one…as lorro said yesterday, i have arranged by changing 25 to 8…
    thank you once again…

    Thread Starter dmayur

    (@dmayur)

    hi…Thank you guys for your replies…it worked…

Viewing 9 replies - 1 through 9 (of 9 total)
  • The topic ‘I want to add weight in my woocommerce shop page’ is closed to new replies.