• Resolved fakiasingh

    (@fakiasingh)


    Hey,
    So, my client is a greengrocer and I’ve made a site for her. She is asking me if she can change the prices or not.
    As we know the prices of the fruits and vegetables changes everyday. She don’t want to waste her time to update each and every variation everyday. Is there a way where she can add a price for a variable product and the prices are autocalculated for other variations of that product?
    For e.g. if I’m adding a price for 1kg tomato. The price should be auto-calculated for 250g tomato or 500g. I don’t want to enter the price for each variation.
    Please, help!

Viewing 4 replies - 1 through 4 (of 4 total)
  • Hi @fakiasingh,

    I did the same thing for my client but in an indifferent manner. For you I think you should add a meta box for price for each variation product and then calculate the price according to the variation title through custom code which will populate the price according to that meta box through jQuery.

    for reference, you can check my code out in jQuery,

    <script>
            jQuery(document).ready(function(){
                jQuery(document).on('keyup','input[id^="ci_per_delivery"]', function(){
                    var id = jQuery(this).attr('variation_id');
                    var devlivery = jQuery(this).attr('deliveries');
                    var price = jQuery(this).val()
                    console.log(id);
                    
                    jQuery('input[id^="ci_total_amount['+id+']').val(price*devlivery);
                } )
            });
        </script>

    Hope this helps you out

    Thank You

    Thread Starter fakiasingh

    (@fakiasingh)

    Thank you so much for your time, but I’m afraid I’m quite not familiar with jQuery.
    Can you walk me through it.
    P.S. Sorry with the late reply!

    Mirko P.

    (@rainfallnixfig)

    Hi @fakiasingh,

    Thanks for reaching out to the WooCommerce forum!

    Kindly note this particular forum is more focused on the default functions packaged with the core WooCommerce plugin. For more development-oriented questions like yours I can also recommend the following channels:

    I will leave this thread open for now just in case @zworthkey12vaibhav or someone else wants to jump in to help.

    Thanks.

    Mirko P.

    (@rainfallnixfig)

    Hi there,

    We’ve not heard back from you in a while so I’ll go ahead and mark this thread as resolved. I hope you will find the above information useful.

    Please feel free to create a new thread if you have further questions.

    Thanks.

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Auto-calculate variable products’ pricing’ is closed to new replies.