X-Cart: shopping cart software

X-Cart forums (https://forum.x-cart.com/index.php)
-   Changing design (https://forum.x-cart.com/forumdisplay.php?f=51)
-   -   Weight to three decimal places (https://forum.x-cart.com/showthread.php?t=25766)

vixnfox 10-13-2006 01:51 AM

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

syddos 10-13-2006 04:57 AM

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.

vixnfox 10-13-2006 05:36 AM

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

syddos 10-13-2006 08:54 AM

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.

vixnfox 10-13-2006 05:06 PM

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

syddos 10-14-2006 06:25 AM

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.

vixnfox 10-14-2006 06:03 PM

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

ITVV 08-02-2007 06:03 AM

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

sparrowdog 06-17-2008 12:59 AM

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?


All times are GMT -8. The time now is 06:35 PM.

Powered by vBulletin Version 3.5.4
Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.