Viewing 10 replies - 1 through 10 (of 10 total)
  • Plugin Contributor Mike Jolley

    (@mikejolley)

    Adapt this for your usage https://gist.github.com/mikejolley/4150218

    Thread Starter cavarmarketing

    (@cavarmarketing)

    Hey thanks a lot!

    Where do i add the script?
    Im sorry im pretty new to customizing =)

    Plugin Contributor Mike Jolley

    (@mikejolley)

    functions.php of your theme. Then modify whats inside.

    Thread Starter cavarmarketing

    (@cavarmarketing)

    Hey Mike!

    Thanks again for your quick replies!
    I’ve added the code, but all it does is, it shows me “+VAT” behind the price.

    I need something else tho.
    I need something, that shows the price per litre next to the full price.
    Our icecontainers always contain 5.2 litres.

    So for example something i need would be: €36,14 (€6,95 / l)

    Can you help me with this?
    Best reagards & Blessings

    Plugin Contributor Mike Jolley

    (@mikejolley)

    I know it’s not what you needed exactly, thats why I said it needed modification. The code snippet shows how to append any text after product prices. So this is what you’re need to adapt to show unit prices.

    Thread Starter cavarmarketing

    (@cavarmarketing)

    Ok great! got it!

    Ill try to code it tommorow! =)

    Hi,

    I would need the same function. Is there any ready plugin to do this? Kiloprice is a required field (by law), so would think someone has done a simple plugin for it. Any ideas?

    – Anne

    Thread Starter cavarmarketing

    (@cavarmarketing)

    Hey!

    So i tried to make it work and added text behind the price. The problem ist, i want to add price / 5.2 . The $price variable tho is not the “naked price”, its a price with the currency symbol, which makes it hard for me to figure out, how to divide it though 5.2.

    This is my actual Code:

    add_filter( 'woocommerce_get_price_html', 'price_plus_vat' );
    
    function price_plus_vat( $price ) {
         return $price . ' ' . __(  '(' . '€' . $price / 5.2 . '/Liter' . ')', 'woocommerce' );
    }

    When i run that tho it’ll show (€0) behind the price and not divide it.
    Please help me

    Plugin Contributor Mike Jolley

    (@mikejolley)

    add_filter( 'woocommerce_get_price_html', 'price_plus_vat', 10, 2 );
    
    function price_plus_vat( $price, $product ) {
         return $price . ' ' . __(  '(' . '€' . ( $product->get_price() / 5.2 ) . '/Liter' . ')', 'woocommerce' );
    }
    Thread Starter cavarmarketing

    (@cavarmarketing)

    WOW thank you so much =)!!!

Viewing 10 replies - 1 through 10 (of 10 total)
  • The topic ‘Can i show "price per Kilo"?’ is closed to new replies.