WooCommerce Product Page -how to display Total Price = Default Quantity x Unit Price where Default Quantity =500

  • Unknown's avatar

    Dear Forum members,

    I’m setting up an online print shop and will allow customers to order business cards for example in multiples of 500 units.

    I’ve installed the “WooCommerce Min Max Quantity & Step Control Global” plugin.
    -Settings (Universal):
    – -Minimum Quantity: 500
    – -Maximum Quantity:
    – -Quantity Step: 500

    I’ve setup the Product Total price to display on the Product page. Unfortunately, the “WooCommerce Product Price x Quantity Preview” plugin is not up to date in order to work on my site, and so I’ve had to locate the necessary code on a forum and add it to my theme’s functions.php file -see below.

    The default Quantity = 500 units.
    The unit price = $0.68 regardless of the quantity.
    The default Total Price incorrectly displays the unit price i.e. $0.68 until the user changes the quantity.
    Once the user changes the quantity (in increments of 500) then the correct Total Price displays i.e. = Quantity x Unit Price.

    Could someone please rectify the code such that the default Total Price = default Quantity (i.e. 500) x Unit Price?

    Thank you.

    add_action( ‘woocommerce_single_product_summary’, ‘woocommerce_total_product_price’, 31 );
    function woocommerce_total_product_price() {
    global $woocommerce, $product;
    // let’s setup our divs
    echo sprintf(‘

    %s %s

    ‘,__(‘Product Total AUD ex tax:’,’woocommerce’),’‘. get_woocommerce_currency_symbol() .’ ‘ .$product->get_price().’‘);
    ?>

    jQuery(function($){
    var price = get_price(); ?>,
    currency = ”;

    $(‘[name=quantity]’).change(function(){
    if (!(this.value < 1)) {

    var product_total = parseFloat(price * this.value);

    $('#product_total_price .price').html( currency + product_total.toFixed(2));

    }
    });
    });

    <?php
    }

  • Hi there,

    If you have WooCommerce installed on a WordPress.com Business Plan or have a paid WooCommerce extension on a self-hosted site you can open a ticket while logged into your account at:

    https://woocommerce.com/my-account/create-a-ticket/

    But, if your site is self-hosted and built using the WordPress.org open software, you’ll need to seek assistance from their forums which can be found at:

    https://wordpress.org/support/plugin/woocommerce

    These forums are for WordPress.com hosted websites. If you want to know the difference between the two, you can find more information in this document:

    WordPress.com vs. WordPress.org

  • Unknown's avatar

    Sorry. I mistakenly thought I was in the right forum because I was able to login. I’ll try wordpress.org.

    Thank you.

  • The topic ‘WooCommerce Product Page -how to display Total Price = Default Quantity x Unit Price where Default Quantity =500’ is closed to new replies.