Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
  • #1348233

    Hi there,
    I am using the Masonry element to display woocommerce products and would like to replace the price range which is displayed for variable products by some calculated price (variation price / variation weight in grams, in reversed order (“from ” the lowest price per gram first, then “to ” the highest) for variables products of specific categories.

    I am not sure that duplicating the Masonry element (which is used for various post types, including products) into a new “Bulk Variable Products Masonry” element is the most efficient way to to this. Especially because I would not like to experiment compatibility issues during upcoming updates of the Enfold theme or the Masonry element.


    • I was thinking ofusing the native woocommerce fields for weight and price of each variation of concerned variable products.
    • The current price range on masonry display would be replaced by “From X,XX€/g to X,XX€/g”
    • I don’t know if it is easier to trigger some specified categories to process this change or if a checkbox option could be displayed in the Masonry edition, as soon as the “product” type is selected.

    Can you please tell me what solution you would use to to this without having to duplicate the whole masonry element and by limiting further compatibility risks ?

    Best regards


    Hey Arsène,
    Thank you for your patience, as you know the masonry element will display the price range for variable products, but it can not change or calculate the prices, this must be done in woocommerce, perhaps the plugin WooCommerce Price Per Unit would help.
    But I don’t believe that you are going to be able to sort by the product price in the masonry element.
    If you have already been able to setup your product with a variable price per gram and only need for the ” /g” to show in the masonry element
    this can be done because the variable product in the masonry element includes the category, for example: product_cat-tshirts
    so this script would add the ” /g” to the price:

    function custom_script() { ?>
    $(".av-masonry-entry.product_cat-tshirts.product-type-variable .woocommerce-Price-amount bdi").each(function() {
       $(this).append(' /g');
    add_action('wp_footer', 'custom_script');

    Best regards,


    Hey Mike,
    Thank you for your answer. I think that I’ll give a try to the WooCommerce Price Per Unit plugin which would allow me to differentiate the net weight of my products from the gross weight (with the packaging).

    In fact, it would be a little bit more complicated than adding a “/g” in the masonry display.
    I really would like to display the price per gram range instead of the current price range for variations (so the order between lowest and highest would have to be reversed). This could use

    • the “Price Per Unit plugin” calculated results or
    • a calculation of each variation’s price divided by the variation weight.

    Even if a plugin or a custom woocommerce function makes the calculation, how can I ask masonry to get the informations and display it instead of the original price range (getting the lowest price per gram then the highest)?

    Btw, I don’t plan to make any change to the product pages and doesn’t need masonry to sort by price.

    Best regards,


    Thanks for the feedback, please try the plugin and hopefully it will replace the variation price with the variation weight as use wish because the masonry element can only show the information and not “calculate” it, this would need to be done with a plugin.
    If this plugin doesn’t help then try to see if there are other plugins available.

    Best regards,

Viewing 4 posts - 1 through 4 (of 4 total)
  • You must be logged in to reply to this topic.