WordPress.org

Ready to get started?Download WordPress

Forums

[Plugin: WP e-Commerce] Remove decimals from product price (1 post)

  1. andersedvardsen
    Member
    Posted 1 year ago #

    Hello,

    I know this is "answered" in other topics, but it really is not i am afraid. Read on.

    Can anyone help me get rid of the two decimals after the products price. I have managed to do this for products with variations, but not products without variations. I have searched everywhere and tried multiple solutions. About every solution removes the decimals, but ONLY for products with variations. None of the changes i make, in both store settings and PHP, affects the price of products without variations. how is that even possible?

    Site:
    http://www.skaugsport.no

    The currency is Norwegian Kroner (NOK). Lets say i have a product with the price 5000 NOK:

    With variations the product shows like this: NOK 5,000.00
    Without variations the product shows like this: 5,000.00

    when i change the settings of the currency placement and stuff, it applies only to the ones with variations.

    I have tried the four following fixes, which all solved the problem for products with variations:

    1.

    .../wp-content/plugins/wp-e-commerce/wpsc-includes/processing.functions.php

    line ~26

    $decimals = 2; // default is 2

    change to:

    $decimals = 0; // default is 2

    2.

    change display-items-functions.php,

    <div class='wpsc_floatleft' style="width:85px;">
    <label><?php _e( 'Price', 'wpsc' ); ?>:</label>
    <input type='text' class='text' size='10' name='meta[_wpsc_price]' value='<?php echo ( isset($product_data['meta']['_wpsc_price']) ) ? number_format( (float)$product_data['meta']['_wpsc_price'], 2, '.', '' ) : 'xx.00'; ?>' />
    </div>

    to

    <div class='wpsc_floatleft' style="width:85px;">
    <label><?php _e( 'Price', 'wpsc' ); ?>:</label>
    <input type='text' class='text' size='10' name='meta[_wpsc_price]' value='<?php echo ( isset($product_data['meta']['_wpsc_price']) ) ? number_format( (float)$product_data['meta']['_wpsc_price'], 0, '.', '' ) : 'xx'; ?>' />
    </div>

    3.

    adding the following to functions.php

    add_filter( 'wpsc_toggle_display_currency_code', 'amu_hide_decimal_point' );
    function amu_hide_decimal_point( $args ) {
    $args['display_decimal_point'] = false;
    return $args;
    }

    4.

    adding the following to functions.php

    add_filter( 'wpsc_modify_decimals', '__return_zero' );

    How can i fix this problem? Please help me out with this,as my client is mad, and i can make sense of it.

Topic Closed

This topic has been closed to new replies.

About this Topic