Jump to content

[SOLVED]How to add packaging weight?


Recommended Posts

Tried to search but I can't find the solution. There is one posting asking the same question but no answer.
If doing it the right way is not possible, can we do it the left way? :-)
What I mean is planting it in the code?
I want to add 0.07 Kg per order. Is this possible? if yes, which file?
I know a bit of programming, I think I can do it.

I'm using PS1.3.2

Thanks,
boy

Link to comment
Share on other sites

You will need to modify a couple of functions. Change lines 939-940 of classes/Cart.php (in PrestaShop v1.3.2) from:

$this->_totalWeight = round(floatval($result['nb']) + floatval($result2['nb']), 3);
return $this->_totalWeight;



to:

$this->_totalWeight = round(floatval($result['nb']) + floatval($result2['nb']), 3);
$this->_totalWeight += 0.07;
return $this->_totalWeight;



and line 793 of classes/Order.php from:

return floatval($result['weight']);



to:

return 0.07 + floatval($result['weight']);

Link to comment
Share on other sites

  • 3 months later...
  • 10 months later...

Hello!

 

This code no longer seems to exist in v1.4

 

Can someone please help shed a light on how to achieve this nowadays?

 

The way the PS system is set up does not integrate well with the way the post works here, so I would need to add a packaging weight to each order.

 

Thanks much!

Link to comment
Share on other sites

  • 2 months later...

alright, figured it out.

 

personally, I still do have 1.4.2.5, though I believe all v1.4 should have the same structure.

 

You gotta change this:

 

self::$_totalWeight[$this->id] = round((float)($result['nb']) + (float)($result2['nb']), 3);

 

to

 

self::$_totalWeight[$this->id] = round((float)($result['nb']) + (float)($result2['nb']), 3);
self::$_totalWeight[$this->id] += 0.05;

 

where in my case, I added 50 grams to every order for packaging purposes. (0.05)

 

In terms of Order.php, code is the same in v1.4, therefore I'm not reposting it once again.

 

hope this helps

  • Like 1
Link to comment
Share on other sites

  • 1 year later...
  • 7 months later...

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...