Follow us on Twitter X-Cart on Facebook Wiki
Shopping cart software Solutions for online shops and malls
 

Weight to three decimal places

 
Reply
   X-Cart forums > X-Cart 4 > Dev Questions > Changing design
 
Thread Tools Search this Thread
  #1  
Old 10-13-2006, 01:51 AM
 
vixnfox vixnfox is offline
 

Advanced Member
  
Join Date: Feb 2006
Location: Adelaide, South Australia
Posts: 82
 

Default Weight to three decimal places

Hi,
i deal in jewellery components whose weight is often 1gram or less.
I changed weight in database xcart_products to decimal(12,3) with default weight of 0.001 (1gram)
I also changed this line in product_details.tpl from
Code:
<input type="text" name="weight" size="18" value="{ $product.weight|formatprice|default:$zero }" />
to
Code:
<input type="text" name="weight" size="18" value="{ $product.weight|default:$zero }" />
to get three decimal places in my modify product template, but if I enter 0.001 for a weight it always comes back as 0.000. If I put 0.009 it will return rounded to 0.010. I dont know how to modify the function .Any clue?

vixnfox
__________________
V 4.3.1 Live:

Developing on
PHP 5.3.0
MySQL server 5.0.75-community-log
MySQL client 5.1.36
Web server Apache/2.2.11 (Unix) mod_ssl/2.2.11
Windows 7 64bit on a Toshiba Satellite P500

ADELAIDE, SOUTH AUSTRALIA
Reply With Quote
  #2  
Old 10-13-2006, 04:57 AM
 
syddos syddos is offline
 

eXpert
  
Join Date: Sep 2002
Location: London, England, UK
Posts: 259
 

Default Re: Weight to three decimal places

In the Uk we use metric for weights etc, and this is one of the first things I change in all the X-cart Pro versions I've tested.

You will have to change several tpl files in addition to the 12/3 decimal in the database.

I posted some info on the following link in June about this.

http://forum.x-cart.com/showpost.php?p=127842&postcount=75

Note Also that
Code:
{ $product.weight|formatprice|default:$zero }
would need to be changed to
Code:
{ $product.weight|formatnumeric|default:$zero }
to produce 3 decimal places as in 2.756g.

I will search my system for the list of files and changes required and post back.
__________________
Syddos

Nothing is impossible, We just don't know how to do it ........Yet!

Xcart 4.1.X PRO (Testing Platform: winXP Pro)
Perl 5.8.7 (win32)
WINAMP 1.6.3 (win32 server package. Includes the following)
- phpMyAdmin v2.8.03
- MySql 5.0.21
- Apache 2.0.55 (win32)
- php 5.1.4
- SQLitemanager 1.2.0
Reply With Quote
  #3  
Old 10-13-2006, 05:36 AM
 
vixnfox vixnfox is offline
 

Advanced Member
  
Join Date: Feb 2006
Location: Adelaide, South Australia
Posts: 82
 

Default Re: Weight to three decimal places

Many thanks syddos. I will look forward to it. Pity metric wasnt catered to fully as an option.

vixnfox
__________________
V 4.3.1 Live:

Developing on
PHP 5.3.0
MySQL server 5.0.75-community-log
MySQL client 5.1.36
Web server Apache/2.2.11 (Unix) mod_ssl/2.2.11
Windows 7 64bit on a Toshiba Satellite P500

ADELAIDE, SOUTH AUSTRALIA
Reply With Quote
  #4  
Old 10-13-2006, 08:54 AM
 
syddos syddos is offline
 

eXpert
  
Join Date: Sep 2002
Location: London, England, UK
Posts: 259
 

Default Re: Weight to three decimal places

Note: I only have an X-Cart PRO license, and only v4.1.X setup for testing, so the skin1 directories may differ for X-Cart GOLD and Gold versions.

DATABASE TABLES
Using phpadmin or similar editor, view the ⌠structure page■

xcart_products
In the FIELD column locate weight
In the TYPE column, change the entry from decimal(12,2) to decimal(12,3)
In the DEFAULT column, change 0.00 to 0.000

xcart_shipping
In the FIELD column locate weight_min and weight_limit
In the TYPE column, change the entry from decimal(12,2) to decimal(12,3)
In the DEFAULT column, change 0.00 to 0.000

xcart_shipping_rates
In the FIELD column locate minweight and maxweight
In the TYPE column, change the entry from decimal(12,2) to decimal(12,3)
In the DEFAULT column, change 0.00 to 0.000


TEMPLATE FILES
admin/main/shipping.tpl

This following appears in 3 lines of code, each in a different template section, also make sure to check the extreme RIGHT of the editing page, as some of these lines a very long.

Code:
Search for "data[{$s.shippingid}][weight_min]" Change value="{$s.weight_min|default:0.00|formatprice}" To value="{$s.weight_min|default:0.000|formatnumeric}" For "data[{$s.shippingid}][weight_limit]" Change value="{$s.weight_limit|formatprice}" To value="{$s.weight_limit|formatnumeric}"

Code:
The following appears in 1 line of code only in this template. Search for "add[weight_min]" Change value="{0.00|formatprice}" To value="{0.000|formatnumeric}" For "add[weight_limit]" Change value="{0.00|formatprice}" To value="{0.000|formatnumeric}"

----------------------------------------------------------------------------------------------------------------------------------

customer/main/product.tpl
Search for {if $product.weight ne "0.00"}
Change to {if $product.weight ne "0.000"}

Search for {$product.weight|formatprice}
Change to {$product.weight|formatnumeric}

----------------------------------------------------------------------------------------------------------------------------------

skin1/main/product_details.tpl
Search for { $product.weight|formatprice|default:$zero }
Change to { $product.weight|formatnumeric|default:$zero }

----------------------------------------------------------------------------------------------------------------------------------

provider or admin/main/shipping_rates.tpl
Code:
Search for "posted_data[{$shipping_rate.rateid}][minweight]" Change value="{$shipping_rate.minweight|formatprice}" To value="{$shipping_rate.minweight|formatnumeric}" For "posted_data[{$shipping_rate.rateid}][maxweight]" Change value=■{$shipping_rate.maxweight|formatprice}■ To value="{$shipping_rate.maxweight|formatnumeric}"

These changes will display 3 decimal places on product pages, and on the "Add"/"Display" admin/provider shipping and shipping rates pages.
__________________
Syddos

Nothing is impossible, We just don't know how to do it ........Yet!

Xcart 4.1.X PRO (Testing Platform: winXP Pro)
Perl 5.8.7 (win32)
WINAMP 1.6.3 (win32 server package. Includes the following)
- phpMyAdmin v2.8.03
- MySql 5.0.21
- Apache 2.0.55 (win32)
- php 5.1.4
- SQLitemanager 1.2.0
Reply With Quote
  #5  
Old 10-13-2006, 05:06 PM
 
vixnfox vixnfox is offline
 

Advanced Member
  
Join Date: Feb 2006
Location: Adelaide, South Australia
Posts: 82
 

Default Re: Weight to three decimal places

That is excellent!! Thank you. I had found the shipping.tpl references and rhe xcart_products table but hadnt thought about the other files and tables you mentioned.
Metric rocks!!

vixnfox
__________________
V 4.3.1 Live:

Developing on
PHP 5.3.0
MySQL server 5.0.75-community-log
MySQL client 5.1.36
Web server Apache/2.2.11 (Unix) mod_ssl/2.2.11
Windows 7 64bit on a Toshiba Satellite P500

ADELAIDE, SOUTH AUSTRALIA
Reply With Quote
  #6  
Old 10-14-2006, 06:25 AM
 
syddos syddos is offline
 

eXpert
  
Join Date: Sep 2002
Location: London, England, UK
Posts: 259
 

Default Re: Weight to three decimal places

Glad to help.

I often wonder how many UK and European X-Cart owners have not spotted that they cannot enter metric weights for any product that falls between X.100g and X.999g, without X-Cart converting it to X.10g and X.99g.
__________________
Syddos

Nothing is impossible, We just don't know how to do it ........Yet!

Xcart 4.1.X PRO (Testing Platform: winXP Pro)
Perl 5.8.7 (win32)
WINAMP 1.6.3 (win32 server package. Includes the following)
- phpMyAdmin v2.8.03
- MySql 5.0.21
- Apache 2.0.55 (win32)
- php 5.1.4
- SQLitemanager 1.2.0
Reply With Quote
  #7  
Old 10-14-2006, 06:03 PM
 
vixnfox vixnfox is offline
 

Advanced Member
  
Join Date: Feb 2006
Location: Adelaide, South Australia
Posts: 82
 

Default Re: Weight to three decimal places

Yes it makes you think. I ran a test order on products supposed to be 0.1 grams and soon reached the max weight limit, was most frustrating and prompted this thread.

Just a slight variation, I only really needed weight to 0.1 grams (many components are even less, but I aint weighing them!!) so I adjusted accordingly (12,1 default 0.0) and modded the files you listed accordingly. Works a treat!

Of course I had to redo all my shipping charges, no big deal, oh and also in General settings changed the default weight symbol to grams, and specify 1 as the unit of weight defined by the symbol.

vixnfox
__________________
V 4.3.1 Live:

Developing on
PHP 5.3.0
MySQL server 5.0.75-community-log
MySQL client 5.1.36
Web server Apache/2.2.11 (Unix) mod_ssl/2.2.11
Windows 7 64bit on a Toshiba Satellite P500

ADELAIDE, SOUTH AUSTRALIA
Reply With Quote
  #8  
Old 08-02-2007, 06:03 AM
 
ITVV ITVV is online now
 

X-Wizard
  
Join Date: Nov 2006
Location: UK
Posts: 1,167
 

Default Re: Weight to three decimal places

Hi Syddos,

Many thanks for a great mod. Works fantastic in 4.1.7.

Just one thing if anyone is working with product variants then you will also need to change the following so that the change shows up in Admin / Products / Variants screen: -

skin1/admin/main/product_links.tpl

Find this {if $product.weight ne "0.00"}
Change to {if $product.weight ne "0.000"}

Next

skin1/modules/product_Options/product_variants.tpl

Find this {$v.weight|formatprice}
Change to {$v.weight|formatnumeric}

Once again many thanks

Kind regards

Nick
__________________
X-Cart Pro 4.7.12 Active and working great with reBOOT-reDUX
X-Cart Pro 4.6.6 Retired after 6 years of first class service
X-Cart Pro 4.1.7 Retired after 9 years of first class service

Apache: 2.4.25
PHP: 7.4.5
MariaDB: 10.1.44
Arch: x86_64
Reply With Quote
  #9  
Old 06-17-2008, 12:59 AM
 
sparrowdog sparrowdog is offline
 

eXpert
  
Join Date: Jan 2007
Posts: 244
 

Default Re: Weight to three decimal places

I'm trying to get this working with 4.1.6 and I can't find the admin/main/shipping_rates.tpl file.

Is this named something different in 4.1.6?
__________________
Version 4.1.6 to 4.1.11
Reply With Quote
Reply
   X-Cart forums > X-Cart 4 > Dev Questions > Changing design



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump


All times are GMT -8. The time now is 11:02 AM.

   

 
X-Cart forums © 2001-2020