Change WooCommerce Price to be by Weight

You can change the WooCommerce price to be by weight by appending some text after the actual price such as ‘per kg’, this can be done by manipulating 3 filters that display the price in the shop/product page, cart and checkout pages;

woocommerce_get_price_html
woocommerce_cart_item_price
woocommerce_checkout_cart_item_quantity

If all items were to be classified as ‘per kg‘ you could use the filters as below…

In the checkout filter I dropped the ‘per kg’ and just left ‘kg’ as the unit price is not used rather the total price.

woocommerce-checkout-weight woocommerce-by-weight

woocommerce-cart-weight

 

If you need more variations on the weight or to use a per item/unit options consider using ACF with a select field that can easily be changed per product.

 

Leave a Comment





%d bloggers like this: